Bug 1180120 - Part 5: Factor out section of ElementRestyler::Restyle that calls AddPendingRestylesForDescendantsMatchingSelectors. r=dbaron a=sylvestre
authorCameron McCormack <cam@mcc.id.au>
Sat, 29 Aug 2015 06:13:47 +1000
changeset 289219 7fca6840789d6f59b78dd23054283977f2884869
parent 289218 dbf8d7d2b9358130e67b616f1fbc5ade6f8ea4c8
child 289220 6ddcf355f74018df5fbc133f93fdf92f572ca0b6
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 5: Factor out section of ElementRestyler::Restyle that calls AddPendingRestylesForDescendantsMatchingSelectors. r=dbaron a=sylvestre
layout/base/RestyleManager.cpp
layout/base/RestyleManager.h
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -2825,16 +2825,46 @@ ElementRestyler::AddPendingRestylesForDe
   for (nsIContent* n = it.GetNextChild(); n; n = it.GetNextChild()) {
     if (n->IsElement()) {
       AddPendingRestylesForDescendantsMatchingSelectors(n->AsElement(),
                                                         aRestyleRoot);
     }
   }
 }
 
+void
+ElementRestyler::AddPendingRestylesForDescendantsMatchingSelectors(
+    nsIContent* aContent)
+{
+  if (!mContent->IsElement() || mSelectorsForDescendants.IsEmpty()) {
+    return;
+  }
+
+  Element* element = mContent->AsElement();
+
+  LOG_RESTYLE("traversing descendants of element %s to propagate "
+              "eRestyle_SomeDescendants for these %d selectors:",
+              ElementTagToString(element).get(),
+              int(mSelectorsForDescendants.Length()));
+  LOG_RESTYLE_INDENT();
+#ifdef RESTYLE_LOGGING
+  for (nsCSSSelector* sel : mSelectorsForDescendants) {
+    LOG_RESTYLE("%s", sel->RestrictedSelectorToString().get());
+  }
+#endif
+  Element* restyleRoot = mRestyleTracker.FindClosestRestyleRoot(element);
+  FlattenedChildIterator it(element);
+  for (nsIContent* n = it.GetNextChild(); n; n = it.GetNextChild()) {
+    if (n->IsElement()) {
+      AddPendingRestylesForDescendantsMatchingSelectors(n->AsElement(),
+                                                        restyleRoot);
+    }
+  }
+}
+
 /**
  * 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
@@ -3009,40 +3039,18 @@ ElementRestyler::Restyle(nsRestyleHint a
     // Send the accessibility notifications that RestyleChildren otherwise
     // would have sent.
     if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
       InitializeAccessibilityNotifications(mFrame->StyleContext());
       SendAccessibilityNotifications();
     }
 
     mRestyleTracker.AddRestyleRootsIfAwaitingRestyle(descendants);
-
-    if (mContent->IsElement()) {
-      if ((aRestyleHint & eRestyle_SomeDescendants) &&
-          !mSelectorsForDescendants.IsEmpty()) {
-        Element* element = mContent->AsElement();
-        LOG_RESTYLE("traversing descendants of element %s to propagate "
-                    "eRestyle_SomeDescendants for these %d selectors:",
-                    ElementTagToString(element).get(),
-                    int(mSelectorsForDescendants.Length()));
-        LOG_RESTYLE_INDENT();
-#ifdef RESTYLE_LOGGING
-        for (nsCSSSelector* sel : mSelectorsForDescendants) {
-          LOG_RESTYLE("%s", sel->RestrictedSelectorToString().get());
-        }
-#endif
-        Element* restyleRoot = mRestyleTracker.FindClosestRestyleRoot(element);
-        FlattenedChildIterator it(element);
-        for (nsIContent* n = it.GetNextChild(); n; n = it.GetNextChild()) {
-          if (n->IsElement()) {
-            AddPendingRestylesForDescendantsMatchingSelectors(n->AsElement(),
-                                                              restyleRoot);
-          }
-        }
-      }
+    if (aRestyleHint & eRestyle_SomeDescendants) {
+      AddPendingRestylesForDescendantsMatchingSelectors(mContent);
     }
     return;
   }
 
   if (!swappedStructs) {
     // If we swapped any structs from the old context, then we need to keep
     // it alive until after the RestyleChildren call so that we can fix up
     // its descendants' cached structs.
--- a/layout/base/RestyleManager.h
+++ b/layout/base/RestyleManager.h
@@ -727,16 +727,17 @@ private:
   enum A11yNotificationType {
     eDontNotify,
     eNotifyShown,
     eNotifyHidden
   };
 
   void AddPendingRestylesForDescendantsMatchingSelectors(Element* aElement,
                                                          Element* aRestyleRoot);
+  void AddPendingRestylesForDescendantsMatchingSelectors(nsIContent* aContent);
 
 #ifdef RESTYLE_LOGGING
   int32_t& LoggingDepth() { return mLoggingDepth; }
 #endif
 
 #ifdef DEBUG
   static nsCString RestyleResultToString(RestyleResult aRestyleResult);
 #endif