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 606975 a0e51834bd9ad024d0179179faaa4273c4c443b9
parent 605408 8699a19d2b5e20c31157e6bbc79f4cd6ed390988
child 606976 a3080512e7a6a2c00a7e3c1415e98f8fea064254
push id93006
push userjyavenard@mozilla.com
push dateThu, 15 Oct 2015 05:15:33 +0000
treeherdertry@45ea2a01301e [default view] [failures only]
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