Bug 1340005 - Part 2: Implement AnimationValue::Transform. r=birtles
authorBoris Chiou <boris.chiou@gmail.com>
Fri, 27 Oct 2017 21:06:30 +0200
changeset 688115 143169e5a42dac7c6a2a24b68494886b44ec748c
parent 688114 86ef7d8d75e43fa1da734e462573466ed2643e98
child 688116 b43c82ffe651880e52322b7dcdc50cc0752baeb6
push id86669
push userhikezoe@mozilla.com
push dateSat, 28 Oct 2017 10:13:18 +0000
reviewersbirtles
bugs1340005
milestone58.0a1
Bug 1340005 - Part 2: Implement AnimationValue::Transform. r=birtles 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
@@ -634,16 +634,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;