EPUB CFI: iframes work

This commit is contained in:
Kovid Goyal 2012-01-15 15:22:39 +05:30
parent 6f24d3afa1
commit 0428d2e628

View File

@ -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]
# }}} # }}}