Bug 1358966 - Compute distance for each sub properties of shorthand. r=birtles

We use Euclidean distance for shorhand.

MozReview-Commit-ID: 6gUbIUl9SZ

--HG--
extra : rebase_source : ef92e2387d9bbb8da51ce3b2c89f0c2cc2d182fe
This commit is contained in:
Hiroyuki Ikezoe 2017-06-09 06:19:37 +09:00
parent d3612df34a
commit aca372df5b

View File

@ -420,15 +420,31 @@ ComputeDistanceForServo(const ValueWrapper* aFromWrapper,
const ValueWrapper& aToWrapper,
double& aDistance)
{
const RefPtr<RawServoAnimationValue>* fromValue =
aFromWrapper ? &aFromWrapper->mServoValues[0] : nullptr;
const RefPtr<RawServoAnimationValue>* toValue = &aToWrapper.mServoValues[0];
RefPtr<RawServoAnimationValue> zeroValueStorage;
if (!FinalizeServoAnimationValues(fromValue, toValue, zeroValueStorage)) {
return NS_ERROR_FAILURE;
size_t len = aToWrapper.mServoValues.Length();
MOZ_ASSERT(!aFromWrapper || aFromWrapper->mServoValues.Length() == len,
"From and to values length should be the same if "
"The start value exists");
double squareDistance = 0;
for (size_t i = 0; i < len; i++) {
const RefPtr<RawServoAnimationValue>* fromValue =
aFromWrapper ? &aFromWrapper->mServoValues[0] : nullptr;
const RefPtr<RawServoAnimationValue>* toValue = &aToWrapper.mServoValues[0];
RefPtr<RawServoAnimationValue> zeroValueStorage;
if (!FinalizeServoAnimationValues(fromValue, toValue, zeroValueStorage)) {
return NS_ERROR_FAILURE;
}
double distance = Servo_AnimationValues_ComputeDistance(*fromValue, *toValue);
if (len == 1) {
aDistance = distance;
return NS_OK;
}
squareDistance += distance * distance;
}
aDistance = Servo_AnimationValues_ComputeDistance(*fromValue, *toValue);
aDistance = sqrt(squareDistance);
return NS_OK;
}