From 5b84f966ac56e886008090bb4e36d82e14960a58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 15 Nov 2019 16:46:29 +0000 Subject: [PATCH] Bug 1596209 - Remove nsIContent::GetBindingParent. r=smaug It's unused after all the previous patches. Differential Revision: https://phabricator.services.mozilla.com/D53217 --HG-- extra : moz-landing-system : lando --- dom/base/BindContext.h | 12 ------------ dom/base/CharacterData.cpp | 31 +------------------------------ dom/base/Element.cpp | 30 ------------------------------ dom/base/FragmentOrElement.cpp | 27 --------------------------- dom/base/ShadowRoot.cpp | 1 - dom/base/nsIContent.h | 29 ----------------------------- dom/base/nsINode.cpp | 14 -------------- dom/base/nsINode.h | 14 -------------- 8 files changed, 1 insertion(+), 157 deletions(-) diff --git a/dom/base/BindContext.h b/dom/base/BindContext.h index 1dc892b3e52c..b4173929ddbb 100644 --- a/dom/base/BindContext.h +++ b/dom/base/BindContext.h @@ -47,17 +47,9 @@ struct MOZ_STACK_CLASS BindContext final { // Whether our subtree root is changing as a result of this operation. bool SubtreeRootChanges() const { return mSubtreeRootChanges; } - // Returns the binding parent of the subtree to be inserted. - // - // This can be null. - Element* GetBindingParent() const { return mBindingParent; } - // This constructor should be used for regular appends to content. explicit BindContext(nsINode& aParent) : mDoc(*aParent.OwnerDoc()), - mBindingParent(aParent.IsContent() - ? aParent.AsContent()->GetBindingParent() - : nullptr), mInComposedDoc(aParent.IsInComposedDoc()), mInUncomposedDoc(aParent.IsInUncomposedDoc()), mSubtreeRootChanges(true), @@ -73,7 +65,6 @@ struct MOZ_STACK_CLASS BindContext final { // This constructor is only meant to be used in that situation. explicit BindContext(ShadowRoot& aShadowRoot) : mDoc(*aShadowRoot.OwnerDoc()), - mBindingParent(aShadowRoot.Host()), mInComposedDoc(aShadowRoot.IsInComposedDoc()), mInUncomposedDoc(false), mSubtreeRootChanges(false), @@ -86,7 +77,6 @@ struct MOZ_STACK_CLASS BindContext final { enum ForNativeAnonymous { ForNativeAnonymous }; BindContext(Element& aParentElement, enum ForNativeAnonymous) : mDoc(*aParentElement.OwnerDoc()), - mBindingParent(&aParentElement), mInComposedDoc(aParentElement.IsInComposedDoc()), mInUncomposedDoc(aParentElement.IsInUncomposedDoc()), mSubtreeRootChanges(true), @@ -114,8 +104,6 @@ struct MOZ_STACK_CLASS BindContext final { Document& mDoc; - Element* const mBindingParent; - const bool mInComposedDoc; const bool mInUncomposedDoc; diff --git a/dom/base/CharacterData.cpp b/dom/base/CharacterData.cpp index c8e44c15c3cb..6096999155a5 100644 --- a/dom/base/CharacterData.cpp +++ b/dom/base/CharacterData.cpp @@ -402,34 +402,9 @@ nsresult CharacterData::BindToTree(BindContext& aContext, nsINode& aParent) { // only assert if our parent is _changing_ while we have a parent. MOZ_ASSERT(!GetParentNode() || &aParent == GetParentNode(), "Already have a parent. Unbind first!"); - MOZ_ASSERT( - !GetBindingParent() || - aContext.GetBindingParent() == GetBindingParent() || - (!aContext.GetBindingParent() && aParent.IsContent() && - aParent.AsContent()->GetBindingParent() == GetBindingParent()), - "Already have a binding parent. Unbind first!"); - MOZ_ASSERT(!IsRootOfNativeAnonymousSubtree() || - aContext.GetBindingParent() == &aParent, - "Native anonymous content must have its parent as its " - "own binding parent"); - MOZ_ASSERT(aContext.GetBindingParent() || !aParent.IsContent() || - aContext.GetBindingParent() == - aParent.AsContent()->GetBindingParent(), - "We should be passed the right binding parent"); - - // First set the binding parent - if (Element* bindingParent = aContext.GetBindingParent()) { - ExtendedContentSlots()->mBindingParent = bindingParent; - } const bool hadParent = !!GetParentNode(); - NS_ASSERTION(!aContext.GetBindingParent() || - IsRootOfNativeAnonymousSubtree() || - !HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE) || - aParent.IsInNativeAnonymousSubtree(), - "Trying to re-bind content from native anonymous subtree to " - "non-native anonymous parent!"); if (aParent.IsInNativeAnonymousSubtree()) { SetFlags(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE); } @@ -497,8 +472,6 @@ nsresult CharacterData::BindToTree(BindContext& aContext, nsINode& aParent) { MOZ_ASSERT(IsInComposedDoc() == aContext.InComposedDoc()); MOZ_ASSERT(IsInUncomposedDoc() == aContext.InUncomposedDoc()); MOZ_ASSERT(&aParent == GetParentNode(), "Bound to wrong parent node"); - MOZ_ASSERT(aContext.GetBindingParent() == GetBindingParent(), - "Bound to wrong binding parent"); MOZ_ASSERT(aParent.IsInUncomposedDoc() == IsInUncomposedDoc()); MOZ_ASSERT(aParent.IsInComposedDoc() == IsInComposedDoc()); MOZ_ASSERT(aParent.IsInShadowTree() == IsInShadowTree()); @@ -533,9 +506,7 @@ void CharacterData::UnbindFromTree(bool aNullParent) { SetSubtreeRootPointer(aNullParent ? this : mParent->SubtreeRoot()); } - nsExtendedContentSlots* slots = GetExistingExtendedContentSlots(); - if (slots) { - slots->mBindingParent = nullptr; + if (nsExtendedContentSlots* slots = GetExistingExtendedContentSlots()) { if (aNullParent || !mParent->IsInShadowTree()) { slots->mContainingShadow = nullptr; } diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 514e4e952365..0368f397d093 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -1460,36 +1460,9 @@ nsresult Element::BindToTree(BindContext& aContext, nsINode& aParent) { // only assert if our parent is _changing_ while we have a parent. MOZ_ASSERT(!GetParentNode() || &aParent == GetParentNode(), "Already have a parent. Unbind first!"); - MOZ_ASSERT( - !GetBindingParent() || - aContext.GetBindingParent() == GetBindingParent() || - (!aContext.GetBindingParent() && aParent.IsContent() && - aParent.AsContent()->GetBindingParent() == GetBindingParent()), - "Already have a binding parent. Unbind first!"); - MOZ_ASSERT(aContext.GetBindingParent() != this, - "Content must not be its own binding parent"); - MOZ_ASSERT(!IsRootOfNativeAnonymousSubtree() || - aContext.GetBindingParent() == &aParent, - "Native anonymous content must have its parent as its " - "own binding parent"); - MOZ_ASSERT(aContext.GetBindingParent() || !aParent.IsContent() || - aContext.GetBindingParent() == - aParent.AsContent()->GetBindingParent(), - "We should be passed the right binding parent"); - - // First set the binding parent - if (Element* bindingParent = aContext.GetBindingParent()) { - ExtendedDOMSlots()->mBindingParent = bindingParent; - } const bool hadParent = !!GetParentNode(); - NS_ASSERTION(!aContext.GetBindingParent() || - IsRootOfNativeAnonymousSubtree() || - !HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE) || - aParent.IsInNativeAnonymousSubtree(), - "Trying to re-bind content from native anonymous subtree to " - "non-native anonymous parent!"); if (aParent.IsInNativeAnonymousSubtree()) { SetFlags(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE); } @@ -1627,8 +1600,6 @@ nsresult Element::BindToTree(BindContext& aContext, nsINode& aParent) { MOZ_ASSERT(IsInComposedDoc() == aContext.InComposedDoc()); MOZ_ASSERT(IsInUncomposedDoc() == aContext.InUncomposedDoc()); MOZ_ASSERT(&aParent == GetParentNode(), "Bound to wrong parent node"); - MOZ_ASSERT(aContext.GetBindingParent() == GetBindingParent(), - "Bound to wrong binding parent"); MOZ_ASSERT(aParent.IsInUncomposedDoc() == IsInUncomposedDoc()); MOZ_ASSERT(aParent.IsInComposedDoc() == IsInComposedDoc()); MOZ_ASSERT(aParent.IsInShadowTree() == IsInShadowTree()); @@ -1765,7 +1736,6 @@ void Element::UnbindFromTree(bool aNullParent) { } if (nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots()) { - slots->mBindingParent = nullptr; if (aNullParent || !mParent->IsInShadowTree()) { slots->mContainingShadow = nullptr; } diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index 3757c8f779c2..57b39dccacb8 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -530,16 +530,12 @@ static_assert(sizeof(FragmentOrElement::nsDOMSlots) <= MaxDOMSlotSizeAllowed, "DOM slots cannot be grown without consideration"); void nsIContent::nsExtendedContentSlots::UnlinkExtendedSlots() { - mBindingParent = nullptr; mContainingShadow = nullptr; mAssignedSlot = nullptr; } void nsIContent::nsExtendedContentSlots::TraverseExtendedSlots( nsCycleCollectionTraversalCallback& aCb) { - NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCb, "mExtendedSlots->mBindingParent"); - aCb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIContent*, mBindingParent)); - NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCb, "mExtendedSlots->mContainingShadow"); aCb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIContent*, mContainingShadow)); @@ -633,7 +629,6 @@ size_t FragmentOrElement::nsDOMSlots::SizeOfIncludingThis( // The following member are not measured: // - mControllers: because it is non-owning - // - mBindingParent: because it is some ancestor element. return n; } @@ -1061,28 +1056,6 @@ void nsIContent::SetAssignedSlot(HTMLSlotElement* aSlot) { ExtendedContentSlots()->mAssignedSlot = aSlot; } -#ifdef DEBUG -void nsIContent::AssertAnonymousSubtreeRelatedInvariants() const { - MOZ_ASSERT(!IsRootOfNativeAnonymousSubtree() || - (GetParent() && GetBindingParent() == GetParent()), - "root of native anonymous subtree must have parent equal " - "to binding parent"); - MOZ_ASSERT(!GetParent() || !IsInComposedDoc() || - ((GetBindingParent() == GetParent()) == - HasFlag(NODE_IS_ANONYMOUS_ROOT)) || - // Unfortunately default content for XBL insertion points - // is anonymous content that is bound with the parent of - // the insertion point as the parent but the bound element - // for the binding as the binding parent. So we have to - // complicate the assert a bit here. - (GetBindingParent() && - (GetBindingParent() == GetParent()->GetBindingParent()) == - HasFlag(NODE_IS_ANONYMOUS_ROOT)), - "For connected nodes, flag and GetBindingParent() check " - "should match"); -} -#endif - void FragmentOrElement::GetTextContentInternal(nsAString& aTextContent, OOMReporter& aError) { if (!nsContentUtils::GetNodeTextContent(this, true, aTextContent, fallible)) { diff --git a/dom/base/ShadowRoot.cpp b/dom/base/ShadowRoot.cpp index 3f4647e6de95..79dfee8b7015 100644 --- a/dom/base/ShadowRoot.cpp +++ b/dom/base/ShadowRoot.cpp @@ -62,7 +62,6 @@ ShadowRoot::ShadowRoot(Element* aElement, ShadowRootMode aMode, SetFlags(NODE_IS_IN_SHADOW_TREE); Bind(); - ExtendedDOMSlots()->mBindingParent = aElement; ExtendedDOMSlots()->mContainingShadow = this; } diff --git a/dom/base/nsIContent.h b/dom/base/nsIContent.h index 6c4a1adf3956..a2af2cf9772a 100644 --- a/dom/base/nsIContent.h +++ b/dom/base/nsIContent.h @@ -185,18 +185,11 @@ class nsIContent : public nsINode { */ nsIContent* FindFirstNonChromeOnlyAccessContent() const; -#ifdef DEBUG - void AssertAnonymousSubtreeRelatedInvariants() const; -#endif - /** * Returns true if and only if this node has a parent, but is not in * its parent's child list. */ bool IsRootOfAnonymousSubtree() const { -#ifdef DEBUG - AssertAnonymousSubtreeRelatedInvariants(); -#endif return HasFlag(NODE_IS_ANONYMOUS_ROOT); } @@ -371,21 +364,6 @@ class nsIContent : public nsINode { */ virtual IMEState GetDesiredIMEState(); - /** - * Gets content node with the binding (or native code, possibly on the - * frame) responsible for our construction (and existence). Used by - * native-anonymous content and shadow DOM. - * - * null for all explicit content (i.e., content reachable from the top - * of its GetParent() chain via child lists). - * - * @return the binding parent - */ - mozilla::dom::Element* GetBindingParent() const { - const nsExtendedContentSlots* slots = GetExistingExtendedContentSlots(); - return slots ? slots->mBindingParent.get() : nullptr; - } - /** * Gets the ShadowRoot binding for this element. * @@ -718,13 +696,6 @@ class nsIContent : public nsINode { virtual size_t SizeOfExcludingThis( mozilla::MallocSizeOf aMallocSizeOf) const; - /** - * The nearest enclosing content node with a binding that created us. - * - * @see nsIContent::GetBindingParent - */ - RefPtr mBindingParent; - /** * @see nsIContent::GetContainingShadow */ diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp index e4760bd55118..46e58d869623 100644 --- a/dom/base/nsINode.cpp +++ b/dom/base/nsINode.cpp @@ -536,20 +536,6 @@ void nsINode::LastRelease() { FragmentOrElement::RemoveBlackMarkedNode(this); } -#ifdef DEBUG -void nsINode::CheckNotNativeAnonymous() const { - if (!IsContent()) return; - nsIContent* content = - static_cast(this)->GetBindingParent(); - while (content) { - if (content->IsRootOfNativeAnonymousSubtree()) { - NS_ERROR("Element not marked to be in native anonymous subtree!"); - break; - } - content = content->GetBindingParent(); - } -} -#endif std::ostream& operator<<(std::ostream& aStream, const nsINode& aNode) { nsAutoString elemDesc; diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h index 187192702688..303138598e15 100644 --- a/dom/base/nsINode.h +++ b/dom/base/nsINode.h @@ -1242,15 +1242,7 @@ class nsINode : public mozilla::dom::EventTarget { * Returns true if |this| or any of its ancestors is native anonymous. */ bool IsInNativeAnonymousSubtree() const { -#ifdef DEBUG - if (HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE)) { - return true; - } - CheckNotNativeAnonymous(); - return false; -#else return HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE); -#endif } /** @@ -2041,12 +2033,6 @@ class nsINode : public mozilla::dom::EventTarget { nsIPrincipal* aSubjectPrincipal, mozilla::ErrorResult& aError) {} -#ifdef DEBUG - // Note: virtual so that IsInNativeAnonymousSubtree can be called accross - // module boundaries. - virtual void CheckNotNativeAnonymous() const; -#endif - void EnsurePreInsertionValidity1(mozilla::ErrorResult& aError); void EnsurePreInsertionValidity2(bool aReplace, nsINode& aNewChild, nsINode* aRefChild,