From 0428d2e6282b26f338d88b8c6ab5a2fa0c42a968 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 15 Jan 2012 15:22:39 +0530 Subject: [PATCH] EPUB CFI: iframes work --- src/calibre/ebooks/oeb/display/cfi.coffee | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/calibre/ebooks/oeb/display/cfi.coffee b/src/calibre/ebooks/oeb/display/cfi.coffee index 7cdca28fbb..66030bec91 100644 --- a/src/calibre/ebooks/oeb/display/cfi.coffee +++ b/src/calibre/ebooks/oeb/display/cfi.coffee @@ -87,17 +87,17 @@ window_scroll_pos = (win) -> # {{{ # }}} 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 [wx, wy] = window_scroll_pos(win) x += wx 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] # }}}