Bug 1340005 - Part 2: Implement AnimationValue::Transform. draft
authorBoris Chiou <boris.chiou@gmail.com>
Fri, 27 Oct 2017 21:06:30 +0200
changeset 687787 42f358b6e5fadd7fea06234383050cb62a4f7fac
parent 687786 dde4ce8a76d43ce3de85154eb3956e4590870537
child 687788 26c8e2d8e61eaa5b486c992c525bc63389424804
push id86604
push userbmo:boris.chiou@gmail.com
push dateFri, 27 Oct 2017 19:27:11 +0000
bugs1340005
milestone58.0a1
Bug 1340005 - Part 2: Implement AnimationValue::Transform. MozReview-Commit-ID: BDKcpDIM9nb
gfx/layers/AnimationHelper.cpp
layout/style/ServoBindingList.h
layout/style/StyleAnimationValue.cpp
layout/style/StyleAnimationValue.h
--- a/gfx/layers/AnimationHelper.cpp
+++ b/gfx/layers/AnimationHelper.cpp
@@ -469,17 +469,19 @@ ToAnimationValue(const Animatable& aAnim
   AnimationValue result;
 
   switch (aAnimatable.type()) {
     case Animatable::Tnull_t:
       break;
     case Animatable::TArrayOfTransformFunction: {
         const InfallibleTArray<TransformFunction>& transforms =
           aAnimatable.get_ArrayOfTransformFunction();
-        result.mGecko.SetTransformValue(CreateCSSValueList(transforms));
+        RefPtr<nsCSSValueSharedList> list(CreateCSSValueList(transforms));
+        MOZ_ASSERT(list, "Transform list should be non null");
+        result = AnimationValue::Transform(StyleBackendType::Gecko, *list);
       }
       break;
     case Animatable::Tfloat:
       result = AnimationValue::Opacity(StyleBackendType::Gecko,
                                        aAnimatable.get_float());
       break;
     default:
       MOZ_ASSERT_UNREACHABLE("Unsupported type");
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -371,16 +371,19 @@ SERVO_BINDING_FUNC(Servo_Shorthand_Anima
 SERVO_BINDING_FUNC(Servo_AnimationValue_GetOpacity, float,
                    RawServoAnimationValueBorrowed value)
 SERVO_BINDING_FUNC(Servo_AnimationValue_Opacity,
                    RawServoAnimationValueStrong,
                    float)
 SERVO_BINDING_FUNC(Servo_AnimationValue_GetTransform, void,
                    RawServoAnimationValueBorrowed value,
                    RefPtr<nsCSSValueSharedList>* list)
+SERVO_BINDING_FUNC(Servo_AnimationValue_Transform,
+                   RawServoAnimationValueStrong,
+                   const nsCSSValueSharedList& list)
 SERVO_BINDING_FUNC(Servo_AnimationValue_DeepEqual, bool,
                    RawServoAnimationValueBorrowed,
                    RawServoAnimationValueBorrowed)
 SERVO_BINDING_FUNC(Servo_AnimationValue_Uncompute,
                    RawServoDeclarationBlockStrong,
                    RawServoAnimationValueBorrowed value)
 SERVO_BINDING_FUNC(Servo_AnimationValue_Compute,
                    RawServoAnimationValueStrong,
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -5506,8 +5506,27 @@ AnimationValue::Opacity(StyleBackendType
     case StyleBackendType::Gecko:
       result.mGecko.SetFloatValue(aOpacity);
       break;
     default:
       MOZ_ASSERT_UNREACHABLE("Unsupported style backend");
   }
   return result;
 }
+
+/* static */ AnimationValue
+AnimationValue::Transform(StyleBackendType aBackendType,
+                          nsCSSValueSharedList& aList)
+{
+  AnimationValue result;
+
+  switch (aBackendType) {
+    case StyleBackendType::Servo:
+      result.mServo = Servo_AnimationValue_Transform(aList).Consume();
+      break;
+    case StyleBackendType::Gecko:
+      result.mGecko.SetTransformValue(&aList);
+      break;
+    default:
+      MOZ_ASSERT_UNREACHABLE("Unsupported style backend");
+  }
+  return result;
+}
--- a/layout/style/StyleAnimationValue.h
+++ b/layout/style/StyleAnimationValue.h
@@ -633,16 +633,19 @@ struct AnimationValue
   // should use this carefully. Now, it is only used by
   // nsDOMWindowUtils::ComputeAnimationDistance.
   static AnimationValue FromString(nsCSSPropertyID aProperty,
                                    const nsAString& aValue,
                                    dom::Element* aElement);
 
   // Create an AnimationValue from an opacity value.
   static AnimationValue Opacity(StyleBackendType aBackendType, float aOpacity);
+  // Create an AnimationValue from a transform list.
+  static AnimationValue Transform(StyleBackendType aBackendType,
+                                  nsCSSValueSharedList& aList);
 
   // mGecko and mServo are mutually exclusive: only one or the other should
   // ever be set.
   // FIXME: After obsoleting StyleAnimationValue, we should remove mGecko, and
   // make AnimationValue a wrapper of RawServoAnimationValue to hide these
   // FFIs.
   StyleAnimationValue mGecko;
   RefPtr<RawServoAnimationValue> mServo;