Bug 1441136: Add a fast way to enumerate ShadowRoots in a document. r=smaug
MozReview-Commit-ID: 7QffP56jsyk
This commit is contained in:
@@ -168,26 +168,6 @@ ServoStyleSet::Init(nsPresContext* aPresContext)
|
||||
SetStylistXBLStyleSheetsDirty();
|
||||
}
|
||||
|
||||
template<typename Functor>
|
||||
void
|
||||
EnumerateShadowRootsInSubtree(const nsINode& aRoot, const Functor& aCb)
|
||||
{
|
||||
for (const nsINode* cur = &aRoot; cur; cur = cur->GetNextNode()) {
|
||||
if (!cur->IsElement()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto* shadowRoot = cur->AsElement()->GetShadowRoot();
|
||||
if (!shadowRoot) {
|
||||
continue;
|
||||
}
|
||||
|
||||
aCb(*shadowRoot);
|
||||
EnumerateShadowRootsInSubtree(*shadowRoot, aCb);
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(emilio): We may want a faster way to do this.
|
||||
template<typename Functor>
|
||||
void
|
||||
EnumerateShadowRoots(const nsIDocument& aDoc, const Functor& aCb)
|
||||
@@ -196,7 +176,13 @@ EnumerateShadowRoots(const nsIDocument& aDoc, const Functor& aCb)
|
||||
return;
|
||||
}
|
||||
|
||||
EnumerateShadowRootsInSubtree(aDoc, aCb);
|
||||
const nsIDocument::ShadowRootSet& shadowRoots = aDoc.ComposedShadowRoots();
|
||||
for (auto iter = shadowRoots.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
ShadowRoot* root = iter.Get()->GetKey();
|
||||
MOZ_ASSERT(root);
|
||||
MOZ_DIAGNOSTIC_ASSERT(root->IsComposedDocParticipant());
|
||||
aCb(*root);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user