From 40daeaa9b4a4eb9cf2f96fa082a20df37d3c6119 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 27 Feb 2013 13:22:10 +0530 Subject: [PATCH] E-book viewer: Fix clicking links going to slightly incorrect locations in some books. Fixes #1132641 (Private bug) --- resources/compiled_coffeescript.zip | Bin 67910 -> 67988 bytes .../ebooks/oeb/display/indexing.coffee | 5 +++++ src/calibre/ebooks/oeb/display/paged.coffee | 2 +- src/calibre/ebooks/oeb/display/utils.coffee | 4 +++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/resources/compiled_coffeescript.zip b/resources/compiled_coffeescript.zip index c9ed50891303fb20e5c16b5295525d5a516a0a94..726167b97cb6473611e9ad552756f757e934febf 100644 GIT binary patch delta 385 zcmX>$iDk-U7Ks3FW)=|!5LlKK?X>mF;_C^a3=9dOllkf;HyY-9PS#Tu^-9f2&DAST zF3Qiz@kvc9QP5T>$;d3$%S|jw&&-Q2&P++wQ9x1?l3xJj=a=WD7P;gnm*%GCm1ssA z#BSc`xrCbqWYuPt`qjKF%R#Kj&}*Wb7yYv2nd}?Nv6!WlYxCwFp2SJ@ESrt9FLG|) z|MoV|^xJHVT)Zewoc@W8(MACzq+oPIp^TS-0feQ&et{7)Lnk|Ci%$3CU=&dRS+ymw zpktmW0|N-l!4!dMk7SU_$u*(e)AQIFd8WVTV3cE0s+`Wx$*4SiKRcraQ*tZVtbgo` zQqvPT7^Rrv`zIglk)A$-1E{=;9jHA215kzX^t~YcOF;TveoemkR$eT?o0Sb@2?r2{ MGchozvoivD0F_^K>Hq)$ delta 286 zcmbO-ndR6d7Ks3FW)=|!5XkS1bXvuINLVP8fk7yA^2SifjfVN2f{97RIjLzS8mT#{ zxta>v3Z|R?doJN-nL1^bfE=??6SHVPm!wgeV*%oAl`0AV?>J79!&=;VZ7qSJq|Gm20Dz`-cTq?$cl zfRj;wdK`%Js{|}NnS)VkdILM76w|jlu)s!kMiG#5mg#GOQcO#GK%$c;^s`Mj=48}j m+WHpAm!Hnc0c6kkHQkVdQCWnQ4P+$;5QZ}`Fx+Hg1o8mFDpU~w diff --git a/src/calibre/ebooks/oeb/display/indexing.coffee b/src/calibre/ebooks/oeb/display/indexing.coffee index cd4a5a83e5..efe42199e9 100644 --- a/src/calibre/ebooks/oeb/display/indexing.coffee +++ b/src/calibre/ebooks/oeb/display/indexing.coffee @@ -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) diff --git a/src/calibre/ebooks/oeb/display/paged.coffee b/src/calibre/ebooks/oeb/display/paged.coffee index 2f698966dd..80aa9b9d7f 100644 --- a/src/calibre/ebooks/oeb/display/paged.coffee +++ b/src/calibre/ebooks/oeb/display/paged.coffee @@ -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 diff --git a/src/calibre/ebooks/oeb/display/utils.coffee b/src/calibre/ebooks/oeb/display/utils.coffee index cc98a06d04..b90fbc55b6 100644 --- a/src/calibre/ebooks/oeb/display/utils.coffee +++ b/src/calibre/ebooks/oeb/display/utils.coffee @@ -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] # }}}