Bug 1317178 - Pass the property name to Servo_DeclarationBlock_SerializeOneValue.
In order to use single_value_to_css() in
Servo_DeclarationBlock_SerializeOneValue(), we need to pass the property name
and a flag for custom properties.
MozReview-Commit-ID: 5HfI2qOmPwP
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -910,36 +910,37 @@ KeyframeEffectReadOnly::GetKeyframes(JSC
JS::Rooted<JS::Value> keyframeJSValue(aCx);
if (!ToJSValue(aCx, keyframeDict, &keyframeJSValue)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
JS::Rooted<JSObject*> keyframeObject(aCx, &keyframeJSValue.toObject());
for (const PropertyValuePair& propertyValue : keyframe.mPropertyValues) {
-
- const char* name = nsCSSProps::PropertyIDLName(propertyValue.mProperty);
-
- // nsCSSValue::AppendToString does not accept shorthands properties but
- // works with token stream values if we pass eCSSProperty_UNKNOWN as
- // the property.
- nsCSSPropertyID propertyForSerializing =
- nsCSSProps::IsShorthand(propertyValue.mProperty)
- ? eCSSProperty_UNKNOWN
- : propertyValue.mProperty;
-
nsAutoString stringValue;
if (propertyValue.mServoDeclarationBlock) {
+ // FIXME: When we support animations for custom properties on servo, we
+ // should pass the flag to Servo_DeclarationBlock_SerializeOneValue.
+ // Now, we pass false to simplify it.
+ nsIAtom* atom = nsCSSProps::AtomForProperty(propertyValue.mProperty);
Servo_DeclarationBlock_SerializeOneValue(
- propertyValue.mServoDeclarationBlock, &stringValue);
+ propertyValue.mServoDeclarationBlock, atom, false, &stringValue);
} else {
+ // nsCSSValue::AppendToString does not accept shorthands properties but
+ // works with token stream values if we pass eCSSProperty_UNKNOWN as
+ // the property.
+ nsCSSPropertyID propertyForSerializing =
+ nsCSSProps::IsShorthand(propertyValue.mProperty)
+ ? eCSSProperty_UNKNOWN
+ : propertyValue.mProperty;
propertyValue.mValue.AppendToString(
propertyForSerializing, stringValue, nsCSSValue::eNormalized);
}
+ const char* name = nsCSSProps::PropertyIDLName(propertyValue.mProperty);
JS::Rooted<JS::Value> value(aCx);
if (!ToJSValue(aCx, stringValue, &value) ||
!JS_DefineProperty(aCx, keyframeObject, name, value,
JSPROP_ENUMERATE)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
}
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -103,17 +103,17 @@ SERVO_BINDING_FUNC(Servo_DeclarationBloc
SERVO_BINDING_FUNC(Servo_DeclarationBlock_Equals, bool,
RawServoDeclarationBlockBorrowed a,
RawServoDeclarationBlockBorrowed b)
SERVO_BINDING_FUNC(Servo_DeclarationBlock_GetCssText, void,
RawServoDeclarationBlockBorrowed declarations,
nsAString* result)
SERVO_BINDING_FUNC(Servo_DeclarationBlock_SerializeOneValue, void,
RawServoDeclarationBlockBorrowed declarations,
- nsString* buffer)
+ const nsIAtom* property, bool is_custom, nsString* buffer)
SERVO_BINDING_FUNC(Servo_DeclarationBlock_Count, uint32_t,
RawServoDeclarationBlockBorrowed declarations)
SERVO_BINDING_FUNC(Servo_DeclarationBlock_GetNthProperty, bool,
RawServoDeclarationBlockBorrowed declarations,
uint32_t index, nsAString* result)
SERVO_BINDING_FUNC(Servo_DeclarationBlock_GetPropertyValue, void,
RawServoDeclarationBlockBorrowed declarations,
nsIAtom* property, bool is_custom, nsAString* value)