Bug 1133615 - Don't assert about the contents of RestyleData::mDescendants when in a full style rebuild. r=dbaron
authorCameron McCormack <cam@mcc.id.au>
Sat, 20 Feb 2016 13:20:24 +1100
changeset 307893 712bfced88a692b75fe29d41bc3475faa7b913b1
parent 307892 cc962ae62f29792f467236562c3ae5a1d9e4d0c0
child 307894 22d83ceb4b4c5f822524ed12326c89f64ec2c075
push id9214
push userraliiev@mozilla.com
push dateMon, 07 Mar 2016 14:25:21 +0000
treeherdermozilla-aurora@8849dd1a4a79 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1133615
milestone47.0a1
Bug 1133615 - Don't assert about the contents of RestyleData::mDescendants when in a full style rebuild. r=dbaron
layout/base/RestyleManager.h
layout/base/RestyleTracker.cpp
--- a/layout/base/RestyleManager.h
+++ b/layout/base/RestyleManager.h
@@ -437,16 +437,20 @@ public:
    * style data has become invalid. We assume that the root frame will not
    * need to be reframed.
    *
    * For parameters, see RebuildAllStyleData.
    */
   void PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint,
                                     nsRestyleHint aRestyleHint);
 
+#ifdef DEBUG
+  bool InRebuildAllStyleData() const { return mInRebuildAllStyleData; }
+#endif
+
 #ifdef RESTYLE_LOGGING
   /**
    * Returns whether a restyle event currently being processed by this
    * RestyleManager should be logged.
    */
   bool ShouldLogRestyle() {
     return ShouldLogRestyle(mPresContext);
   }
--- a/layout/base/RestyleTracker.cpp
+++ b/layout/base/RestyleTracker.cpp
@@ -408,18 +408,29 @@ RestyleTracker::GetRestyleData(Element* 
   mPendingRestyles.RemoveAndForget(aElement, aData);
   NS_ASSERTION(aData.get(), "Must have data if restyle bit is set");
 
   if (aData->mRestyleHint & eRestyle_LaterSiblings) {
     // Someone readded the eRestyle_LaterSiblings hint for this
     // element.  Leave it around for now, but remove the other restyle
     // hints and the change hint for it.  Also unset its root bit,
     // since it's no longer a root with the new restyle data.
-    NS_ASSERTION(aData->mDescendants.IsEmpty(),
+
+    // During a normal restyle, we should have already processed the
+    // mDescendants array the last time we processed the restyle
+    // for this element.  But in RebuildAllStyleData, we don't initially
+    // expand out eRestyle_LaterSiblings, so we can get in here the
+    // first time we need to process a restyle for this element.  In that
+    // case, it's fine for us to have a non-empty mDescendants, since
+    // we know that RebuildAllStyleData adds eRestyle_ForceDescendants
+    // and we're guaranteed we'll restyle the entire tree.
+    NS_ASSERTION(mRestyleManager->InRebuildAllStyleData() ||
+                 aData->mDescendants.IsEmpty(),
                  "expected descendants to be handled by now");
+
     RestyleData* newData = new RestyleData;
     newData->mChangeHint = nsChangeHint(0);
     newData->mRestyleHint = eRestyle_LaterSiblings;
     mPendingRestyles.Put(aElement, newData);
     aElement->UnsetFlags(RootBit());
     aData->mRestyleHint =
       nsRestyleHint(aData->mRestyleHint & ~eRestyle_LaterSiblings);
   } else {