From 631e5910fd3b331f272848f43ab303a8e582762c Mon Sep 17 00:00:00 2001 From: girst Date: Tue, 5 May 2020 14:07:34 +0200 Subject: [PATCH] Fix getting stuck in normal mode in docked DevTools after refocusing In Nightly 70 the docked DevTools were switched from a Chrome Frame to a Content Frame. The part of VimFx that determines what is part of the browser UI (to work around a bug regarding delayed ipc messages) then didn't recognize the DevTools as part of the UI any longer. When a focusType event comes from the browser UI, a second event is fired erroneously a few milliseconds later. This caused us to enter insert mode in the devtools, and immediately exit out of it again, making it impossible to type in e.g. the style editor. STR: 1. open devtools->style editor (or ->network) 2. focus textbox (vimfx icon will turn silver) 3. focus webpage (vimfx switches to normal mode) 4. focus style editor (vimfx fails to return to ignore mode) regressed by: Bug 1539979 - https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=91f7769b3d7ec17aa11f7a8ada7104f5b4cec38d&tochange=39e19afc797d310f568447eae7054789e641b591 Unrelated to this change, the about:devtools-toolbox's chrome document was renamed from .xul to .xhtml a few releases back. This second URI was added; no idea if its absence broke anything. --- extension/lib/utils.coffee | 6 ++++++ extension/lib/vim.coffee | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/extension/lib/utils.coffee b/extension/lib/utils.coffee index 4f89bb3..5571d69 100644 --- a/extension/lib/utils.coffee +++ b/extension/lib/utils.coffee @@ -91,8 +91,13 @@ isDevtoolsWindow = (window) -> return window.location?.href in [ 'about:devtools-toolbox' 'chrome://devtools/content/framework/toolbox.xul' + 'chrome://devtools/content/framework/toolbox.xhtml' # fx72+ ] +# Note: this is possibly a bit overzealous, but Works For Now™. +isDockedDevtoolsElement = (element) -> + return element.ownerDocument.URL.startsWith('chrome://devtools/content/') + isFocusable = (element) -> # Focusable elements have `.tabIndex > 1` (but not necessarily a # `tabindex="…"` attribute) … @@ -727,6 +732,7 @@ module.exports = { isContentEditable isDevtoolsElement isDevtoolsWindow + isDockedDevtoolsElement isFocusable isIframeEditor isIgnoreModeFocusType diff --git a/extension/lib/vim.coffee b/extension/lib/vim.coffee index c865516..88d1910 100644 --- a/extension/lib/vim.coffee +++ b/extension/lib/vim.coffee @@ -88,7 +88,8 @@ class Vim @_isUIElement(event.originalTarget) _isUIElement: (element) -> - return element.ownerGlobal instanceof ChromeWindow and + return (element.ownerGlobal instanceof ChromeWindow or + utils.isDockedDevtoolsElement(element)) and element != @window.gBrowser.selectedBrowser # `args...` is passed to the mode's `onEnter` method. -- 2.39.3