Bug 1340958 - Do not call EffectCompositor::GetServoAnimationRule for print preview. r?heycam draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Fri, 17 Mar 2017 12:48:34 +0900
changeset 500408 132125b8f31b51ddb90188b7af686d92f29ebc7c
parent 500407 d3d7ce08e7bf75dea902d5ca31d61a2a42d7b6d5
child 500409 9fbdebbd6b645a5d9a5e11e6111d59704e74c8ad
push id49724
push userhikezoe@mozilla.com
push dateFri, 17 Mar 2017 06:26:10 +0000
reviewersheycam
bugs1340958
milestone55.0a1
Bug 1340958 - Do not call EffectCompositor::GetServoAnimationRule for print preview. r?heycam The only one caller of GetServoAnimationRule is Gecko_GetAnimationRule. There is no risk that pres context is destroyed in Gecko_GetAnimationRule. MozReview-Commit-ID: 52pxbCiCNoJ
dom/animation/EffectCompositor.cpp
layout/style/ServoBindings.cpp
--- a/dom/animation/EffectCompositor.cpp
+++ b/dom/animation/EffectCompositor.cpp
@@ -477,20 +477,18 @@ namespace {
   };
 }
 
 ServoAnimationRule*
 EffectCompositor::GetServoAnimationRule(const dom::Element* aElement,
                                         CSSPseudoElementType aPseudoType,
                                         CascadeLevel aCascadeLevel)
 {
-  if (!mPresContext || !mPresContext->IsDynamic()) {
-    // For print or print preview, ignore animations.
-    return nullptr;
-  }
+  MOZ_ASSERT(mPresContext && mPresContext->IsDynamic(),
+             "Should not be in print preview");
 
   EffectSet* effectSet = EffectSet::GetEffectSet(aElement, aPseudoType);
   if (!effectSet) {
     return nullptr;
   }
 
   // Get a list of effects sorted by composite order.
   nsTArray<KeyframeEffectReadOnly*> sortedEffectList(effectSet->Count());
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -399,17 +399,18 @@ Gecko_GetAnimationRule(RawGeckoElementBo
              aPseudoTag == nsCSSPseudoElements::after);
 
   const RawServoDeclarationBlockStrong emptyDeclarationBlock{ nullptr };
   nsIDocument* doc = aElement->GetComposedDoc();
   if (!doc || !doc->GetShell()) {
     return emptyDeclarationBlock;
   }
   nsPresContext* presContext = doc->GetShell()->GetPresContext();
-  if (!presContext) {
+  if (!presContext || !presContext->IsDynamic()) {
+    // For print or print preview, ignore animations.
     return emptyDeclarationBlock;
   }
 
   CSSPseudoElementType pseudoType =
     nsCSSPseudoElements::GetPseudoType(
       aPseudoTag,
       nsCSSProps::EnabledState::eIgnoreEnabledState);