aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts
diff options
context:
space:
mode:
authorStephen Blott2016-03-10 12:03:17 +0000
committerStephen Blott2016-03-28 05:41:09 +0100
commit17379d86faefdeb158b30ccdfb5c3814008bfea3 (patch)
tree2374f734fbbd91cf7b34298c38ce9ea63cdfac39 /content_scripts
parent09519db103b1cef197e183435e864287ab67e7e3 (diff)
downloadvimium-17379d86faefdeb158b30ccdfb5c3814008bfea3.tar.bz2
Move link activation to HintCoordinator.
This moves the link activation logic out of LinkHintsMode and into the hint coordinator. At this point, there is (almost) no DOM-specific logic left in LinksHintMode. It only depends an a list of "elements", each of which has a rect property. The main exception to this is filtered hints. In the following commits, we're going to leave filtered hints behind - mainly to keep the diff shorter and cleaner.
Diffstat (limited to 'content_scripts')
-rw-r--r--content_scripts/link_hints.coffee28
1 files changed, 17 insertions, 11 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index 57f7cc2b..b3c7412d 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -53,6 +53,21 @@ HintCoordinator =
activateMode: (activateModeCallback) ->
activateModeCallback ClickableElements.getVisibleClickableElements()
+ activateLink: (mode, linkMatched) ->
+ clickEl = linkMatched.clickableItem
+
+ clickActivator = (modifiers) -> (link) -> DomUtils.simulateClick link, modifiers
+ linkActivator = mode.linkActivator ? clickActivator mode.clickModifiers
+
+ if DomUtils.isSelectable clickEl
+ DomUtils.simulateSelect clickEl
+ else
+ # TODO: Are there any other input elements which should not receive focus?
+ if clickEl.nodeName.toLowerCase() == "input" and clickEl.type not in ["button", "submit"]
+ clickEl.focus()
+ linkActivator clickEl
+ LinkHints.activateModeWithQueue() if @mode is OPEN_WITH_QUEUE
+
LinkHints =
activateMode: (count = 1, mode = OPEN_IN_CURRENT_TAB) ->
if 0 < count
@@ -129,8 +144,6 @@ class LinkHintsModeBase
id: "vimiumHintMarkerContainer", className: "vimiumReset"
setOpenLinkMode: (@mode) ->
- clickActivator = (modifiers) -> (link) -> DomUtils.simulateClick link, modifiers
- @linkActivator = @mode.linkActivator ? clickActivator @mode.clickModifiers
@hintMode.setIndicator @mode.indicator
#
@@ -383,18 +396,11 @@ class LinkHintsMode extends LinkHintsModeBase
#
activateLink: (linkMatched, userMightOverType=false) ->
@removeHintMarkers()
- clickEl = linkMatched.clickableItem
+ mode = @mode
linkActivator = =>
@deactivateMode()
- if DomUtils.isSelectable clickEl
- DomUtils.simulateSelect clickEl
- else
- # TODO: Are there any other input elements which should not receive focus?
- if clickEl.nodeName.toLowerCase() == "input" and clickEl.type not in ["button", "submit"]
- clickEl.focus()
- @linkActivator clickEl
- LinkHints.activateModeWithQueue() if @mode is OPEN_WITH_QUEUE
+ HintCoordinator.activateLink mode, linkMatched
if userMightOverType and Settings.get "waitForEnterForFilteredHints"
new WaitForEnter linkMatched.rect, linkActivator