Bug 1339591 - Rearrange construction order of RAII objects in SMIL code; r=mccr8 a=gchang
authorBrian Birtles <birtles@gmail.com>
Thu, 16 Feb 2017 15:36:04 +0900
changeset 376256 e2244b7749692299ee9977b17fddf9adf17d38e6
parent 376255 03268e651db85ff3e6f00ce2e222a8b388a79243
child 376257 2af97db52557c07ca1dc692bb5406ccafbb704e5
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8, gchang
bugs1339591
milestone53.0a2
Bug 1339591 - Rearrange construction order of RAII objects in SMIL code; r=mccr8 a=gchang MozReview-Commit-ID: FXFF0Phvgjj
dom/smil/nsSMILAnimationController.cpp
dom/smil/nsSMILInstanceTime.cpp
--- a/dom/smil/nsSMILAnimationController.cpp
+++ b/dom/smil/nsSMILAnimationController.cpp
@@ -322,16 +322,18 @@ nsSMILAnimationController::DoSample(bool
   bool isStyleFlushNeeded = mResampleNeeded;
   mResampleNeeded = false;
 
   if (mDocument->IsStyledByServo()) {
     NS_ERROR("stylo: SMIL animations not supported yet");
     return;
   }
 
+  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
@@ -425,17 +427,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(FlushType::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,