Bug 1395351: Don't clobber restyle root flags from frame construction. r?bholley
MozReview-Commit-ID: EsXKiLbYQsY
--- 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,