Bug 1519193 part 5. Convert AssertNoStaleServoDataIn to using ShadowIncludingTreeIterator. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D16247

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2019-01-12 03:20:44 +00:00
Родитель 188ff78bd7
Коммит d2c80f84e7
1 изменённых файлов: 9 добавлений и 8 удалений

Просмотреть файл

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