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
--- 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);