aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormrmr19932017-10-29 10:22:17 +0000
committermrmr19932017-10-29 10:22:17 +0000
commita00bb7d2172803bc04b3543b31345879cb434b27 (patch)
tree4eaf6bde0c34ef9a17ed9e5f68fb38f5633339ac
parent0b9287696825cb7df2301d97a54c7666d9094521 (diff)
downloadvimium-a00bb7d2172803bc04b3543b31345879cb434b27.tar.bz2
Move selectFoundInputElement into mode_find
-rw-r--r--content_scripts/mode_find.coffee10
-rw-r--r--content_scripts/vimium_frontend.coffee12
2 files changed, 11 insertions, 11 deletions
diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee
index e02f61c9..b6c80cec 100644
--- a/content_scripts/mode_find.coffee
+++ b/content_scripts/mode_find.coffee
@@ -255,6 +255,16 @@ focusFoundLink = ->
link = getLinkFromSelection()
link.focus() if link
+selectFoundInputElement = ->
+ # Since the last focused element might not be the one currently pointed to by find (e.g. the current one
+ # might be disabled and therefore unable to receive focus), we use the approximate heuristic of checking
+ # that the last anchor node is an ancestor of our element.
+ findModeAnchorNode = document.getSelection().anchorNode
+ if (FindMode.query.hasResults && document.activeElement &&
+ DomUtils.isSelectable(document.activeElement) &&
+ DomUtils.isDOMDescendant(findModeAnchorNode, document.activeElement))
+ DomUtils.simulateSelect(document.activeElement)
+
root = exports ? (window.root ?= {})
root.PostFindMode = PostFindMode
root.FindMode = FindMode
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index 5f6c377e..920fb27c 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -353,16 +353,6 @@ checkIfEnabledForUrl = do ->
checkEnabledAfterURLChange = forTrusted ->
checkIfEnabledForUrl() if windowIsFocused()
-selectFoundInputElement = ->
- # Since the last focused element might not be the one currently pointed to by find (e.g. the current one
- # might be disabled and therefore unable to receive focus), we use the approximate heuristic of checking
- # that the last anchor node is an ancestor of our element.
- findModeAnchorNode = document.getSelection().anchorNode
- if (FindMode.query.hasResults && document.activeElement &&
- DomUtils.isSelectable(document.activeElement) &&
- DomUtils.isDOMDescendant(findModeAnchorNode, document.activeElement))
- DomUtils.simulateSelect(document.activeElement)
-
# used by the findAndFollow* functions.
followLink = (linkElement) ->
if (linkElement.nodeName.toLowerCase() == "link")
@@ -472,7 +462,7 @@ root.Frame = Frame
root.windowIsFocused = windowIsFocused
root.bgLog = bgLog
# These are exported for find mode and link-hints mode.
-extend root, {selectFoundInputElement, focusThisFrame, FocusSelector, findAndFollowRel, findAndFollowLink}
+extend root, {focusThisFrame, FocusSelector, findAndFollowRel, findAndFollowLink}
# These are exported only for the tests.
extend root, {installModes}
extend window, root unless exports?