diff options
| author | mrmr1993 | 2017-10-29 10:22:17 +0000 |
|---|---|---|
| committer | mrmr1993 | 2017-10-29 10:22:17 +0000 |
| commit | a00bb7d2172803bc04b3543b31345879cb434b27 (patch) | |
| tree | 4eaf6bde0c34ef9a17ed9e5f68fb38f5633339ac /content_scripts/mode_find.coffee | |
| parent | 0b9287696825cb7df2301d97a54c7666d9094521 (diff) | |
| download | vimium-a00bb7d2172803bc04b3543b31345879cb434b27.tar.bz2 | |
Move selectFoundInputElement into mode_find
Diffstat (limited to 'content_scripts/mode_find.coffee')
| -rw-r--r-- | content_scripts/mode_find.coffee | 10 |
1 files changed, 10 insertions, 0 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 |
