Bug 1441136: Add a fast way to enumerate ShadowRoots in a document. r=smaug

MozReview-Commit-ID: 7QffP56jsyk
This commit is contained in:
Emilio Cobos Álvarez
2018-03-29 18:49:10 +02:00
parent 12e993f341
commit c94e7011c1
5 changed files with 64 additions and 25 deletions

View File

@@ -81,12 +81,35 @@ ShadowRoot::~ShadowRoot()
host->RemoveMutationObserver(this);
}
if (IsComposedDocParticipant()) {
OwnerDoc()->RemoveComposedDocShadowRoot(*this);
}
MOZ_DIAGNOSTIC_ASSERT(!OwnerDoc()->IsComposedDocShadowRoot(*this));
UnsetFlags(NODE_IS_IN_SHADOW_TREE);
// nsINode destructor expects mSubtreeRoot == this.
SetSubtreeRootPointer(this);
}
void
ShadowRoot::SetIsComposedDocParticipant(bool aIsComposedDocParticipant)
{
bool changed = mIsComposedDocParticipant != aIsComposedDocParticipant;
mIsComposedDocParticipant = aIsComposedDocParticipant;
if (!changed) {
return;
}
nsIDocument* doc = OwnerDoc();
if (IsComposedDocParticipant()) {
doc->AddComposedDocShadowRoot(*this);
} else {
doc->RemoveComposedDocShadowRoot(*this);
}
}
JSObject*
ShadowRoot::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{