Bug 1425759: Make ChildIterator handle Shadow DOM explicitly. r?smaug
I'll rename mIsXBLInvolved in a bit, since I plan to do more changes here in
bug 1422653.
MozReview-Commit-ID: JCeAgk2DoY4
--- a/dom/base/ChildIterator.cpp
+++ b/dom/base/ChildIterator.cpp
@@ -122,28 +122,40 @@ ExplicitChildIterator::GetNextChild()
void
FlattenedChildIterator::Init(bool aIgnoreXBL)
{
if (aIgnoreXBL) {
return;
}
+ // TODO(emilio): I think it probably makes sense to only allow constructing
+ // FlattenedChildIterators with Element.
+ if (mParent->IsElement()) {
+ if (ShadowRoot* shadow = mParent->AsElement()->GetShadowRoot()) {
+ mParent = shadow;
+ mXBLInvolved = true;
+ return;
+ }
+ }
+
nsXBLBinding* binding =
mParent->OwnerDoc()->BindingManager()->GetBindingWithContent(mParent);
if (binding) {
MOZ_ASSERT(binding->GetAnonymousContent());
mParent = binding->GetAnonymousContent();
mXBLInvolved = true;
}
// We set mXBLInvolved to true if either:
// - The node we're iterating has a binding with content attached to it.
// - The node is generated XBL content and has an <xbl:children> child.
+ //
+ // FIXME(emilio): This is very slow :(
if (!mXBLInvolved && mParent->GetBindingParent()) {
for (nsIContent* child = mParent->GetFirstChild();
child;
child = child->GetNextSibling()) {
if (child->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
MOZ_ASSERT(child->GetBindingParent());
mXBLInvolved = true;
break;