Bug 1115812 patch 12 - Null-check the root frame in StartRebuildAllStyleData. r=heycam
authorL. David Baron <dbaron@dbaron.org>
Tue, 13 Jan 2015 21:03:12 -0800
changeset 223713 dee1be6469184a7236b542ba677cccb7142a1611
parent 223712 fa9e8fe352a17e023f4dd0f272bda98967763882
child 223714 b939cbd6e0e17591be57a4ab6a6d98bed3db0735
push id10811
push usercbook@mozilla.com
push dateWed, 14 Jan 2015 13:52:17 +0000
treeherderfx-team@b8d38d19dbd9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1115812
milestone38.0a1
Bug 1115812 patch 12 - Null-check the root frame in StartRebuildAllStyleData. r=heycam In the new way of doing a rebuild-all, StartRebuildAllStyleData might be called directly from ProcessPendingRestyles rather than from RebuildAllStyleData (which null-checks the root frame) or from within processing restyles (which can only happen when there's a root frame). This means it needs its own null-check of the root frame.
layout/base/RestyleManager.cpp
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -1528,16 +1528,22 @@ RestyleManager::RebuildAllStyleData(nsCh
   ProcessPendingRestyles();
 }
 
 void
 RestyleManager::StartRebuildAllStyleData(RestyleTracker& aRestyleTracker)
 {
   MOZ_ASSERT(mIsProcessingRestyles);
 
+  nsIFrame* rootFrame = mPresContext->PresShell()->GetRootFrame();
+  if (!rootFrame) {
+    // No need to do anything.
+    return;
+  }
+
   mInRebuildAllStyleData = true;
 
   // 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)) {
     MOZ_CRASH("unable to rebuild style data");
   }
@@ -1575,17 +1581,17 @@ RestyleManager::StartRebuildAllStyleData
   // Recalculate all of the style contexts for the document, from the
   // root frame.  We can't do this with a change hint, since we can't
   // post a change hint for the root frame.
   // Note that we can ignore the return value of ComputeStyleChangeFor
   // because we never need to reframe the root frame.
   // XXX Does it matter that we're passing aExtraHint to the real root
   // frame and not the root node's primary frame?  (We could do
   // roughly what we do for aRestyleHint above.)
-  ComputeAndProcessStyleChange(mPresContext->PresShell()->GetRootFrame(),
+  ComputeAndProcessStyleChange(rootFrame,
                                changeHint, aRestyleTracker, restyleHint);
 }
 
 void
 RestyleManager::DoRebuildAllStyleData(RestyleTracker& aRestyleTracker)
 {
   BeginProcessingRestyles(aRestyleTracker);
   EndProcessingRestyles();