From 255ea5b6bb2f2474504b6ffbd7bd32e1a141ef23 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sat, 21 Nov 2015 13:57:04 +0100 Subject: [PATCH] Fix text input focus problems since commit a197a16 Since that commit, and only in non-multi-process, when focusing a text input for a second time it got styled as focused, but no blinking text caret appeared. You could still type into the text input, though. --- extension/lib/utils.coffee | 9 ++++++++- extension/lib/vim.coffee | 8 ++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/extension/lib/utils.coffee b/extension/lib/utils.coffee index 1052d42..ac2a243 100644 --- a/extension/lib/utils.coffee +++ b/extension/lib/utils.coffee @@ -92,7 +92,14 @@ isTypingElement = (element) -> getActiveElement = (window) -> {activeElement} = window.document - if activeElement.contentWindow + # If the active element is a frame, recurse into it. The easiest way to detect + # a frame that works both in browser UI and in web page content is to check + # for the presence of `.contentWindow`. However, in non-multi-process + # `` (sometimes ``) elements have a `.contentWindow` + # pointing to the web page content `window`, which we don’t want to recurse + # into. `.localName` is `.nodeName` without `xul:` (if it exists). This seems + # to be the only way to detect such elements. + if activeElement.localName != 'browser' and activeElement.contentWindow return getActiveElement(activeElement.contentWindow) else return activeElement diff --git a/extension/lib/vim.coffee b/extension/lib/vim.coffee index 0f4fd36..17d1e46 100644 --- a/extension/lib/vim.coffee +++ b/extension/lib/vim.coffee @@ -107,10 +107,10 @@ class Vim @_isUIElement(event.originalTarget) _isUIElement: (element) -> - if MULTI_PROCESS_ENABLED - return (element != @window.gBrowser.selectedBrowser) - else - return (element.ownerGlobal instanceof ChromeWindow) + # TODO: The `element.ownerGlobal` check will be redundant when + # non-multi-process is removed from Firefox. + return element.ownerGlobal instanceof ChromeWindow and + element != @window.gBrowser.selectedBrowser # `args...` is passed to the mode's `onEnter` method. enterMode: (mode, args...) -> -- 2.39.3