From 86455fc5f34119f2b989470ee1fca1db51e53d4f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 20 Jun 2012 11:01:13 +0530 Subject: [PATCH 1/2] ... --- src/calibre/gui2/viewer/documentview.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/calibre/gui2/viewer/documentview.py b/src/calibre/gui2/viewer/documentview.py index ad8bff76d4..8c6da27d71 100644 --- a/src/calibre/gui2/viewer/documentview.py +++ b/src/calibre/gui2/viewer/documentview.py @@ -928,6 +928,13 @@ class DocumentView(QWebView): # {{{ self.document.scroll_to(x=loc, y=0) if self.manager is not None: self.manager.scrolled(self.scroll_fraction) + event.accept() + elif self.manager is not None: + if direction == 'next': + self.manager.next_document() + else: + self.manager.previous_document() + event.accept() return if event.delta() < -14: From fcdd96c2bb5b49959326ced7deeddff7131e3196 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 20 Jun 2012 12:20:32 +0530 Subject: [PATCH 2/2] Speed up rendering in paged mode by not causing an extra re-layout to adjust the top margin of body --- src/calibre/ebooks/oeb/display/paged.coffee | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/calibre/ebooks/oeb/display/paged.coffee b/src/calibre/ebooks/oeb/display/paged.coffee index 6096326d7e..454c50bb87 100644 --- a/src/calibre/ebooks/oeb/display/paged.coffee +++ b/src/calibre/ebooks/oeb/display/paged.coffee @@ -82,6 +82,17 @@ class PagedDisplay this.cols_per_screen = cols_per_screen layout: () -> + # Remove the top margin from the first child of body as that gets added + # to the top margin of body. This is done here just in case + # getComputedStyle() causes a relayout. The re-layout will be much + # faster before we implement the multi-column layout. + for node in document.body.childNodes + if node.nodeType == 1 # Element node + style = window.getComputedStyle(node) + if style.display in ['block', 'table'] + node.style.setProperty('margin-top', '0px') + break + ww = window.innerWidth wh = window.innerHeight body_height = wh - this.margin_bottom = this.margin_top @@ -135,11 +146,6 @@ class PagedDisplay priority = rule.style.getPropertyPriority(prop) rule.style.setProperty(cprop, val, priority) - # Ensure that the top margin is correct, otherwise for some documents, - # webkit lays out the body with a lot of space on top - brect = document.body.getBoundingClientRect() - if brect.top > this.margin_top - bs.setProperty('margin-top', (this.margin_top - brect.top)+'px') this.in_paged_mode = true this.current_margin_side = sm return sm