aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2016-04-10 11:21:34 +0100
committerStephen Blott2016-04-12 06:36:03 +0100
commit81fa2852b9ebfd1a0a2abd8b5ea374ac9bc49ca8 (patch)
treecc867be5ce477c91c480f9fd970e3e71cf22f7eb
parent598f6fa4ffa1348c096ad681a10bee28adde4a3e (diff)
downloadvimium-81fa2852b9ebfd1a0a2abd8b5ea374ac9bc49ca8.tar.bz2
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.
-rw-r--r--content_scripts/link_hints.coffee9
-rw-r--r--lib/dom_utils.coffee4
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