E-book viewer: Fix clicking links going to slightly incorrect locations in some books. Fixes #1132641 (Private bug)

This commit is contained in:
Kovid Goyal 2013-02-27 13:22:10 +05:30
parent 8add71a50c
commit 40daeaa9b4
4 changed files with 9 additions and 2 deletions

Binary file not shown.

View File

@ -81,6 +81,11 @@ class BookIndexing
if elem == null
pos = [body.scrollWidth+1000, body.scrollHeight+1000]
else
# Because of a bug in WebKit's getBoundingClientRect() in
# column mode, this position can be inaccurate,
# see https://bugs.launchpad.net/calibre/+bug/1132641 for a
# test case. The usual symptom of the inaccuracy is br.top is
# highly negative.
br = elem.getBoundingClientRect()
pos = viewport_to_document(br.left, br.top, elem.ownerDocument)

View File

@ -410,7 +410,7 @@ class PagedDisplay
elem.scrollIntoView()
if this.in_paged_mode
# Ensure we are scrolled to the column containing elem
this.scroll_to_xpos(calibre_utils.absleft(elem) + 5)
this.scroll_to_xpos(calibre_utils.viewport_to_document(elem.scrollLeft+this.margin_side, elem.scrollTop, elem.ownerDocument)[0])
snap_to_selection: () ->
# Ensure that the viewport is positioned at the start of the column

View File

@ -86,7 +86,9 @@ class CalibreUtils
absleft: (elem) -> # {{{
# The left edge of elem in document co-ords. Works in all
# circumstances, including column layout. Note that this will cause
# a relayout if the render tree is dirty.
# a relayout if the render tree is dirty. Also, because of a bug in the
# version of WebKit bundled with Qt 4.8, this does not always work, see
# https://bugs.launchpad.net/bugs/1132641 for a test case.
r = elem.getBoundingClientRect()
return this.viewport_to_document(r.left, 0, elem.ownerDocument)[0]
# }}}