Bug 1317178 - Pass the property name to Servo_DeclarationBlock_SerializeOneValue. draft
authorBoris Chiou <boris.chiou@gmail.com>
Tue, 22 Nov 2016 19:18:18 +0800
changeset 443268 4b80cf00f959d8b6eb28931a06933ad27980f55b
parent 443267 7af1697ce7487b12d20203d610b1ccd25099c87f
child 443269 c14d7c8536a08297b84dc33443ee4e305af5c9eb
push id36944
push userbmo:boris.chiou@gmail.com
push dateThu, 24 Nov 2016 05:19:37 +0000
bugs1317178
milestone53.0a1
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
dom/animation/KeyframeEffectReadOnly.cpp
layout/style/ServoBindingList.h
--- 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)