Bug 1311257 - getKeyframes() returns base computed values in missing keyframes. r?birtles
MozReview-Commit-ID: K8btLtALEfK
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -1243,16 +1243,18 @@ KeyframeEffectReadOnly::GetKeyframes(JSC
MOZ_ASSERT(aResult.IsEmpty());
MOZ_ASSERT(!aRv.Failed());
if (!aResult.SetCapacity(mKeyframes.Length(), mozilla::fallible)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
+ bool isServo = mDocument->IsStyledByServo();
+
for (const Keyframe& keyframe : mKeyframes) {
// Set up a dictionary object for the explicit members
BaseComputedKeyframe keyframeDict;
if (keyframe.mOffset) {
keyframeDict.mOffset.SetValue(keyframe.mOffset.value());
}
MOZ_ASSERT(keyframe.mComputedOffset != Keyframe::kComputedOffsetNotSet,
"Invalid computed offset");
@@ -1270,20 +1272,31 @@ KeyframeEffectReadOnly::GetKeyframes(JSC
if (!ToJSValue(aCx, keyframeDict, &keyframeJSValue)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
JS::Rooted<JSObject*> keyframeObject(aCx, &keyframeJSValue.toObject());
for (const PropertyValuePair& propertyValue : keyframe.mPropertyValues) {
nsAutoString stringValue;
- if (propertyValue.mServoDeclarationBlock) {
- Servo_DeclarationBlock_SerializeOneValue(
- propertyValue.mServoDeclarationBlock,
- propertyValue.mProperty, &stringValue);
+ if (isServo) {
+ if (propertyValue.mServoDeclarationBlock) {
+ Servo_DeclarationBlock_SerializeOneValue(
+ propertyValue.mServoDeclarationBlock,
+ propertyValue.mProperty, &stringValue);
+ } else {
+ RawServoAnimationValue* value =
+ mBaseStyleValuesForServo.GetWeak(propertyValue.mProperty);
+
+ if (value) {
+ Servo_AnimationValue_Serialize(value,
+ propertyValue.mProperty,
+ &stringValue);
+ }
+ }
} else if (nsCSSProps::IsShorthand(propertyValue.mProperty)) {
// nsCSSValue::AppendToString does not accept shorthands properties but
// works with token stream values if we pass eCSSProperty_UNKNOWN as
// the property.
propertyValue.mValue.AppendToString(
eCSSProperty_UNKNOWN, stringValue, nsCSSValue::eNormalized);
} else {
nsCSSValue cssValue = propertyValue.mValue;