From 5612bac8bfc86989624f3e94abeb110ef5f814ec Mon Sep 17 00:00:00 2001 From: girst Date: Thu, 21 Nov 2019 16:47:49 +0100 Subject: [PATCH] remove getAnonymousNodes() code path from getAllElements() in fx68 and newer, there are no in-content bindings (i.e. those in .xul about:-pages) left, and hardly any that are reachable via VimFx hints. The only element with anonymous nodes that was reachable that way is the (non-megabar) URL bar, which is better focused using 'o'. The other now removed function, getBindingParent(), will have to stay; otherwise custom elements (e.g. on bugs.chromium.org or the element on XUL-about:config) won't be properly clickable through hints. --- extension/lib/markable-elements.coffee | 34 ++++---------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/extension/lib/markable-elements.coffee b/extension/lib/markable-elements.coffee index 3885612..0da92fa 100644 --- a/extension/lib/markable-elements.coffee +++ b/extension/lib/markable-elements.coffee @@ -68,35 +68,11 @@ findAllDOMs = (dom) -> ) getAllElements = (document, selector) -> - unless utils.isXULDocument(document) and document.getAnonymousNodes? - return [].concat( - findAllDOMs(document).map((d) -> - Array.from(d.querySelectorAll(selector)) - )... - ) - - # Note: getAnonymousNodes() has been removed from fx72. FIXME: remove. - # Use a `Set` since this algorithm may find the same element more than once. - # Ideally we should find a way to find all elements without duplicates. - elements = new Set() - getAllRegular = (element) -> - # The first time `eb` is run `.getElementsByTagName('*')` may oddly include - # `undefined` in its result! Filter those out. (Also, `selector` is ignored - # here since it doesn’t make sense in XUL documents because of all the - # trickery around anonymous elements.) - for child in element.getElementsByTagName('*') when child - elements.add(child) - getAllAnonymous(child) - return - getAllAnonymous = (element) -> - for child in document.getAnonymousNodes(element) or [] - continue unless isElementInstance(child) - elements.add(child) - getAllRegular(child) - getAllAnonymous(child) - return - getAllRegular(document.documentElement) - return Array.from(elements) + return [].concat( + findAllDOMs(document).map((d) -> + Array.from(d.querySelectorAll(selector)) + )... + ) getRects = (element, viewport) -> # `element.getClientRects()` returns a list of rectangles, usually just one, -- 2.39.3