Bug 1403712: Make some assertions not assert for conditions that may happen mid-unbind. r?bholley
MozReview-Commit-ID: DNSphdMismy
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -4286,16 +4286,17 @@ BitsArePropagated(const Element* aElemen
return true;
}
if (!curr->HasAllFlags(aBits)) {
return false;
}
nsINode* parentNode = curr->GetParentNode();
curr = curr->GetFlattenedTreeParentElementForStyle();
MOZ_ASSERT_IF(!curr,
+ !parentNode || // can only happen mid-unbind.
parentNode == aElement->OwnerDoc() ||
parentNode == parentNode->OwnerDoc()->GetRootElement());
}
return true;
}
#endif
static inline void
@@ -4448,17 +4449,20 @@ NoteDirtyElement(Element* aElement, uint
} else {
// We didn't find a common ancestor element. That means we're descended
// from two different document style roots, so the common ancestor is the
// document.
doc->SetServoRestyleRoot(doc, existingBits | aBits);
}
}
+ // See the comment in nsIDocument::SetServoRestyleRoot about the !IsElement()
+ // check there. Same justification here.
MOZ_ASSERT(aElement == doc->GetServoRestyleRoot() ||
+ !doc->GetServoRestyleRoot()->IsElement() ||
nsContentUtils::ContentIsFlattenedTreeDescendantOfForStyle(
aElement, doc->GetServoRestyleRoot()));
MOZ_ASSERT(aElement == doc->GetServoRestyleRoot() ||
BitsArePropagated(parent, aBits, doc->GetServoRestyleRoot()));
MOZ_ASSERT(doc->GetServoRestyleRootDirtyBits() & aBits);
}
void
--- a/dom/base/nsIDocumentInlines.h
+++ b/dom/base/nsIDocumentInlines.h
@@ -83,15 +83,14 @@ nsIDocument::SetServoRestyleRoot(nsINode
// content unbinding for parents, like fieldset validity stuff and ancestor
// direction changes off script runners or, alternatively, nulling out the
// document and parent node _after_ nulling out the children's, and then
// remove that line.
MOZ_ASSERT(!mServoRestyleRoot ||
mServoRestyleRoot == aRoot ||
!aRoot->IsElement() ||
nsContentUtils::ContentIsFlattenedTreeDescendantOfForStyle(mServoRestyleRoot, aRoot));
- MOZ_ASSERT(aRoot == aRoot->OwnerDocAsNode() ||
- (aRoot->IsElement() && aRoot->IsInComposedDoc()));
+ MOZ_ASSERT(aRoot == aRoot->OwnerDocAsNode() || aRoot->IsElement());
mServoRestyleRoot = aRoot;
mServoRestyleRootDirtyBits = aDirtyBits;
}
#endif // nsIDocumentInlines_h