зеркало из https://github.com/mozilla/gecko-dev.git
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
This commit is contained in:
Родитель
e4483437bd
Коммит
5b84f966ac
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -62,7 +62,6 @@ ShadowRoot::ShadowRoot(Element* aElement, ShadowRootMode aMode,
|
|||
SetFlags(NODE_IS_IN_SHADOW_TREE);
|
||||
Bind();
|
||||
|
||||
ExtendedDOMSlots()->mBindingParent = aElement;
|
||||
ExtendedDOMSlots()->mContainingShadow = this;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<mozilla::dom::Element> mBindingParent;
|
||||
|
||||
/**
|
||||
* @see nsIContent::GetContainingShadow
|
||||
*/
|
||||
|
|
|
@ -536,20 +536,6 @@ void nsINode::LastRelease() {
|
|||
FragmentOrElement::RemoveBlackMarkedNode(this);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void nsINode::CheckNotNativeAnonymous() const {
|
||||
if (!IsContent()) return;
|
||||
nsIContent* content =
|
||||
static_cast<const nsIContent*>(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;
|
||||
|
|
|
@ -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,
|
||||
|
|
Загрузка…
Ссылка в новой задаче