From f27399c40e966e25dbabf4e77e09852fda006d76 Mon Sep 17 00:00:00 2001 From: girst Date: Fri, 27 Dec 2019 06:09:54 +0100 Subject: [PATCH] Clean up some shims for # Firefox does things differently when blurring the location bar, depending on # whether the autocomplete popup is open or not. To be consistent, always # close the autocomplete popup before blurring. - try - vim.window.gURLBar.view.close() - catch - vim.window.gURLBar.closePopup() # pre mozilla64 + vim.window.gURLBar.view.close() utils.blurActiveBrowserElement(vim) utils.getFindBar(vim.window.gBrowser).then((findBar) -> findBar.close()) diff --git a/extension/lib/markable-elements.coffee b/extension/lib/markable-elements.coffee index c87aa75..6b6448d 100644 --- a/extension/lib/markable-elements.coffee +++ b/extension/lib/markable-elements.coffee @@ -161,10 +161,7 @@ getElementShape = (elementData, tryRight, rects = null) -> utils.walkTextNodes(element, (node) -> unless node.data.trim() == '' for quads in node.getBoxQuads() - try - bounds = quads.getBounds() - catch - bounds = quads.bounds # waterfox 56 + bounds = quads.getBounds() if bounds.width < MIN_TEXTNODE_SIZE or bounds.height < MIN_TEXTNODE_SIZE continue diff --git a/extension/lib/utils.coffee b/extension/lib/utils.coffee index 2e2b72f..fde3502 100644 --- a/extension/lib/utils.coffee +++ b/extension/lib/utils.coffee @@ -13,16 +13,6 @@ nsIStyleSheetService = Cc['@mozilla.org/content/style-sheet-service;1'] nsIWindowMediator = Cc['@mozilla.org/appshell/window-mediator;1'] .getService(Ci.nsIWindowMediator) -# This interface was removed from Firefox with no alternative. Try to use it if -# available but otherwise just ignore it. Code in this module handles this -# variable being `null`. -nsIDomUtils = - try - Cc['@mozilla.org/inspector/dom-utils;1'] - .getService(Ci.inIDOMUtils) - catch - null - # For XUL, `instanceof` checks are often better than `.localName` checks, # because some of the below interfaces are extended by many elements. XULButtonElement = Ci.nsIDOMXULButtonElement @@ -32,10 +22,8 @@ XULMenuListElement = Ci.nsIDOMXULMenuListElement # Traverse the DOM upwards until we hit its containing document (most likely an # HTMLDocument or (<=fx68) XULDocument) or the ShadowRoot. getDocument = (e) -> if e.parentNode? then arguments.callee(e.parentNode) else e -# for shadow DOM custom elements, as they require special handling. -# (ShadowRoot is only available in mozilla63+) -isInShadowRoot = (element) -> - ShadowRoot? and getDocument(element) instanceof ShadowRoot + +isInShadowRoot = (element) -> getDocument(element) instanceof ShadowRoot isXULElement = (element) -> XUL_NS = 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' @@ -522,15 +510,6 @@ setAttributes = (element, attributes) -> element.setAttribute(attribute, value) return -setHover = (element, hover) -> - return unless nsIDomUtils - - method = if hover then 'addPseudoClassLock' else 'removePseudoClassLock' - while element.parentElement - nsIDomUtils[method](element, ':hover') - element = element.parentElement - return - walkTextNodes = (element, fn) -> for node in element.childNodes then switch node.nodeType when 3 # TextNode. @@ -781,7 +760,6 @@ module.exports = { selectAllSubstringMatches selectElement setAttributes - setHover walkTextNodes Counter diff --git a/extension/lib/vim-frame.coffee b/extension/lib/vim-frame.coffee index ac1a9b1..b317bc2 100644 --- a/extension/lib/vim-frame.coffee +++ b/extension/lib/vim-frame.coffee @@ -77,7 +77,6 @@ class VimFrame markPageInteraction: (value = true) -> @state.hasInteraction = value setHover: (element, browserOffset) -> - utils.setHover(element, true) utils.simulateMouseEvents(element, 'hover-start', browserOffset) @state.lastHover.element = element @state.lastHover.browserOffset = browserOffset @@ -85,7 +84,6 @@ class VimFrame clearHover: -> if @state.lastHover.element {element, browserOffset} = @state.lastHover - utils.setHover(element, false) utils.simulateMouseEvents(element, 'hover-end', browserOffset) @state.lastHover.element = null -- 2.39.3