Bug 1395351: Don't clobber restyle root flags from frame construction. r=bholley
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 31 Aug 2017 21:37:50 +0200
changeset 427801 ec07132e0715d11936a1d272ccfae8ebffa69e32
parent 427800 1feb294747ee383b3c84d4d14719a4a448865c52
child 427802 2c92da35650879f58efef9a20e5010338b7b6e99
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1395351
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1395351: Don't clobber restyle root flags from frame construction. r=bholley MozReview-Commit-ID: EsXKiLbYQsY
dom/base/nsIDocumentInlines.h
layout/base/nsCSSFrameConstructor.cpp
--- a/dom/base/nsIDocumentInlines.h
+++ b/dom/base/nsIDocumentInlines.h
@@ -59,20 +59,17 @@ nsIDocument::FindDocStyleSheetInsertionP
 }
 
 inline void
 nsIDocument::SetServoRestyleRoot(nsINode* aRoot, uint32_t aDirtyBits)
 {
   MOZ_ASSERT(aRoot);
   MOZ_ASSERT(aDirtyBits);
   MOZ_ASSERT((aDirtyBits & ~Element::kAllServoDescendantBits) == 0);
-  // FIXME(emilio): This should hold, but we're clobbering it from
-  // nsCSSFrameConstructor::ConstructDocElementFrame, which is wrong!
-  //
-  // MOZ_ASSERT((aDirtyBits & mServoRestyleRootDirtyBits) == mServoRestyleRootDirtyBits);
+  MOZ_ASSERT((aDirtyBits & mServoRestyleRootDirtyBits) == mServoRestyleRootDirtyBits);
 
   MOZ_ASSERT(!mServoRestyleRoot ||
              mServoRestyleRoot == aRoot ||
              nsContentUtils::ContentIsFlattenedTreeDescendantOfForStyle(mServoRestyleRoot, aRoot));
   MOZ_ASSERT(aRoot == aRoot->OwnerDocAsNode() ||
              (aRoot->IsElement() && aRoot->IsInComposedDoc()));
   mServoRestyleRoot = aRoot;
   mServoRestyleRootDirtyBits = aDirtyBits;
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -2544,23 +2544,23 @@ nsCSSFrameConstructor::ConstructDocEleme
   // have stale restyle bits from a previous frame constructor for
   // this document.  Unlike in AddFrameConstructionItems, it's safe to
   // unset all element restyle flags, since we don't have any
   // siblings.
   aDocElement->UnsetRestyleFlagsIfGecko();
 
   // --------- CREATE AREA OR BOX FRAME -------
   if (ServoStyleSet* set = mPresShell->StyleSet()->GetAsServo()) {
-    // We need to explicitly set a restyle root for the first traversal.
-    aDocElement->OwnerDoc()->SetServoRestyleRoot(aDocElement->OwnerDocAsNode(),
-                                                 ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO);
-    // NOTE(emilio): If the root has a non-null binding, we'll stop at the
-    // document element and won't process any children, loading the bindings (or
-    // failing to do so) will take care of the rest.
-    set->StyleDocument(ServoTraversalFlags::Empty);
+    // Ensure the document element is styled at this point.
+    if (!aDocElement->HasServoData()) {
+      // NOTE(emilio): If the root has a non-null binding, we'll stop at the
+      // document element and won't process any children, loading the bindings
+      // (or failing to do so) will take care of the rest.
+      set->StyleNewSubtree(aDocElement);
+    }
   }
 
   // FIXME: Should this use ResolveStyleContext?  (The calls in this
   // function are the only case in nsCSSFrameConstructor where we don't
   // do so for the construction of a style context for an element.)
   RefPtr<nsStyleContext> styleContext =
     mPresShell->StyleSet()->ResolveStyleFor(aDocElement,
                                             nullptr,