This commit is contained in:
Kovid Goyal 2012-06-20 17:43:49 +05:30
parent 6919614d36
commit 8de0c610ea
2 changed files with 9 additions and 12 deletions

Binary file not shown.

View File

@ -73,16 +73,13 @@ class PagedDisplay
this.cols_per_screen = cols_per_screen this.cols_per_screen = cols_per_screen
layout: () -> layout: () ->
# Remove the top margin from the first child of body as that gets added # When laying body out in columns, webkit bleeds the top margin of the
# to the top margin of body. This is done here just in case # first block element out above the columns, leading to an extra top
# getComputedStyle() causes a relayout. The re-layout will be much # margin for the page. We compensate for that here. Computing the
# faster before we implement the multi-column layout. # boundingrect of body is very expensive with column layout, so we do
for node in document.body.childNodes # it before the column layout is applied.
if node.nodeType == 1 # Element node document.body.style.marginTop = '0px'
style = window.getComputedStyle(node) extra_margin = document.body.getBoundingClientRect().top
if style.display in ['block', 'table']
node.style.setProperty('margin-top', '0px')
break
ww = window.innerWidth ww = window.innerWidth
@ -110,9 +107,9 @@ class PagedDisplay
bs.setProperty('-webkit-column-width', col_width+'px') bs.setProperty('-webkit-column-width', col_width+'px')
bs.setProperty('-webkit-column-rule-color', fgcolor) bs.setProperty('-webkit-column-rule-color', fgcolor)
bs.setProperty('overflow', 'visible') bs.setProperty('overflow', 'visible')
bs.setProperty('height', 'auto') bs.setProperty('height', (window.innerHeight - this.margin_top - this.margin_bottom) + 'px')
bs.setProperty('width', 'auto') bs.setProperty('width', 'auto')
bs.setProperty('margin-top', this.margin_top+'px') bs.setProperty('margin-top', (this.margin_top - extra_margin)+'px')
bs.setProperty('margin-bottom', this.margin_bottom+'px') bs.setProperty('margin-bottom', this.margin_bottom+'px')
bs.setProperty('margin-left', sm+'px') bs.setProperty('margin-left', sm+'px')
bs.setProperty('margin-right', sm+'px') bs.setProperty('margin-right', sm+'px')