diff options
| -rw-r--r-- | content_scripts/mode_find.coffee | 12 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 15 |
2 files changed, 13 insertions, 14 deletions
diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee index d361d4be..e02f61c9 100644 --- a/content_scripts/mode_find.coffee +++ b/content_scripts/mode_find.coffee @@ -243,6 +243,18 @@ getCurrentRange = -> selection.collapseToStart() if selection.type == "Range" selection.getRangeAt 0 +getLinkFromSelection = -> + node = window.getSelection().anchorNode + while (node && node != document.body) + return node if (node.nodeName.toLowerCase() == "a") + node = node.parentNode + null + +focusFoundLink = -> + if (FindMode.query.hasResults) + link = getLinkFromSelection() + link.focus() if link + 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 b936fe04..5f6c377e 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -353,11 +353,6 @@ checkIfEnabledForUrl = do -> checkEnabledAfterURLChange = forTrusted -> checkIfEnabledForUrl() if windowIsFocused() -focusFoundLink = -> - if (FindMode.query.hasResults) - 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 @@ -368,13 +363,6 @@ selectFoundInputElement = -> DomUtils.isDOMDescendant(findModeAnchorNode, document.activeElement)) DomUtils.simulateSelect(document.activeElement) -getLinkFromSelection = -> - node = window.getSelection().anchorNode - while (node && node != document.body) - return node if (node.nodeName.toLowerCase() == "a") - node = node.parentNode - null - # used by the findAndFollow* functions. followLink = (linkElement) -> if (linkElement.nodeName.toLowerCase() == "link") @@ -484,8 +472,7 @@ root.Frame = Frame root.windowIsFocused = windowIsFocused root.bgLog = bgLog # These are exported for find mode and link-hints mode. -extend root, {focusFoundLink, selectFoundInputElement, focusThisFrame, FocusSelector, - findAndFollowRel, findAndFollowLink} +extend root, {selectFoundInputElement, focusThisFrame, FocusSelector, findAndFollowRel, findAndFollowLink} # These are exported only for the tests. extend root, {installModes} extend window, root unless exports? |
