Bug 1077849 - Use eRestyle_ForceDescendants for all cases of rebuilding the rule tree. r=heycam
authorL. David Baron <dbaron@dbaron.org>
Sat, 04 Oct 2014 16:59:47 -0700
changeset 232049 41ce29f771b23dc619c2589ef1c30648e16599bb
parent 232048 916f2837201cfa240febe707f2ba73f0c6e33cd1
child 232050 e2ae0efd508a8d67b31dc567315898046d1de597
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1077849, 931668
milestone35.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 1077849 - Use eRestyle_ForceDescendants for all cases of rebuilding the rule tree. r=heycam Bug 931668 added the eRestyle_ForceDescendants case for all cases that go through RebuildAllStyleData, but there is another case that calls DoRebuildAllStyleData directly, and we should cover that too. This is needed because when we're rebuilding the rule tree, we need to create new style contexts for all frames. I don't know of any bugs caused by this, but it seems worth fixing.
layout/base/RestyleManager.cpp
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -1449,19 +1449,17 @@ RestyleManager::RebuildAllStyleData(nsCh
   mPostAnimationRestyles = true;
 
   // FIXME (bug 1047928): Many of the callers probably don't need
   // eRestyle_Subtree because they're changing things that affect data
   // computation rather than selector matching; we could have a restyle
   // hint passed in, and substantially improve the performance of things
   // like pref changes and the restyling that we do for downloadable
   // font loads.
-  DoRebuildAllStyleData(mPendingRestyles, aExtraHint,
-                        nsRestyleHint(eRestyle_Subtree |
-                                      eRestyle_ForceDescendants));
+  DoRebuildAllStyleData(mPendingRestyles, aExtraHint, eRestyle_Subtree);
 
   mPostAnimationRestyles = false;
   mSkipAnimationRules = false;
 #ifdef DEBUG
   mIsProcessingRestyles = false;
 #endif
 
   // Make sure that we process any pending animation restyles from the
@@ -1478,18 +1476,20 @@ RestyleManager::DoRebuildAllStyleData(Re
 {
   // Tell the style set to get the old rule tree out of the way
   // so we can recalculate while maintaining rule tree immutability
   nsresult rv = mPresContext->StyleSet()->BeginReconstruct();
   if (NS_FAILED(rv)) {
     return;
   }
 
-  if ((aRestyleHint & (eRestyle_Subtree | eRestyle_ForceDescendants)) !=
-      (eRestyle_Subtree | eRestyle_ForceDescendants)) {
+  aRestyleHint = aRestyleHint | eRestyle_ForceDescendants;
+
+  if (!(aRestyleHint & eRestyle_Subtree) &&
+      (aRestyleHint & ~(eRestyle_Force | eRestyle_ForceDescendants))) {
     // We want this hint to apply to the root node's primary frame
     // rather than the root frame, since it's the primary frame that has
     // the styles for the root element (rather than the ancestors of the
     // primary frame whose mContent is the root node but which have
     // different styles).  If we use up the hint for one of the
     // ancestors that we hit first, then we'll fail to do the restyling
     // we need to do.
     aRestyleTracker.AddPendingRestyle(mPresContext->Document()->GetRootElement(),