E-book viewer: Fix incorrect toc navigation in books that link the entries to inline tags that wrap block tags that span multiple pages. Fixes #1918437 [Book reader incorrectly go to table of contents items](https://bugs.launchpad.net/calibre/+bug/1918437)

This commit is contained in:
Kovid Goyal 2021-03-10 22:37:42 +05:30
parent 7b77ab672b
commit 537efd11b1
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -506,7 +506,19 @@ def jump_to_anchor(name):
scroll_to_elem(elem)
def scrollable_element(elem):
# bounding rect calculation for an inline element containing a block
# element that spans multiple columns is incorrect. Detet the common case
# of this and avoid it.
if not in_paged_mode() or window.getComputedStyle(elem).display.indexOf('inline') < 0 or not elem.firstElementChild:
return elem
if window.getComputedStyle(elem.firstElementChild).display.indexOf('block') > -1:
return elem.firstElementChild
return elem
def scroll_to_elem(elem):
elem = scrollable_element(elem)
scroll_viewport.scroll_into_view(elem)
if in_paged_mode():
@ -786,6 +798,7 @@ anchor_funcs = {
'pos_for_elem': def pos_for_elem(elem):
if not elem:
return 0
elem = scrollable_element(elem)
br = elem.getBoundingClientRect()
pos = scroll_viewport.viewport_to_document_inline(
scroll_viewport.rect_inline_start(br))