Bug 1355349 - Use Servo's zero values to fill in missing SMIL animation endpoints; r?hiro
MozReview-Commit-ID: 3WLDIlfnJcD
--- a/dom/smil/nsSMILCSSValueType.cpp
+++ b/dom/smil/nsSMILCSSValueType.cpp
@@ -77,39 +77,51 @@ GetZeroValueForUnit(StyleAnimationValue:
//
// If one argument is null, this method updates it to point to "zero"
// for the other argument's Unit (if applicable; otherwise, we return false).
//
// If neither argument is null, this method generally does nothing, though it
// may apply a workaround for the special case where a 0 length-value is mixed
// with a eUnit_Float value. (See comment below.)
//
+// |aZeroValueStorage| should be a null AnimationValue. This is used for the
+// Servo backend where we may need to allocate a new ServoAnimationValue to
+// represent the appropriate zero value.
+//
// Returns true on success, or false.
static bool
FinalizeStyleAnimationValues(const AnimationValue*& aValue1,
- const AnimationValue*& aValue2)
+ const AnimationValue*& aValue2,
+ AnimationValue& aZeroValueStorage)
{
MOZ_ASSERT(aValue1 || aValue2,
"expecting at least one non-null value");
MOZ_ASSERT(!aValue1 || !aValue2 || !aValue1->mServo == !aValue2->mServo,
"If both values are specified, they should be for the same"
" style system");
+ MOZ_ASSERT(aZeroValueStorage.IsNull(),
+ "Zero storage should be empty");
bool isServo = aValue1 ? aValue1->mServo : aValue2->mServo;
+ // Are we missing either val? (If so, it's an implied 0 in other val's units)
+
if (isServo) {
- // Bug 1355349: Implement additive animation for Stylo
- if (!aValue1 || !aValue2) {
- NS_WARNING("stylo: Missing values are not yet supported (bug 1355349)");
- return false;
+ if (!aValue1) {
+ aZeroValueStorage.mServo =
+ Servo_AnimationValues_GetZeroValue(aValue2->mServo).Consume();
+ aValue1 = &aZeroValueStorage;
+ } else if (!aValue2) {
+ aZeroValueStorage.mServo =
+ Servo_AnimationValues_GetZeroValue(aValue1->mServo).Consume();
+ aValue2 = &aZeroValueStorage;
}
- return true;
+ return aValue1->mServo && aValue2->mServo;
}
- // Are we missing either val? (If so, it's an implied 0 in other val's units)
if (!aValue1) {
aValue1 = GetZeroValueForUnit(aValue2->mGecko.GetUnit());
return !!aValue1; // Fail if we have no zero value for this unit.
}
if (!aValue2) {
aValue2 = GetZeroValueForUnit(aValue1->mGecko.GetUnit());
return !!aValue2; // Fail if we have no zero value for this unit.
}
@@ -258,17 +270,19 @@ nsSMILCSSValueType::Add(nsSMILValue& aDe
}
const AnimationValue* valueToAdd = valueToAddWrapper
? &valueToAddWrapper->mCSSValue
: nullptr;
const AnimationValue* destValue = destWrapper
? &destWrapper->mCSSValue
: nullptr;
- if (!FinalizeStyleAnimationValues(valueToAdd, destValue)) {
+ AnimationValue zeroValueStorage;
+ if (!FinalizeStyleAnimationValues(valueToAdd, destValue,
+ zeroValueStorage)) {
return NS_ERROR_FAILURE;
}
// Did FinalizeStyleAnimationValues change destValue?
// If so, update outparam to use the new value.
if (destWrapper && &destWrapper->mCSSValue != destValue) {
destWrapper->mCSSValue = *destValue;
}
@@ -302,17 +316,19 @@ nsSMILCSSValueType::ComputeDistance(cons
const ValueWrapper* fromWrapper = ExtractValueWrapper(aFrom);
const ValueWrapper* toWrapper = ExtractValueWrapper(aTo);
MOZ_ASSERT(toWrapper, "expecting non-null endpoint");
const AnimationValue* fromCSSValue = fromWrapper
? &fromWrapper->mCSSValue
: nullptr;
const AnimationValue* toCSSValue = &toWrapper->mCSSValue;
- if (!FinalizeStyleAnimationValues(fromCSSValue, toCSSValue)) {
+ AnimationValue zeroValueStorage;
+ if (!FinalizeStyleAnimationValues(fromCSSValue, toCSSValue,
+ zeroValueStorage)) {
return NS_ERROR_FAILURE;
}
if (toCSSValue->mServo) {
aDistance = Servo_AnimationValues_ComputeDistance(fromCSSValue->mServo,
toCSSValue->mServo);
return NS_OK;
}
@@ -344,17 +360,19 @@ nsSMILCSSValueType::Interpolate(const ns
const ValueWrapper* startWrapper = ExtractValueWrapper(aStartVal);
const ValueWrapper* endWrapper = ExtractValueWrapper(aEndVal);
MOZ_ASSERT(endWrapper, "expecting non-null endpoint");
const AnimationValue* startCSSValue = startWrapper
? &startWrapper->mCSSValue
: nullptr;
const AnimationValue* endCSSValue = &endWrapper->mCSSValue;
- if (!FinalizeStyleAnimationValues(startCSSValue, endCSSValue)) {
+ AnimationValue zeroValueStorage;
+ if (!FinalizeStyleAnimationValues(startCSSValue, endCSSValue,
+ zeroValueStorage)) {
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(!startCSSValue ||
!startCSSValue->mServo == !endCSSValue->mServo,
"Start and end values should use the same style system");
if (endCSSValue->mServo) {
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -232,16 +232,19 @@ SERVO_BINDING_FUNC(Servo_GetProperties_O
SERVO_BINDING_FUNC(Servo_AnimationValues_Interpolate,
RawServoAnimationValueStrong,
RawServoAnimationValueBorrowed from,
RawServoAnimationValueBorrowed to,
double progress)
SERVO_BINDING_FUNC(Servo_AnimationValues_IsInterpolable, bool,
RawServoAnimationValueBorrowed from,
RawServoAnimationValueBorrowed to)
+SERVO_BINDING_FUNC(Servo_AnimationValues_GetZeroValue,
+ RawServoAnimationValueStrong,
+ RawServoAnimationValueBorrowed value_to_match)
SERVO_BINDING_FUNC(Servo_AnimationValues_ComputeDistance, double,
RawServoAnimationValueBorrowed from,
RawServoAnimationValueBorrowed to)
SERVO_BINDING_FUNC(Servo_AnimationValue_Serialize, void,
RawServoAnimationValueBorrowed value,
nsCSSPropertyID property,
nsAString* buffer)
SERVO_BINDING_FUNC(Servo_AnimationValue_GetOpacity, float,