From 81fa2852b9ebfd1a0a2abd8b5ea374ac9bc49ca8 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 10 Apr 2016 11:21:34 +0100 Subject: Make rects absolute in window earlier. This is part of an effort (as yet incomplete) to track down some CSP violations we're getting, in this case related to global link hints. Prior to this, we were seeing CSP violations when accessing the window subsequently to collecting the hints, specifically when accessing window.scrollX/Y. Here, we collect the window position immediately, when initially harvesting the hints. --- content_scripts/link_hints.coffee | 9 +++++++-- lib/dom_utils.coffee | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 6ea10377..083e214e 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -196,8 +196,8 @@ class LinkHintsMode localHintDescriptor = HintCoordinator.getLocalHintMarker desc el = DomUtils.createElement "div" el.rect = localHintDescriptor.rect - el.style.left = el.rect.left + window.scrollX + "px" - el.style.top = el.rect.top + window.scrollY + "px" + el.style.left = el.rect.left + "px" + el.style.top = el.rect.top + "px" extend el, className: "vimiumReset internalVimiumHintMarker vimiumHintMarker" showLinkText: localHintDescriptor.showLinkText @@ -718,6 +718,11 @@ LocalHints = # click some elements that we could click before. nonOverlappingElements.push visibleElement unless visibleElement.secondClassCitizen + # Position the rects within the window. + for hint in nonOverlappingElements + hint.rect.top += window.scrollY + hint.rect.left += window.scrollX + if Settings.get "filterLinkHints" @withLabelMap (labelMap) => extend hint, @generateLinkText labelMap, hint for hint in localHints diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index a57cbedb..3d719337 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -265,8 +265,8 @@ DomUtils = flashEl = @createElement "div" flashEl.id = "vimiumFlash" flashEl.className = "vimiumReset" - flashEl.style.left = rect.left + window.scrollX + "px" - flashEl.style.top = rect.top + window.scrollY + "px" + flashEl.style.left = rect.left + "px" + flashEl.style.top = rect.top + "px" flashEl.style.width = rect.width + "px" flashEl.style.height = rect.height + "px" document.documentElement.appendChild flashEl -- cgit v1.2.3