aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2016-04-03 08:25:20 +0100
committerStephen Blott2016-04-04 06:15:51 +0100
commit4cbeb44d7ae33e6bfeb221b47b63eac6b727ef8d (patch)
tree0b72872b01158a62f1e7f7a3aff003316e1ab069
parentad97d7e4c09e6c26bbacd1d6f2375cf39af0d8eb (diff)
downloadvimium-4cbeb44d7ae33e6bfeb221b47b63eac6b727ef8d.tar.bz2
Keep rects local for link hints.
Previously, we passed each hints rect to every other frame. However, the rect is only actually needed in its own frame. Here, we instead keep (and use) each hint's rect locally only.
-rw-r--r--content_scripts/link_hints.coffee15
1 files changed, 7 insertions, 8 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index 50299732..c3a4046b 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -79,8 +79,8 @@ HintCoordinator =
@localHints = LocalHints.getLocalHints()
console.log "getHintDescriptors", frameId, "[#{@localHints.length}]" if @debug
@sendMessage "postHintDescriptors", hintDescriptors:
- @localHints.map ({rect, linkText, showLinkText, hasHref, reason}, localIndex) ->
- {rect, linkText, showLinkText, hasHref, reason, frameId, localIndex}
+ @localHints.map ({linkText, showLinkText, hasHref, reason}, localIndex) ->
+ {linkText, showLinkText, hasHref, reason, frameId, localIndex}
# We activate LinkHintsMode() in every frame and provide every frame with exactly the same hint descriptors.
# We also propagate the key state between frames. Therefore, the hint-selection process proceeds in lock
@@ -188,18 +188,17 @@ class LinkHintsMode
marker =
if desc.frameId == frameId
el = DomUtils.createElement "div"
- el.style.left = desc.rect.left + window.scrollX + "px"
- el.style.top = desc.rect.top + window.scrollY + "px"
+ el.rect = HintCoordinator.getLocalHintMarker(desc).rect
+ el.style.left = el.rect.left + window.scrollX + "px"
+ el.style.top = el.rect.top + window.scrollY + "px"
extend el, className: "vimiumReset internalVimiumHintMarker vimiumHintMarker"
else
{}
- # Extract other relevant fields from the hint descriptor and a stable sort key.
extend marker,
hintDescriptor: desc
linkText: desc.linkText
showLinkText: desc.showLinkText
- rect: desc.rect
isLocalMarker: desc.frameId == frameId
stableSortCount: ++@stableSortCount
@@ -319,7 +318,7 @@ class LinkHintsMode
installKeyboardBlocker = (startKeyboardBlocker) ->
if linkMatched.isLocalMarker
- flashEl = DomUtils.addFlashRect linkMatched.hintDescriptor.rect
+ flashEl = DomUtils.addFlashRect linkMatched.rect
HintCoordinator.onExit.push -> DomUtils.removeElement flashEl
if document.hasFocus()
@@ -332,7 +331,7 @@ class LinkHintsMode
else if userMightOverType
installKeyboardBlocker (callback) -> new TypingProtector 200, callback
else if linkMatched.isLocalMarker
- DomUtils.flashRect linkMatched.hintDescriptor.rect
+ DomUtils.flashRect linkMatched.rect
HintCoordinator.sendMessage "exit", isSuccess: true
#