Bug 1180120 - Part 6.1: Factor out some of RestyleUndisplayedDescendants. r=dbaron a=sylvestre
authorCameron McCormack <cam@mcc.id.au>
Sat, 29 Aug 2015 06:13:47 +1000
changeset 289221 80143eb3ab7333a09939f264cd8748edb228f4bc
parent 289220 6ddcf355f74018df5fbc133f93fdf92f572ca0b6
child 289222 121de382cd526ac99d0087fdcacef274bf5944aa
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron, sylvestre
bugs1180120
milestone42.0a2
Bug 1180120 - Part 6.1: Factor out some of RestyleUndisplayedDescendants. r=dbaron a=sylvestre
layout/base/RestyleManager.cpp
layout/base/RestyleManager.h
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -2855,16 +2855,32 @@ ElementRestyler::AddPendingRestylesForDe
   for (nsIContent* n = it.GetNextChild(); n; n = it.GetNextChild()) {
     if (n->IsElement()) {
       AddPendingRestylesForDescendantsMatchingSelectors(n->AsElement(),
                                                         restyleRoot);
     }
   }
 }
 
+bool
+ElementRestyler::MustCheckUndisplayedContent(nsIContent*& aUndisplayedParent)
+{
+  // When the root element is display:none, we still construct *some*
+  // frames that have the root element as their mContent, down to the
+  // DocElementContainingBlock.
+  if (mFrame->StyleContext()->GetPseudo()) {
+    aUndisplayedParent = nullptr;
+    return mFrame == mPresContext->FrameConstructor()->
+                       GetDocElementContainingBlock();
+  }
+
+  aUndisplayedParent = mFrame->GetContent();
+  return !!aUndisplayedParent;
+}
+
 /**
  * Recompute style for mFrame (which should not have a prev continuation
  * with the same style), all of its next continuations with the same
  * style, and all ib-split siblings of the same type (either block or
  * inline, skipping the intermediates of the other type) and accumulate
  * changes into mChangeList given that mHintsHandled is already accumulated
  * for an ancestor.
  * mParentContent is the content node used to resolve the parent style
@@ -3936,30 +3952,18 @@ ElementRestyler::ComputeStyleChangeFor(n
       }
     }
   }
 }
 
 void
 ElementRestyler::RestyleUndisplayedDescendants(nsRestyleHint aChildRestyleHint)
 {
-  // When the root element is display:none, we still construct *some*
-  // frames that have the root element as their mContent, down to the
-  // DocElementContainingBlock.
-  bool checkUndisplayed;
   nsIContent* undisplayedParent;
-  if (mFrame->StyleContext()->GetPseudo()) {
-    checkUndisplayed = mFrame == mPresContext->FrameConstructor()->
-                                   GetDocElementContainingBlock();
-    undisplayedParent = nullptr;
-  } else {
-    checkUndisplayed = !!mFrame->GetContent();
-    undisplayedParent = mFrame->GetContent();
-  }
-  if (checkUndisplayed) {
+  if (MustCheckUndisplayedContent(undisplayedParent)) {
     DoRestyleUndisplayedDescendants(aChildRestyleHint, undisplayedParent,
                                     mFrame->StyleContext());
   }
 }
 
 void
 ElementRestyler::DoRestyleUndisplayedDescendants(nsRestyleHint aChildRestyleHint,
                                                  nsIContent* aParent,
--- a/layout/base/RestyleManager.h
+++ b/layout/base/RestyleManager.h
@@ -681,20 +681,20 @@ private:
                      nsStyleContext* aNewContext,
                      nsChangeHint aChangeToAssume,
                      uint32_t* aEqualStructs,
                      uint32_t* aSamePointerStructs);
   RestyleResult ComputeRestyleResultFromFrame(nsIFrame* aSelf);
   RestyleResult ComputeRestyleResultFromNewContext(nsIFrame* aSelf,
                                                    nsStyleContext* aNewContext);
 
-  /**
-   * Helpers for RestyleChildren().
-   */
+  // Helpers for RestyleChildren().
   void RestyleUndisplayedDescendants(nsRestyleHint aChildRestyleHint);
+  bool MustCheckUndisplayedContent(nsIContent*& aUndisplayedParent);
+
   /**
    * In the following two methods, aParentStyleContext is either
    * mFrame->StyleContext() if we have a frame, or a display:contents
    * style context if we don't.
    */
   void DoRestyleUndisplayedDescendants(nsRestyleHint aChildRestyleHint,
                                        nsIContent* aParent,
                                        nsStyleContext* aParentStyleContext);