mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -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()
|
||||
)
|
||||
|
||||
ncols = (document.body.scrollWidth + gap) / col_and_gap
|
||||
if ncols is not Math.floor(ncols):
|
||||
n = Math.floor(ncols)
|
||||
dw = (n*col_width + (n-1)*gap)
|
||||
document.body.width = dw + 'px'
|
||||
print('WARNING: column layout broken', {'col_with':col_width, 'gap':gap, 'scrollWidth':document.body.scrollWidth, 'ncols':ncols, 'delta':document.body.scrollWidth - dw})
|
||||
def check_column_widths():
|
||||
ncols = (document.body.scrollWidth + gap) / col_and_gap
|
||||
if ncols is not Math.floor(ncols):
|
||||
n = Math.floor(ncols)
|
||||
dw = (n*col_width + (n-1)*gap)
|
||||
data = {'col_with':col_width, 'gap':gap, 'scrollWidth':document.body.scrollWidth, 'ncols':ncols, 'desired_width':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
|
||||
fit_images()
|
||||
return gap
|
||||
|
Loading…
x
Reference in New Issue
Block a user