From 243aae81a320308b9c2aad3fc70e69019422b20d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 23 Sep 2019 15:52:55 +0000 Subject: [PATCH] Bug 1582585 - Use flattenedTreeParentNode in AutoScrollController.jsm. r=botond This makes it work with both Shadow DOM and XBL. Differential Revision: https://phabricator.services.mozilla.com/D46729 --HG-- extra : moz-landing-system : lando --- toolkit/modules/AutoScrollController.jsm | 42 +----------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/toolkit/modules/AutoScrollController.jsm b/toolkit/modules/AutoScrollController.jsm index 235ecad085b9..53011aee0121 100644 --- a/toolkit/modules/AutoScrollController.jsm +++ b/toolkit/modules/AutoScrollController.jsm @@ -108,51 +108,11 @@ class AutoScrollController { return null; } - getXBLNodes(parent, array) { - let content = parent.ownerGlobal; - let anonNodes = content.document.getAnonymousNodes(parent); - let nodes = Array.from(anonNodes || parent.childNodes || []); - for (let node of nodes) { - if (node.nodeName == "children") { - return true; - } - if (this.getXBLNodes(node, array)) { - array.push(node); - return true; - } - } - return false; - } - - *parentNodeIterator(aNode) { - let content = aNode.ownerGlobal; - - while (aNode) { - yield aNode; - - let parent = aNode.parentNode; - if (parent && parent instanceof content.XULElement) { - let anonNodes = content.document.getAnonymousNodes(parent); - if (anonNodes && !Array.from(anonNodes).includes(aNode)) { - // XBL elements are skipped by parentNode property. - // Yield elements between parent and here. - let nodes = []; - this.getXBLNodes(parent, nodes); - for (let node of nodes) { - yield node; - } - } - } - - aNode = parent; - } - } - findNearestScrollableElement(aNode) { // go upward in the DOM and find any parent element that has a overflow // area and can therefore be scrolled this._scrollable = null; - for (let node of this.parentNodeIterator(aNode)) { + for (let node = aNode; node; node = node.flattenedTreeParentNode) { // do not use overflow based autoscroll for and // Elements or non-html/non-xul elements such as svg or Document nodes // also make sure to skip select elements that are not multiline