Skip to content

Commit

Permalink
Revert "remove compatibility shims for firefox <= 80"
Browse files Browse the repository at this point in the history
This reverts commit ae0fbd5.
  • Loading branch information
girst committed Jun 5, 2023
1 parent 12c6e62 commit 5be59ec
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
8 changes: 6 additions & 2 deletions extension/lib/commands.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 <fx72
mainWindow.insertBefore(
markerContainer.container,
mainWindow.firstChild
Expand Down
10 changes: 7 additions & 3 deletions extension/lib/markable-elements.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,14 @@ tryPoint = (elementData, elementRect, x, dx, y, dy, tryRight = 0) ->
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

Expand Down
14 changes: 8 additions & 6 deletions extension/lib/utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down Expand Up @@ -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™.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5be59ec

Please sign in to comment.