Bug 1395351: Assert the root element is styled in StyleDocument. r?bholley
MozReview-Commit-ID: 6KncJ5IqLbt
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -885,18 +885,17 @@ ServoStyleSet::StyleDocument(ServoTraver
AutoPrepareTraversal guard(this);
const SnapshotTable& snapshots = Snapshots();
// Restyle the document from the root element and each of the document level
// NAC subtree roots.
bool postTraversalRequired = false;
Element* rootElement = doc->GetRootElement();
- // NB: We distinguish between the main document and document-level NAC here.
- const bool isInitialForMainDoc = rootElement && !rootElement->HasServoData();
+ MOZ_ASSERT_IF(rootElement, rootElement->HasServoData());
// Do the first traversal.
DocumentStyleRootIterator iter(doc->GetServoRestyleRoot());
while (Element* root = iter.GetNextStyleRoot()) {
MOZ_ASSERT(MayTraverseFrom(const_cast<Element*>(root)));
// If there were text nodes inserted into the document (but not elements),
// there may be lazy frame construction to do even if no styling is required.
@@ -926,28 +925,18 @@ ServoStyleSet::StyleDocument(ServoTraver
//
// We don't need to do this for SMIL since SMIL only updates its animation
// values once at the begin of a tick. As a result, even if the previous
// traversal caused, for example, the font-size to change, the SMIL style
// won't be updated until the next tick anyway.
if (mPresContext->EffectCompositor()->PreTraverse(aBaseFlags)) {
nsINode* styleRoot = doc->GetServoRestyleRoot();
Element* root = styleRoot->IsElement() ? styleRoot->AsElement() : rootElement;
- auto flags = aBaseFlags;
- flags |= ServoTraversalFlags::ParallelTraversal;
- if (isInitialForMainDoc) {
- // We're doing initial styling, and the additional animation
- // traversal will change the styles that were set by the first traversal.
- // This would normally require a post-traversal to update the style
- // contexts, but since this is actually the initial styling, there are
- // no style contexts to update and no frames to apply the change hints to,
- // so we just do a forgetful traversal and clear the flags on the way.
- flags |= ServoTraversalFlags::Forgetful |
- ServoTraversalFlags::ClearAnimationOnlyDirtyDescendants;
- }
+
+ auto flags = aBaseFlags | ServoTraversalFlags::ParallelTraversal;
bool required = Servo_TraverseSubtree(root, mRawSet.get(), &snapshots, flags);
postTraversalRequired |= required;
}
return postTraversalRequired;
}