From 850533b89c71a0320b610ad2d26161067a5ace3b Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Wed, 3 Jun 2015 01:27:29 +0100 Subject: Remove global findModeAnchorNode and false comments justifying it --- content_scripts/vimium_frontend.coffee | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 26eace9c..633e4122 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -8,7 +8,6 @@ window.findModeQuery = { rawQuery: "", matchCount: 0 } window.findMode = null window.findModeQueryHasResults = false -findModeAnchorNode = null isShowingHelpDialog = false keyPort = null isEnabledForUrl = true @@ -739,9 +738,6 @@ executeFind = (query, options) -> if document.activeElement and DomUtils.isEditable document.activeElement document.activeElement.blur() unless DomUtils.isSelected document.activeElement - # we need to save the anchor node here because seems to nullify it, regardless of whether we do - # preventDefault() - findModeAnchorNode = document.getSelection().anchorNode result restoreDefaultSelectionHighlight = -> document.body.classList.remove("vimiumFindMode") @@ -752,10 +748,10 @@ focusFoundLink = -> link.focus() if link selectFoundInputElement = -> - # if the found text is in an input element, getSelection().anchorNode will be null, so we use activeElement - # instead. however, 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. + # 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 (findModeQueryHasResults && document.activeElement && DomUtils.isSelectable(document.activeElement) && DomUtils.isDOMDescendant(findModeAnchorNode, document.activeElement)) -- cgit v1.2.3