Ensure WebKit sizes columns correctly

This commit is contained in:
Kovid Goyal 2016-04-29 20:30:35 +05:30
parent 83548b11b4
commit 11136aab92

View File

@ -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