diff --git a/content/base/public/nsIContent.h b/content/base/public/nsIContent.h index 63f192f8af5..3171afd30a1 100644 --- a/content/base/public/nsIContent.h +++ b/content/base/public/nsIContent.h @@ -33,8 +33,8 @@ enum nsLinkState { // IID for the nsIContent interface #define NS_ICONTENT_IID \ -{ 0x8a8b4b1d, 0x72d8, 0x428e, \ - { 0x95, 0x75, 0xf9, 0x18, 0xba, 0xf6, 0x9e, 0xa1 } } +{ 0Xf22c131c, 0Xc554, 0X4d06, \ + { 0X81, 0Xac, 0X86, 0X64, 0X2f, 0X05, 0Xcc, 0X81 } } /** * A node of content in a document's content model. This interface @@ -305,6 +305,12 @@ public: return mNodeInfo->Equals(aTag, kNameSpaceID_MathML); } + inline bool IsActiveChildrenElement() const + { + return mNodeInfo->Equals(nsGkAtoms::children, kNameSpaceID_XBL) && + GetBindingParent(); + } + /** * Returns an atom holding the name of the attribute of type ID on * this content node (if applicable). Returns null for non-element diff --git a/content/base/src/ChildIterator.cpp b/content/base/src/ChildIterator.cpp index f3f43e517e3..fa83d891c57 100644 --- a/content/base/src/ChildIterator.cpp +++ b/content/base/src/ChildIterator.cpp @@ -16,7 +16,7 @@ ExplicitChildIterator::GetNextChild() // If we're already in the inserted-children array, look there first if (mIndexInInserted) { MOZ_ASSERT(mChild); - MOZ_ASSERT(mChild->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)); + MOZ_ASSERT(mChild->IsActiveChildrenElement()); MOZ_ASSERT(!mDefaultChild); XBLChildrenElement* point = static_cast(mChild); @@ -28,7 +28,7 @@ ExplicitChildIterator::GetNextChild() } else if (mDefaultChild) { // If we're already in default content, check if there are more nodes there MOZ_ASSERT(mChild); - MOZ_ASSERT(mChild->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)); + MOZ_ASSERT(mChild->IsActiveChildrenElement()); mDefaultChild = mDefaultChild->GetNextSibling(); if (mDefaultChild) { @@ -44,8 +44,7 @@ ExplicitChildIterator::GetNextChild() } // Iterate until we find a non-, or a with content. - while (mChild && - mChild->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) { + while (mChild && mChild->IsActiveChildrenElement()) { XBLChildrenElement* point = static_cast(mChild); if (!point->mInsertedChildren.IsEmpty()) { mIndexInInserted = 1; @@ -85,6 +84,7 @@ FlattenedChildIterator::FlattenedChildIterator(nsIContent* aParent) child; child = child->GetNextSibling()) { if (child->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) { + MOZ_ASSERT(child->GetBindingParent()); mXBLInvolved = true; break; } @@ -131,8 +131,7 @@ nsIContent* FlattenedChildIterator::GetPreviousChild() } // Iterate until we find a non-, or a with content. - while (mChild && - mChild->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) { + while (mChild && mChild->IsActiveChildrenElement()) { XBLChildrenElement* point = static_cast(mChild); if (!point->mInsertedChildren.IsEmpty()) { mIndexInInserted = point->InsertedChildrenLength(); diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index d631f9560be..9d4902d81fc 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -3518,7 +3518,7 @@ nsCSSFrameConstructor::ConstructFrameFromItemInternal(FrameConstructionItem& aIt // descendants. nsIContent* parent = content->GetParent(); bool pushInsertionPoint = aState.mTreeMatchContext.mAncestorFilter.HasFilter() && - parent && parent->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL); + parent && parent->IsActiveChildrenElement(); TreeMatchContext::AutoAncestorPusher insertionPointPusher(pushInsertionPoint, aState.mTreeMatchContext, @@ -6511,7 +6511,7 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer, nsIFrame* parentFrame = GetFrameFor(aContainer); // See comment in ContentRangeInserted for why this is necessary. - if (!parentFrame && !aContainer->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) { + if (!parentFrame && !aContainer->IsActiveChildrenElement()) { return NS_OK; } @@ -6934,7 +6934,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer, // The xbl:children element won't have a frame, but default content can have the children as // a parent. While its uncommon to change the structure of the default content itself, a label, // for example, can be reframed by having its value attribute set or removed. - if (!parentFrame && !aContainer->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) { + if (!parentFrame && !aContainer->IsActiveChildrenElement()) { return NS_OK; } diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index a61fbdcbf46..e23efc50826 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -1379,8 +1379,7 @@ nsFrameManager::ReResolveStyleContext(nsPresContext *aPresContext, // children element. Push the children element as an ancestor here because it does // not have a frame and would not otherwise be pushed as an ancestor. nsIContent* parent = undisplayed->mContent->GetParent(); - bool pushInsertionPoint = parent && - parent->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL); + bool pushInsertionPoint = parent && parent->IsActiveChildrenElement(); TreeMatchContext::AutoAncestorPusher insertionPointPusher(pushInsertionPoint, aTreeMatchContext, @@ -1549,8 +1548,7 @@ nsFrameManager::ReResolveStyleContext(nsPresContext *aPresContext, // Check if the frame has a content because |child| may be a nsPageFrame that does // not have a content. nsIContent* parent = child->GetContent() ? child->GetContent()->GetParent() : nullptr; - bool pushInsertionPoint = parent && - parent->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL); + bool pushInsertionPoint = parent && parent->IsActiveChildrenElement(); TreeMatchContext::AutoAncestorPusher insertionPointPusher(pushInsertionPoint, aTreeMatchContext, parent && parent->IsElement() ? parent->AsElement() : nullptr); @@ -1911,8 +1909,7 @@ nsFrameManagerBase::UndisplayedMap::GetEntryFor(nsIContent** aParentContent) // be a element) but the parent in the frame tree would be the // insertion parent (parent of the element). Here the children // elements are normalized to the insertion parent to correct for the mismatch. - if (parentContent && - parentContent->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) { + if (parentContent && parentContent->IsActiveChildrenElement()) { parentContent = parentContent->GetParent(); // Change the caller's pointer for the parent content to be the insertion parent. *aParentContent = parentContent; diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index f961205184e..ec16e670b86 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -2312,9 +2312,7 @@ static bool SelectorMatchesTree(Element* aPrevElement, // element wasn't in the tree to allow old selectors // were written before participated in CSS selector // matching to work. - if (selector->mOperator == '>' && - element->NodeInfo()->Equals(nsGkAtoms::children, - kNameSpaceID_XBL)) { + if (selector->mOperator == '>' && element->IsActiveChildrenElement()) { Element* styleScope = aTreeMatchContext.mCurrentStyleScope; if (SelectorMatchesTree(element, selector, aTreeMatchContext, aLookForRelevantLink)) {