From 5be59ecbc14e793117253573d8875b3b64fe5bae Mon Sep 17 00:00:00 2001 From: girst Date: Mon, 5 Jun 2023 18:33:56 +0200 Subject: [PATCH] Revert "remove compatibility shims for firefox <= 80" This reverts commit ae0fbd54d0d8655947835e8d0e04f2ec7eae8960. --- extension/lib/commands.coffee | 8 ++++++-- extension/lib/markable-elements.coffee | 10 +++++++--- extension/lib/utils.coffee | 14 ++++++++------ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/extension/lib/commands.coffee b/extension/lib/commands.coffee index 46e20da..ee91c29 100644 --- a/extension/lib/commands.coffee +++ b/extension/lib/commands.coffee @@ -27,7 +27,10 @@ commands = {} commands.focus_location_bar = ({vim}) -> - vim.window.gURLBar.select() + try + vim.window.gURLBar.select() # fx76+ + catch + vim.window.focusAndSelectUrlBar() commands.focus_search_bar = ({vim, count}) -> # The `.webSearch()` method opens a search engine in a tab if the search bar @@ -754,7 +757,8 @@ commands.click_browser_element = ({vim}) -> }) MarkerContainer.remove(window) # Better safe than sorry. markerContainer.container.classList.add('ui') - mainWindow = window.document.body + mainWindow = window.document.body or + window.document.getElementById('main-window') # fallback return false if newX > viewport.right or newX > elementRect.right return tryPoint(elementData, elementRect, newX, 0, y, 0, tryRight - 1) -# Elements in shadows roots may be “anonymous”. These are never returned by -# `document.elementFromPoint` but their host elements are. +# In XUL documents there are “anonymous” elements. These are never returned by +# `document.elementFromPoint` but their closest non-anonymous parents are. +# The same is true for Web Components (where their hosts are returned), with +# the further caveat that they might be nested. +# Note: getBindingParent() has been removed from fx72. normalize = (element) -> - element = e while (e = element.containingShadowRoot?.host)? + element = e while (e = element.ownerDocument.getBindingParent?(element))? + element = e while (e = element.containingShadowRoot?.host)? # >=fx72 element = element.parentNode while element.prefix? return element diff --git a/extension/lib/utils.coffee b/extension/lib/utils.coffee index 569507a..526acd6 100644 --- a/extension/lib/utils.coffee +++ b/extension/lib/utils.coffee @@ -23,7 +23,7 @@ XULControlElement = Ci.nsIDOMXULControlElement XULMenuListElement = Ci.nsIDOMXULMenuListElement # Traverse the DOM upwards until we hit its containing document (most likely an -# HTMLDocument) or the ShadowRoot. +# HTMLDocument or (<=fx68) XULDocument) or the ShadowRoot. getDocument = (e) -> if e.parentNode? then arguments.callee(e.parentNode) else e isInShadowRoot = (element) -> @@ -97,7 +97,8 @@ isDevtoolsWindow = (window) -> # SecurityError; the `try` around it makes it `undefined` in such a case. return (try window.location?.href) in [ 'about:devtools-toolbox' - 'chrome://devtools/content/framework/toolbox.xhtml' + 'chrome://devtools/content/framework/toolbox.xul' + 'chrome://devtools/content/framework/toolbox.xhtml' # fx72+ ] # Note: this is possibly a bit overzealous, but Works For Now™. @@ -321,7 +322,8 @@ contentAreaClick = (data, browser) -> originStoragePrincipal: data.originStoragePrincipal, triggeringPrincipal: data.triggeringPrincipal, csp: if data.csp then E10SUtils.deserializeCSP(data.csp) else null, - frameID: data.frameID, + frameOuterWindowID: data.frameOuterWindowID, # <=fx79 + frameID: data.frameID, # >=fx80 allowInheritPrincipal: true, openerBrowser: browser, # >=fx98 hasValidUserGestureActivation: true, # >=fx103 @@ -396,9 +398,9 @@ simulateMouseEvents = (element, sequence, browserOffset) -> element.dispatchEvent(mouseEvent) else try - window.windowUtils.dispatchDOMEventViaPresShellForTesting( - element, mouseEvent - ) + (window.windowUtils.dispatchDOMEventViaPresShellForTesting or + window.windowUtils.dispatchDOMEventViaPresShell # < fx73 + )(element, mouseEvent) catch error if error.result != Cr.NS_ERROR_UNEXPECTED throw error -- 2.39.3