Bug 1211334 - Make sure presshell is still available after dispatching transition events; r=mats, a=lhenry
authorBrian Birtles <birtles@gmail.com>
Wed, 07 Oct 2015 14:55:55 +0900
changeset 296391 a0e51834bd9ad024d0179179faaa4273c4c443b9
parent 296390 8699a19d2b5e20c31157e6bbc79f4cd6ed390988
child 296392 a3080512e7a6a2c00a7e3c1415e98f8fea064254
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats, lhenry
bugs1211334
milestone43.0a2
Bug 1211334 - Make sure presshell is still available after dispatching transition events; r=mats, a=lhenry
layout/base/nsRefreshDriver.cpp
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -1323,30 +1323,33 @@ static bool
 DispatchAnimationEventsOnSubDocuments(nsIDocument* aDocument,
                                       void* aRefreshDriver)
 {
   nsIPresShell* shell = aDocument->GetShell();
   if (!shell) {
     return true;
   }
 
-  nsPresContext* context = shell->GetPresContext();
+  nsRefPtr<nsPresContext> context = shell->GetPresContext();
   if (!context || context->RefreshDriver() != aRefreshDriver) {
     return true;
   }
 
   nsCOMPtr<nsIDocument> kungFuDeathGrip(aDocument);
 
   context->TransitionManager()->SortEvents();
   context->AnimationManager()->SortEvents();
 
   // Dispatch transition events first since transitions conceptually sit
   // below animations in terms of compositing order.
   context->TransitionManager()->DispatchEvents();
-  context->AnimationManager()->DispatchEvents();
+  // Check that the presshell has not been destroyed
+  if (context->GetPresShell()) {
+    context->AnimationManager()->DispatchEvents();
+  }
 
   aDocument->EnumerateSubDocuments(DispatchAnimationEventsOnSubDocuments,
                                    aRefreshDriver);
 
   return true;
 }
 
 void