Bug 1067769 - Part 1: Avoid doing RequestRestyle and mutation batch for null target. r=birtles
We don't need to restyle if mTarget is nullptr, so skip it. For
nsAutoAnimationMutationBatch, we also skip it if mTarget is nullptr.
AnimationColletion, nsAnimationManager and nsTransitionManger are for
CSS Animations and CSS Transtions, so the effect should have an effective
target. Therefore, I think we don't have to revise them for
nsAutoAnimationMutationBatch.
MozReview-Commit-ID: Egzr1QVEa0v
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -184,17 +184,17 @@ KeyframeEffectReadOnly::NotifyAnimationT
// Bug 1216843: When we implement iteration composite modes, we need to
// also detect if the current iteration has changed.
if (mAnimation && GetComputedTiming().mProgress != mProgressOnLastCompose) {
EffectCompositor::RestyleType restyleType =
CanThrottle() ?
EffectCompositor::RestyleType::Throttled :
EffectCompositor::RestyleType::Standard;
nsPresContext* presContext = GetPresContext();
- if (presContext) {
+ if (presContext && mTarget) {
presContext->EffectCompositor()->
RequestRestyle(mTarget, mPseudoType, restyleType,
mAnimation->CascadeLevel());
}
// If we're not relevant, we will have been removed from the EffectSet.
// As a result, when the restyle we requested above is fulfilled, our
// ComposeStyle will not get called and mProgressOnLastCompose will not
@@ -558,25 +558,25 @@ KeyframeEffectReadOnly::UpdateProperties
runningOnCompositorProperties.HasProperty(property.mProperty);
}
if (mTarget) {
EffectSet* effectSet = EffectSet::GetEffectSet(mTarget, mPseudoType);
if (effectSet) {
effectSet->MarkCascadeNeedsUpdate();
}
- }
- if (mAnimation) {
- nsPresContext* presContext = GetPresContext();
- if (presContext) {
- presContext->EffectCompositor()->
- RequestRestyle(mTarget, mPseudoType,
- EffectCompositor::RestyleType::Layer,
- mAnimation->CascadeLevel());
+ if (mAnimation) {
+ nsPresContext* presContext = GetPresContext();
+ if (presContext) {
+ presContext->EffectCompositor()->
+ RequestRestyle(mTarget, mPseudoType,
+ EffectCompositor::RestyleType::Layer,
+ mAnimation->CascadeLevel());
+ }
}
}
}
void
KeyframeEffectReadOnly::ComposeStyle(RefPtr<AnimValuesStyleRule>& aStyleRule,
nsCSSPropertySet& aSetProperties)
{
@@ -1354,27 +1354,28 @@ KeyframeEffect::Constructor(
{
return ConstructKeyframeEffect<KeyframeEffect>(aGlobal, aTarget, aFrames,
aOptions, aRv);
}
void KeyframeEffect::NotifySpecifiedTimingUpdated()
{
// Use the same document for a pseudo element and its parent element.
- nsAutoAnimationMutationBatch mb(mTarget->OwnerDoc());
+ // Use nullptr if we don't have mTarget, so disable the mutation batch.
+ nsAutoAnimationMutationBatch mb(mTarget ? mTarget->OwnerDoc() : nullptr);
if (mAnimation) {
mAnimation->NotifyEffectTimingUpdated();
if (mAnimation->IsRelevant()) {
nsNodeUtils::AnimationChanged(mAnimation);
}
nsPresContext* presContext = GetPresContext();
- if (presContext) {
+ if (presContext && mTarget) {
presContext->EffectCompositor()->
RequestRestyle(mTarget, mPseudoType,
EffectCompositor::RestyleType::Layer,
mAnimation->CascadeLevel());
}
}
}