mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
EPUB CFI: iframes work
This commit is contained in:
parent
6f24d3afa1
commit
0428d2e628
@ -87,17 +87,17 @@ window_scroll_pos = (win) -> # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
viewport_to_document = (x, y, doc) -> # {{{
|
viewport_to_document = (x, y, doc) -> # {{{
|
||||||
|
until doc == window.document
|
||||||
|
# We are in a frame
|
||||||
|
frame = doc.defaultView.frameElement
|
||||||
|
rect = frame.getBoundingClientRect()
|
||||||
|
x += rect.left
|
||||||
|
y += rect.top
|
||||||
|
doc = frame.ownerDocument
|
||||||
win = doc.defaultView
|
win = doc.defaultView
|
||||||
[wx, wy] = window_scroll_pos(win)
|
[wx, wy] = window_scroll_pos(win)
|
||||||
x += wx
|
x += wx
|
||||||
y += wy
|
y += wy
|
||||||
if doc != window.document
|
|
||||||
# We are in a frame
|
|
||||||
node = win.frameElement
|
|
||||||
rect = node.getBoundingClientRect()
|
|
||||||
[vx, vy] = viewport_to_document(rect.left, rect.top, node.ownerDocument)
|
|
||||||
x += vx
|
|
||||||
y += vy
|
|
||||||
return [x, y]
|
return [x, y]
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user