From d29b097216dd47b546955aac73e6a6f74d80b0ef Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 26 Nov 2012 14:20:13 +0530 Subject: [PATCH] Viewer: Fix vertical margin at the top of the first page incorrect in a certain rare circumstance (first child of body being an empty paragraph). Fixes #1082640 (ebook-viewer: top line of the text is cut off when using two-paged mode) --- resources/compiled_coffeescript.zip | Bin 59820 -> 60149 bytes src/calibre/ebooks/oeb/display/paged.coffee | 12 ++++++++++++ 2 files changed, 12 insertions(+) diff --git a/resources/compiled_coffeescript.zip b/resources/compiled_coffeescript.zip index 215d6a2cb488d9db43dbe9cf77f3e74f6db1e24e..72ed709700d477b436218df4f01ac5ff9abfbd77 100644 GIT binary patch delta 508 zcmZ2;nfdEgW|;tQW)=|!5U?n!a-8*A^36RD1_lt8W|(a7QgpMgiaVc>jzV&NPJDT0 zN=XKYS(;a}d5+N@*7{@xTZNST31J7=f*gQi zhW$?MHIWOEaX(lhgPlTy?2i&E8f6x0pWHDMOjZVt3qZoHX`OGauT7uV#|F9bGo zg*#0cQYE1#=O_Eq7Sy!(Z~WG*fN9&kK>32{$Q;7``&;-1X%QebkZ6tZMeBv`US xif?kyb1f$GWH9&ab19%*QcT9VVD6t6Mof>YfJ|4WPq)D$Juju$uD$>n4*+NjnUnwk delta 205 zcmex*m3hr&W|jbNW|qnOUrKEbO@70@$fy7n>H^J`VtSPg*5mrhh-qdenA!Kr SfNA9|F!SmwDYl;HAe{g=?n}l1 diff --git a/src/calibre/ebooks/oeb/display/paged.coffee b/src/calibre/ebooks/oeb/display/paged.coffee index b8a7310659..c5f2dbc97a 100644 --- a/src/calibre/ebooks/oeb/display/paged.coffee +++ b/src/calibre/ebooks/oeb/display/paged.coffee @@ -116,6 +116,18 @@ class PagedDisplay # above the columns, which causes them to effectively be added to the # page margins (the margin collapse algorithm) bs.setProperty('-webkit-margin-collapse', 'separate') + # Remove any webkit specified default margin from the first child of body + # Otherwise, you could end up with an effective negative margin, I dont + # understand exactly why, but see: + # https://bugs.launchpad.net/calibre/+bug/1082640 for an example + c = document.body.firstChild + count = 0 + while c?.nodeType != 1 and count < 20 + c = c?.nextSibling + count += 1 + if c?.nodeType == 1 + c.style.setProperty('-webkit-margin-before', '0') + bs.setProperty('overflow', 'visible') bs.setProperty('height', (window.innerHeight - this.margin_top - this.margin_bottom) + 'px')