Bug 1317178 - Pass the property name to Servo_DeclarationBlock_SerializeOneValue. r=birtles
authorBoris Chiou <boris.chiou@gmail.com>
Tue, 22 Nov 2016 19:18:18 +0800
changeset 324053 085baebf9e4aebb4e57d5088df9152c490232806
parent 324052 65643222e76c6dfa3560d3d4165d603495ea25e7
child 324054 120c84ca53629202c22cce565053fee7973eea72
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersbirtles
bugs1317178
milestone53.0a1
Bug 1317178 - Pass the property name to Servo_DeclarationBlock_SerializeOneValue. r=birtles 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)