mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
Ensure WebKit sizes columns correctly
This commit is contained in:
parent
83548b11b4
commit
11136aab92
@ -178,12 +178,22 @@ def layout(is_single_page):
|
|||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def check_column_widths():
|
||||||
ncols = (document.body.scrollWidth + gap) / col_and_gap
|
ncols = (document.body.scrollWidth + gap) / col_and_gap
|
||||||
if ncols is not Math.floor(ncols):
|
if ncols is not Math.floor(ncols):
|
||||||
n = Math.floor(ncols)
|
n = Math.floor(ncols)
|
||||||
dw = (n*col_width + (n-1)*gap)
|
dw = (n*col_width + (n-1)*gap)
|
||||||
document.body.width = dw + 'px'
|
data = {'col_with':col_width, 'gap':gap, 'scrollWidth':document.body.scrollWidth, 'ncols':ncols, 'desired_width':dw}
|
||||||
print('WARNING: column layout broken', {'col_with':col_width, 'gap':gap, 'scrollWidth':document.body.scrollWidth, 'ncols':ncols, 'delta':document.body.scrollWidth - dw})
|
return data
|
||||||
|
data = check_column_widths()
|
||||||
|
if data:
|
||||||
|
dw = data.desired_width
|
||||||
|
set_css(document.body, max_width=dw + 'px', min_width=dw + 'px')
|
||||||
|
set_css(document.documentElement, max_width=dw + 'px', min_width=dw + 'px')
|
||||||
|
data = check_column_widths()
|
||||||
|
if data:
|
||||||
|
print('WARNING: column layout broken', data)
|
||||||
|
|
||||||
_in_paged_mode = True
|
_in_paged_mode = True
|
||||||
fit_images()
|
fit_images()
|
||||||
return gap
|
return gap
|
||||||
|
Loading…
x
Reference in New Issue
Block a user