From ebd53300c511fef6f894ffcab3b6055772459dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 5 Oct 2021 14:54:47 +0000 Subject: [PATCH] Bug 1707448 - Remove unused eAllButXBL flag. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D127539 --- dom/base/ChildIterator.cpp | 26 +++++++++++--------------- dom/base/ChildIterator.h | 26 +++++++------------------- dom/base/nsIContent.h | 32 ++++++-------------------------- 3 files changed, 24 insertions(+), 60 deletions(-) diff --git a/dom/base/ChildIterator.cpp b/dom/base/ChildIterator.cpp index 5292bd63fccd..dc3e67191cf6 100644 --- a/dom/base/ChildIterator.cpp +++ b/dom/base/ChildIterator.cpp @@ -79,23 +79,19 @@ nsIContent* ExplicitChildIterator::GetNextChild() { return mChild; } -void FlattenedChildIterator::Init(bool aIgnoreXBL) { - if (aIgnoreXBL) { +void FlattenedChildIterator::Init() { + if (!mParent->IsElement()) { + // TODO(emilio): I think it probably makes sense to only allow constructing + // FlattenedChildIterators with Element. return; } - - // TODO(emilio): I think it probably makes sense to only allow constructing - // FlattenedChildIterators with Element. - if (mParent->IsElement()) { - if (ShadowRoot* shadow = mParent->AsElement()->GetShadowRoot()) { - mParent = shadow; - mShadowDOMInvolved = true; - return; - } - if (mParentAsSlot) { - mShadowDOMInvolved = true; - return; - } + if (ShadowRoot* shadow = mParent->AsElement()->GetShadowRoot()) { + mParent = shadow; + mShadowDOMInvolved = true; + return; + } + if (mParentAsSlot) { + mShadowDOMInvolved = true; } } diff --git a/dom/base/ChildIterator.h b/dom/base/ChildIterator.h index a8fe672f3029..f31fa7fd8cbb 100644 --- a/dom/base/ChildIterator.h +++ b/dom/base/ChildIterator.h @@ -115,32 +115,20 @@ class FlattenedChildIterator : public ExplicitChildIterator { bool aStartAtBeginning = true) : ExplicitChildIterator(aParent, aStartAtBeginning), mOriginalContent(aParent) { - Init(false); + Init(); } bool ShadowDOMInvolved() { return mShadowDOMInvolved; } const nsIContent* Parent() const { return mOriginalContent; } - private: - void Init(bool aIgnoreXBL); - protected: - /** - * This constructor is a hack to help AllChildrenIterator which sometimes - * doesn't want to consider XBL. - */ - FlattenedChildIterator(const nsIContent* aParent, uint32_t aFlags, - bool aStartAtBeginning = true) - : ExplicitChildIterator(aParent, aStartAtBeginning), - mOriginalContent(aParent) { - bool ignoreXBL = aFlags & nsIContent::eAllButXBL; - Init(ignoreXBL); - } const nsIContent* mOriginalContent; private: + void Init(); + // For certain optimizations, nsCSSFrameConstructor needs to know if the child // list of the element that we're iterating matches its .childNodes. bool mShadowDOMInvolved = false; @@ -148,9 +136,9 @@ class FlattenedChildIterator : public ExplicitChildIterator { /** * AllChildrenIterator traverses the children of an element including before / - * after content and optionally XBL children. The iterator can be initialized - * to start at the end by providing false for aStartAtBeginning in order to - * start iterating in reverse from the last child. + * after content and shadow DOM. The iterator can be initialized to start at + * the end by providing false for aStartAtBeginning in order to start iterating + * in reverse from the last child. * * Note: it assumes that no mutation of the DOM or frame tree takes place during * iteration, and will break horribly if that is not true. @@ -159,7 +147,7 @@ class AllChildrenIterator : private FlattenedChildIterator { public: AllChildrenIterator(const nsIContent* aNode, uint32_t aFlags, bool aStartAtBeginning = true) - : FlattenedChildIterator(aNode, aFlags, aStartAtBeginning), + : FlattenedChildIterator(aNode, aStartAtBeginning), mAnonKidsIdx(aStartAtBeginning ? UINT32_MAX : 0), mFlags(aFlags), mPhase(aStartAtBeginning ? eAtBegin : eAtEnd) {} diff --git a/dom/base/nsIContent.h b/dom/base/nsIContent.h index 612f3dc4c6ad..74a11b9244bc 100644 --- a/dom/base/nsIContent.h +++ b/dom/base/nsIContent.h @@ -116,48 +116,28 @@ class nsIContent : public nsINode { * * @note the result children order is * 1. :before generated node - * 2. XBL flattened tree children of this node + * 2. Shadow DOM flattened tree children of this node * 3. native anonymous nodes * 4. :after generated node */ eAllChildren = 0, /** - * All XBL explicit children of the node (see - * http://www.w3.org/TR/xbl/#explicit3 ), as well as :before and :after - * anonymous content and native anonymous children. - * - * @note the result children order is - * 1. :before generated node - * 2. XBL explicit children of the node - * 3. native anonymous nodes - * 4. :after generated node + * Skip native anonymous content created for placeholder of HTML input. */ - eAllButXBL = 1, - - /** - * Skip native anonymous content created for placeholder of HTML input, - * used in conjunction with eAllChildren or eAllButXBL. - */ - eSkipPlaceholderContent = 2, + eSkipPlaceholderContent = 1 << 0, /** * Skip native anonymous content created by ancestor frames of the root * element's primary frame, such as scrollbar elements created by the root * scroll frame. */ - eSkipDocumentLevelNativeAnonymousContent = 4, + eSkipDocumentLevelNativeAnonymousContent = 1 << 1, }; /** - * Return either the XBL explicit children of the node or the XBL flattened - * tree children of the node, depending on the filter, as well as - * native anonymous children. - * - * @note calling this method with eAllButXBL will return children that are - * also in the eAllButXBL and eAllChildren child lists of other descendants - * of this node in the tree, but those other nodes cannot be reached from the - * eAllButXBL child list. + * Return the flattened tree children of the node, depending on the filter, as + * well as native anonymous children. */ virtual already_AddRefed GetChildren(uint32_t aFilter) = 0;