diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 9775330be467..d8b866305b71 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -75,6 +75,7 @@ #include "mozilla/dom/Performance.h" #include "mozilla/dom/ServiceWorkerContainer.h" #include "mozilla/dom/ScriptLoader.h" +#include "mozilla/dom/ShadowIncludingTreeIterator.h" #include "mozilla/dom/StyleSheetList.h" #include "mozilla/dom/SVGUseElement.h" #include "nsGenericHTMLElement.h" @@ -3547,21 +3548,21 @@ void Document::TryChannelCharset(nsIChannel* aChannel, int32_t& aCharsetSource, } } -static inline void AssertNoStaleServoDataIn(const nsINode& aSubtreeRoot) { +static inline void AssertNoStaleServoDataIn(nsINode& aSubtreeRoot) { #ifdef DEBUG - for (const nsINode* node = &aSubtreeRoot; node; - node = node->GetNextNode(&aSubtreeRoot)) { + for (nsINode* node : ShadowIncludingTreeIterator(aSubtreeRoot)) { const Element* element = Element::FromNode(node); if (!element) { continue; } MOZ_ASSERT(!element->HasServoData()); - if (auto* shadow = element->GetShadowRoot()) { - AssertNoStaleServoDataIn(*shadow); - } if (nsXBLBinding* binding = element->GetXBLBinding()) { if (nsXBLBinding* bindingWithContent = binding->GetBindingWithContent()) { nsIContent* content = bindingWithContent->GetAnonymousContent(); + // Need to do this instead of just AssertNoStaleServoDataIn(*content), + // because the parent of the children of the element isn't the + // element, but the bound element, and that confuses + // GetNextNode a lot. MOZ_ASSERT(!content->AsElement()->HasServoData()); for (nsINode* child = content->GetFirstChild(); child; child = child->GetNextSibling()) { @@ -3581,7 +3582,7 @@ already_AddRefed Document::CreateShell( NS_ENSURE_FALSE(GetBFCacheEntry(), nullptr); FillStyleSet(aStyleSet.get()); - AssertNoStaleServoDataIn(static_cast(*this)); + AssertNoStaleServoDataIn(*this); RefPtr shell = new PresShell; // Note: we don't hold a ref to the shell (it holds a ref to us) @@ -3704,7 +3705,7 @@ void Document::DeleteShell() { mStyleSetFilled = false; ClearStaleServoData(); - AssertNoStaleServoDataIn(static_cast(*this)); + AssertNoStaleServoDataIn(*this); } void Document::SetBFCacheEntry(nsIBFCacheEntry* aEntry) {