Fix #2099678 [Clicking on an article in a newsletter scrolls the Table of Contents to the end](https://bugs.launchpad.net/calibre/+bug/2099678)

This commit is contained in:
Kovid Goyal 2025-03-05 08:26:24 +05:30
parent 0d92c9f7dd
commit c4de6b9bd9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -850,7 +850,7 @@ def handle_gesture(gesture):
def get_bounding_client_rect(elem): def get_bounding_client_rect(elem):
br = elem.getBoundingClientRect() br = elem.getBoundingClientRect()
if br.width is 0 and br.height is 0: if br.width is 0 and br.height is 0 and br.x is 0 and br.y is 0:
# getBoundingClientRect() fails sometimes, see https://bugs.launchpad.net/calibre/+bug/2037543 # getBoundingClientRect() fails sometimes, see https://bugs.launchpad.net/calibre/+bug/2037543
r = document.createRange() r = document.createRange()
r.selectNodeContents(elem) r.selectNodeContents(elem)