Bug 1339591 - Rearrange construction order of RAII objects in SMIL code. r=mccr8, a=jcristau
authorBrian Birtles <birtles@gmail.com>
Thu, 16 Feb 2017 15:36:04 +0900
changeset 369388 758af211353cb6c1d034b66eee910fc5bfa6531d
parent 369387 6aa6b1d56e32d15a33134ba874c9df82ea7d9b8a
child 369389 4ae8b06d0576da03a6474df328a86765b1f793de
push id1369
push userjlorenzo@mozilla.com
push dateMon, 27 Feb 2017 14:59:41 +0000
treeherdermozilla-release@d75a1dba431f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8, jcristau
bugs1339591
milestone52.0
Bug 1339591 - Rearrange construction order of RAII objects in SMIL code. r=mccr8, a=jcristau MozReview-Commit-ID: FXFF0Phvgjj
dom/smil/nsSMILAnimationController.cpp
dom/smil/nsSMILInstanceTime.cpp
--- a/dom/smil/nsSMILAnimationController.cpp
+++ b/dom/smil/nsSMILAnimationController.cpp
@@ -316,16 +316,18 @@ nsSMILAnimationController::DoSample(bool
   }
   if (mRunningSample) {
     NS_ERROR("Shouldn't be recursively sampling");
     return;
   }
 
   bool isStyleFlushNeeded = mResampleNeeded;
   mResampleNeeded = false;
+  nsCOMPtr<nsIDocument> document(mDocument);  // keeps 'this' alive too
+
   // Set running sample flag -- do this before flushing styles so that when we
   // flush styles we don't end up requesting extra samples
   AutoRestore<bool> autoRestoreRunningSample(mRunningSample);
   mRunningSample = true;
 
   // STEP 1: Bring model up to date
   // (i)  Rewind elements where necessary
   // (ii) Run milestone samples
@@ -419,17 +421,16 @@ nsSMILAnimationController::DoSample(bool
   }
 
   // return early if there are no active animations to avoid a style flush
   if (currentCompositorTable->Count() == 0) {
     mLastCompositorTable = nullptr;
     return;
   }
 
-  nsCOMPtr<nsIDocument> document(mDocument);  // keeps 'this' alive too
   if (isStyleFlushNeeded) {
     document->FlushPendingNotifications(Flush_Style);
   }
 
   // WARNING:
   // WARNING: the above flush may have destroyed the pres shell and/or
   // WARNING: frames and other layout related objects.
   // WARNING:
--- a/dom/smil/nsSMILInstanceTime.cpp
+++ b/dom/smil/nsSMILInstanceTime.cpp
@@ -85,20 +85,20 @@ nsSMILInstanceTime::HandleChangedInterva
     // Break the cycle here
     Unlink();
     return;
   }
 
   bool objectChanged = mCreator->DependsOnBegin() ? aBeginObjectChanged :
                                                       aEndObjectChanged;
 
+  RefPtr<nsSMILInstanceTime> deathGrip(this);
   mozilla::AutoRestore<bool> setVisited(mVisited);
   mVisited = true;
 
-  RefPtr<nsSMILInstanceTime> deathGrip(this);
   mCreator->HandleChangedInstanceTime(*GetBaseTime(), aSrcContainer, *this,
                                       objectChanged);
 }
 
 void
 nsSMILInstanceTime::HandleDeletedInterval()
 {
   MOZ_ASSERT(mBaseInterval,