diff --git a/layout/style/StyleAnimationValue.cpp b/layout/style/StyleAnimationValue.cpp index 7984b5d7b0b2..5ce8d95bdb3f 100644 --- a/layout/style/StyleAnimationValue.cpp +++ b/layout/style/StyleAnimationValue.cpp @@ -5295,3 +5295,31 @@ AnimationValue::IsInterpolableWith(nsCSSPropertyID aProperty, return StyleAnimationValue::Interpolate( aProperty, mGecko, aToValue.mGecko, 0.5, dummy); } + +double +AnimationValue::ComputeDistance(nsCSSPropertyID aProperty, + const AnimationValue& aOther, + nsStyleContext* aStyleContext) const +{ + if (IsNull() || aOther.IsNull()) { + return 0.0; + } + + MOZ_ASSERT(!mServo != mGecko.IsNull()); + MOZ_ASSERT(mGecko.IsNull() == aOther.mGecko.IsNull() && + !mServo == !aOther.mServo, + "Animation values should have the same style engine"); + + if (mServo) { + return Servo_AnimationValues_ComputeDistance(mServo, aOther.mServo); + } + + double distance = 0.0; + return StyleAnimationValue::ComputeDistance(aProperty, + mGecko, + aOther.mGecko, + aStyleContext, + distance) + ? distance + : 0.0; +} diff --git a/layout/style/StyleAnimationValue.h b/layout/style/StyleAnimationValue.h index 6be78462cc25..9729b26257c9 100644 --- a/layout/style/StyleAnimationValue.h +++ b/layout/style/StyleAnimationValue.h @@ -602,6 +602,13 @@ struct AnimationValue // Check if |*this| and |aToValue| can be interpolated. bool IsInterpolableWith(nsCSSPropertyID aProperty, const AnimationValue& aToValue) const; + + // Compute the distance between *this and aOther. + // If |aStyleContext| is nullptr, we will return 0.0 if we have mismatched + // transform lists. + double ComputeDistance(nsCSSPropertyID aProperty, + const AnimationValue& aOther, + nsStyleContext* aStyleContext) const; }; struct PropertyStyleAnimationValuePair