Bug 1286445: stylo: Unset restyle frames appropriately after regenerating style contexts. r=heycam draft
authorEmilio Cobos Álvarez <ecoal95@gmail.com>
Fri, 15 Jul 2016 11:48:45 -0700
changeset 388419 d73d6b3baa8547cde259afc5d991b09e6e192629
parent 388418 780c3eca880f911ab46bc573e5addcfe2936169a
child 525538 a38a34bab7c8eda7d73b74fd3213d93b790efe0a
push id23164
push userbmo:ealvarez@mozilla.com
push dateFri, 15 Jul 2016 18:56:00 +0000
reviewersheycam
bugs1286445
milestone50.0a1
Bug 1286445: stylo: Unset restyle frames appropriately after regenerating style contexts. r=heycam MozReview-Commit-ID: IgG4KOESJUY
layout/base/ServoRestyleManager.cpp
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -97,16 +97,17 @@ ServoRestyleManager::PostRebuildAllStyle
 ServoRestyleManager::RecreateStyleContexts(nsIContent* aContent,
                                            nsStyleContext* aParentContext,
                                            ServoStyleSet* aStyleSet)
 {
   if (!(aContent->IsDirtyForServo() || aContent->HasDirtyDescendantsForServo())) {
     return;
   }
 
+  aContent->UnsetFlags(NODE_IS_DIRTY_FOR_SERVO);
   nsIFrame* primaryFrame = aContent->GetPrimaryFrame();
 
   // TODO: AFAIK this can happen when we have, let's say, display: none. Here we
   // should trigger frame construction if the element is actually dirty (I
   // guess), but we'd better do that once we have all the restyle hints thing
   // figured out.
   if (!primaryFrame) {
     return;
@@ -122,20 +123,25 @@ ServoRestyleManager::RecreateStyleContex
                           aParentContext,
                           nullptr,
                           CSSPseudoElementType::NotPseudo);
 
   // TODO: Compare old and new styles to generate restyle change hints, and
   // process them.
   primaryFrame->SetStyleContext(context.get());
 
+  if (!aContent->HasDirtyDescendantsForServo()) {
+    return; // We're done
+  }
+
   FlattenedChildIterator it(aContent);
   for (nsIContent* n = it.GetNextChild(); n; n = it.GetNextChild()) {
     RecreateStyleContexts(n, context.get(), aStyleSet);
   }
+  aContent->UnsetFlags(NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO);
 }
 
 void
 ServoRestyleManager::ProcessPendingRestyles()
 {
   ServoStyleSet* styleSet = StyleSet();
 
   nsIDocument* doc = PresContext()->Document();