diff options
| -rw-r--r-- | content_scripts/mode_find.coffee | 10 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 12 |
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? |
