Bug 1346052 - Part 2: Implement AnimationValue::ComputeDistance. r=birtles

We will use this API to compute the distance between two AnimationValues
in the patch series.

MozReview-Commit-ID: 2Tw9xumuz45

--HG--
extra : rebase_source : 298baaf597a81e03191a0468f9d7509e092a5e78
This commit is contained in:
Boris Chiou 2017-04-26 20:05:04 +08:00
Родитель c78d90ed63
Коммит b3ceb979ce
2 изменённых файлов: 35 добавлений и 0 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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