aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content_scripts/link_hints.coffee15
-rw-r--r--lib/dom_utils.coffee7
2 files changed, 13 insertions, 9 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index b5fa527d..783e6369 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -399,8 +399,11 @@ class LinkHintsMode
installKeyboardBlocker = (startKeyboardBlocker) ->
if linkMatched.isLocalMarker
- flashEl = DomUtils.addFlashRect linkMatched.rect
- HintCoordinator.onExit.push -> DomUtils.removeElement flashEl
+ {top: viewportTop, left: viewportLeft} = DomUtils.getViewportTopLeft()
+ for rect in (Rect.copy rect for rect in clickEl.getClientRects())
+ extend rect, top: rect.top + viewportTop, left: rect.left + viewportLeft
+ flashEl = DomUtils.addFlashRect rect
+ do (flashEl) -> HintCoordinator.onExit.push -> DomUtils.removeElement flashEl
if windowIsFocused()
startKeyboardBlocker (isSuccess) -> HintCoordinator.sendMessage "exit", {isSuccess}
@@ -811,13 +814,7 @@ LocalHints =
nonOverlappingElements.push visibleElement unless visibleElement.secondClassCitizen
# Position the rects within the window.
- if getComputedStyle(document.documentElement).position == "static"
- top = window.scrollY
- left = window.scrollX
- else
- rect = document.documentElement.getBoundingClientRect()
- top = -rect.top
- left = -rect.left
+ {top, left} = DomUtils.getViewportTopLeft()
for hint in nonOverlappingElements
hint.rect.top += top
hint.rect.left += left
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index 8e953405..82c13287 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -288,6 +288,13 @@ DomUtils =
flashEl = @addFlashRect rect
setTimeout((-> DomUtils.removeElement flashEl), 400)
+ getViewportTopLeft: ->
+ if getComputedStyle(document.documentElement).position == "static"
+ top: window.scrollY, left: window.scrollX
+ else
+ rect = document.documentElement.getBoundingClientRect()
+ top: -rect.top, left: -rect.left
+
suppressPropagation: (event) ->
event.stopImmediatePropagation()