Bug 1337313 - Part 2: Add AnimationValue::SerializeSpecifiedValue.
Move the implementation of uncomputing to string into AnimationValue,
and add one more FFI for RawServoAnimationValue.
MozReview-Commit-ID: JFnXnGO3mlp
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -1009,22 +1009,18 @@ KeyframeEffectReadOnly::GetTargetStyleCo
#ifdef DEBUG
void
DumpAnimationProperties(nsTArray<AnimationProperty>& aAnimationProperties)
{
for (auto& p : aAnimationProperties) {
printf("%s\n", nsCSSProps::GetStringValue(p.mProperty).get());
for (auto& s : p.mSegments) {
nsString fromValue, toValue;
- Unused << StyleAnimationValue::UncomputeValue(p.mProperty,
- s.mFromValue.mGecko,
- fromValue);
- Unused << StyleAnimationValue::UncomputeValue(p.mProperty,
- s.mToValue.mGecko,
- toValue);
+ s.mFromValue.SerializeSpecifiedValue(p.mProperty, fromValue);
+ s.mToValue.SerializeSpecifiedValue(p.mProperty, toValue);
printf(" %f..%f: %s..%s\n", s.mFromKey, s.mToKey,
NS_ConvertUTF16toUTF8(fromValue).get(),
NS_ConvertUTF16toUTF8(toValue).get());
}
}
}
#endif
@@ -1083,19 +1079,17 @@ CreatePropertyValue(nsCSSPropertyID aPro
const AnimationValue& aValue,
dom::CompositeOperation aComposite,
AnimationPropertyValueDetails& aResult)
{
aResult.mOffset = aOffset;
if (!aValue.IsNull()) {
nsString stringValue;
- DebugOnly<bool> uncomputeResult =
- StyleAnimationValue::UncomputeValue(aProperty, aValue.mGecko, stringValue);
- MOZ_ASSERT(uncomputeResult, "failed to uncompute value");
+ aValue.SerializeSpecifiedValue(aProperty, stringValue);
aResult.mValue.Construct(stringValue);
}
if (aTimingFunction) {
aResult.mEasing.Construct();
aTimingFunction->AppendToString(aResult.mEasing.Value());
} else {
aResult.mEasing.Construct(NS_LITERAL_STRING("linear"));
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -122,16 +122,20 @@ SERVO_BINDING_FUNC(Servo_AnimationValues
SERVO_BINDING_FUNC(Servo_AnimationValues_Interpolate,
RawServoAnimationValueStrong,
RawServoAnimationValueBorrowed from,
RawServoAnimationValueBorrowed to,
double progress)
SERVO_BINDING_FUNC(Servo_AnimationValues_Uncompute,
RawServoDeclarationBlockStrong,
RawServoAnimationValueBorrowedListBorrowed value)
+SERVO_BINDING_FUNC(Servo_AnimationValue_Serialize, void,
+ RawServoAnimationValueBorrowed value,
+ nsCSSPropertyID property,
+ nsAString* buffer)
SERVO_BINDING_FUNC(Servo_AnimationValues_GetOpacity, float,
RawServoAnimationValueBorrowed value)
SERVO_BINDING_FUNC(Servo_AnimationValues_GetTransform, void,
RawServoAnimationValueBorrowed value,
RefPtr<nsCSSValueSharedList>* list)
// Style attribute
SERVO_BINDING_FUNC(Servo_ParseStyleAttribute, RawServoDeclarationBlockStrong,
--- a/layout/style/StyleAnimationValue.h
+++ b/layout/style/StyleAnimationValue.h
@@ -584,38 +584,55 @@ private:
}
};
struct AnimationValue
{
StyleAnimationValue mGecko;
RefPtr<RawServoAnimationValue> mServo;
- bool operator==(const AnimationValue& aOther) const {
+ bool operator==(const AnimationValue& aOther) const
+ {
// FIXME: Bug 1337229: add a deep == impl for RawServoAnimationValue.
return mGecko == aOther.mGecko && mServo == aOther.mServo;
}
bool IsNull() const { return mGecko.IsNull() && !mServo; }
- float GetOpacity() const {
+ float GetOpacity() const
+ {
return mServo ? Servo_AnimationValues_GetOpacity(mServo)
: mGecko.GetFloatValue();
}
// Returns the scale for mGecko or mServo, which are calculated with
// reference to aFrame.
- gfxSize GetScaleValue(const nsIFrame* aFrame) const {
+ gfxSize GetScaleValue(const nsIFrame* aFrame) const
+ {
if (mServo) {
RefPtr<nsCSSValueSharedList> list;
Servo_AnimationValues_GetTransform(mServo, &list);
return nsStyleTransformMatrix::GetScaleValue(list, aFrame);
}
return mGecko.GetScaleValue(aFrame);
}
+
+ // Uncompute this AnimationValue and then serialize it.
+ void SerializeSpecifiedValue(nsCSSPropertyID aProperty,
+ nsAString& aString) const
+ {
+ if (mServo) {
+ Servo_AnimationValue_Serialize(mServo, aProperty, &aString);
+ return;
+ }
+
+ DebugOnly<bool> uncomputeResult =
+ StyleAnimationValue::UncomputeValue(aProperty, mGecko, aString);
+ MOZ_ASSERT(uncomputeResult, "failed to uncompute StyleAnimationValue");
+ }
};
struct PropertyStyleAnimationValuePair
{
nsCSSPropertyID mProperty;
AnimationValue mValue;
};
} // namespace mozilla