mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
IE strikes again
This commit is contained in:
parent
61340f3e86
commit
68d0bf7080
@ -493,6 +493,16 @@ class CanonicalFragmentIdentifier
|
|||||||
r.surroundContents(span)
|
r.surroundContents(span)
|
||||||
span.scrollIntoView()
|
span.scrollIntoView()
|
||||||
fn = ->
|
fn = ->
|
||||||
|
# Remove the span and get the new position now that scrolling
|
||||||
|
# has (hopefully) completed
|
||||||
|
#
|
||||||
|
# In WebKit, the boundingrect of the span is wrong in some
|
||||||
|
# situations, whereas in IE resetting the range causes it to
|
||||||
|
# loose bounding info. So we use the range's rects unless they
|
||||||
|
# are absent, in which case we use the span's rect
|
||||||
|
#
|
||||||
|
rect = span.getBoundingClientRect()
|
||||||
|
|
||||||
# Remove the span we inserted
|
# Remove the span we inserted
|
||||||
p = span.parentNode
|
p = span.parentNode
|
||||||
for node in span.childNodes
|
for node in span.childNodes
|
||||||
@ -501,10 +511,13 @@ class CanonicalFragmentIdentifier
|
|||||||
p.removeChild(span)
|
p.removeChild(span)
|
||||||
p.normalize()
|
p.normalize()
|
||||||
|
|
||||||
# Reset the range to what it was before span
|
# Reset the range to what it was before the span was added
|
||||||
r.setStart(sc, so)
|
r.setStart(sc, so)
|
||||||
r.setEnd(ec, eo)
|
r.setEnd(ec, eo)
|
||||||
rect = r.getClientRects()[0]
|
rects = r.getClientRects()
|
||||||
|
if rects.length > 0
|
||||||
|
rect = rects[0]
|
||||||
|
|
||||||
x = (point.a*rect.left + (1-point.a)*rect.right)
|
x = (point.a*rect.left + (1-point.a)*rect.right)
|
||||||
y = (rect.top + rect.bottom)/2
|
y = (rect.top + rect.bottom)/2
|
||||||
[x, y] = viewport_to_document(x, y, ndoc)
|
[x, y] = viewport_to_document(x, y, ndoc)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user