Bug 1340958 - Allocate StyleRule only if we need to compose styles. r?birtles
MozReview-Commit-ID: 6ucsxBAaYRp
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -435,17 +435,17 @@ KeyframeEffectReadOnly::ResolveBaseStyle
StyleAnimationValue
KeyframeEffectReadOnly::GetUnderlyingStyle(
nsCSSPropertyID aProperty,
const RefPtr<AnimValuesStyleRule>& aAnimationRule)
{
StyleAnimationValue result;
- if (aAnimationRule->HasValue(aProperty)) {
+ if (aAnimationRule && aAnimationRule->HasValue(aProperty)) {
// If we have already composed style for the property, we use the style
// as the underlying style.
DebugOnly<bool> success = aAnimationRule->GetValue(aProperty, result);
MOZ_ASSERT(success, "AnimValuesStyleRule::GetValue should not fail");
} else {
// If we are composing with composite operation that is not 'replace'
// and we have not composed style for the property yet, we have to get
// the base style for the property.
@@ -618,33 +618,33 @@ KeyframeEffectReadOnly::ComposeStyle(
} else if (valuePosition < 0.5) {
aStyleRule.mServo->AddValue(prop.mProperty, servoFromValue);
} else {
aStyleRule.mServo->AddValue(prop.mProperty, servoToValue);
}
} else {
// Gecko backend
- if (!aStyleRule.mGecko) {
- // Allocate the style rule now that we know we have animation data.
- aStyleRule.mGecko = new AnimValuesStyleRule();
- }
-
StyleAnimationValue fromValue =
CompositeValue(prop.mProperty, aStyleRule.mGecko,
segment->mFromValue.mGecko,
segment->mFromComposite);
StyleAnimationValue toValue =
CompositeValue(prop.mProperty, aStyleRule.mGecko,
segment->mToValue.mGecko,
segment->mToComposite);
if (fromValue.IsNull() || toValue.IsNull()) {
continue;
}
+ if (!aStyleRule.mGecko) {
+ // Allocate the style rule now that we know we have animation data.
+ aStyleRule.mGecko = new AnimValuesStyleRule();
+ }
+
// Iteration composition for accumulate
if (mEffectOptions.mIterationComposite ==
IterationCompositeOperation::Accumulate &&
computedTiming.mCurrentIteration > 0) {
const AnimationPropertySegment& lastSegment =
prop.mSegments.LastElement();
// FIXME: Bug 1293492: Add a utility function to calculate both of
// below StyleAnimationValues.