Bug 1395351: Assert the root element is styled in StyleDocument. r?bholley draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 01 Sep 2017 19:31:45 +0200
changeset 657642 6535d852a23138393a4b6203001fd5abb948e407
parent 657641 0ecd7593a02dbe48875546231cff9fcd8de19676
child 657643 99058669514143979dc0e200a1b6226320582395
push id77581
push userbmo:emilio@crisal.io
push dateFri, 01 Sep 2017 18:40:22 +0000
reviewersbholley
bugs1395351
milestone57.0a1
Bug 1395351: Assert the root element is styled in StyleDocument. r?bholley MozReview-Commit-ID: 6KncJ5IqLbt
layout/style/ServoStyleSet.cpp
--- 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;
 }