Bug 1335942 - Part 3: Use AnimationValue as the argument in layers::SetAnimatable. draft
authorBoris Chiou <boris.chiou@gmail.com>
Wed, 08 Feb 2017 11:31:15 +0800
changeset 480416 8e2657dae119190bb5d2d6d85797e86a110dc203
parent 480415 55d1028e26e423423abb39fec75372de796d86be
child 480417 2c3a6a7b035d577e158fe66f60a7ee4a8922d93d
child 480421 009095ecfb5fee0933ac78ccb536df7fb330fd12
push id44527
push userbmo:boris.chiou@gmail.com
push dateWed, 08 Feb 2017 05:25:55 +0000
bugs1335942
milestone54.0a1
Bug 1335942 - Part 3: Use AnimationValue as the argument in layers::SetAnimatable. MozReview-Commit-ID: 4XnLL6I291q
layout/painting/nsDisplayList.cpp
layout/style/ServoBindingList.h
layout/style/StyleAnimationValue.h
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -415,36 +415,38 @@ ToTimingFunction(const Maybe<ComputedTim
   }
 
   uint32_t type = aCTF->GetType() == nsTimingFunction::Type::StepStart ? 1 : 2;
   return TimingFunction(StepFunction(aCTF->GetSteps(), type));
 }
 
 static void
 SetAnimatable(nsCSSPropertyID aProperty,
-              const StyleAnimationValue& aAnimationValue,
+              const AnimationValue& aAnimationValue,
               nsIFrame* aFrame,
               TransformReferenceBox& aRefBox,
               layers::Animatable& aAnimatable)
 {
   MOZ_ASSERT(aFrame);
 
   if (aAnimationValue.IsNull()) {
     aAnimatable = null_t();
     return;
   }
 
   switch (aProperty) {
     case eCSSProperty_opacity:
-      aAnimatable = aAnimationValue.GetFloatValue();
+      aAnimatable = aAnimationValue.GetOpacity();
       break;
     case eCSSProperty_transform: {
       aAnimatable = InfallibleTArray<TransformFunction>();
+      // TODO: Get transform from RawServoAnimationValue.
       nsCSSValueSharedList* list =
-        aAnimationValue.GetCSSValueSharedListValue();
+        aAnimationValue.mGecko.GetCSSValueSharedListValue();
+      MOZ_ASSERT(list, "Invalid transform list");
       AddTransformFunctions(list->mHead,
                             aFrame->StyleContext(),
                             aFrame->PresContext(),
                             aRefBox,
                             aAnimatable.get_ArrayOfTransformFunction());
       break;
     }
     default:
@@ -460,17 +462,19 @@ SetBaseAnimationStyle(nsCSSPropertyID aP
 {
   MOZ_ASSERT(aFrame);
 
   StyleAnimationValue baseValue =
     EffectCompositor::GetBaseStyle(aProperty, aFrame);
   MOZ_ASSERT(!baseValue.IsNull(),
              "The base value should be already there");
 
-  SetAnimatable(aProperty, baseValue, aFrame, aRefBox, aBaseStyle);
+  // FIXME: Bug 1311257: We need to get the baseValue for
+  //        RawServoAnimationValue.
+  SetAnimatable(aProperty, { baseValue, nullptr }, aFrame, aRefBox, aBaseStyle);
 }
 
 static void
 AddAnimationForProperty(nsIFrame* aFrame, const AnimationProperty& aProperty,
                         dom::Animation* aAnimation, Layer* aLayer,
                         AnimationData& aData, bool aPending)
 {
   MOZ_ASSERT(aLayer->AsContainerLayer(), "Should only animate ContainerLayer");
@@ -552,21 +556,21 @@ AddAnimationForProperty(nsIFrame* aFrame
     animation->baseStyle() = null_t();
   }
 
   for (uint32_t segIdx = 0; segIdx < aProperty.mSegments.Length(); segIdx++) {
     const AnimationPropertySegment& segment = aProperty.mSegments[segIdx];
 
     AnimationSegment* animSegment = animation->segments().AppendElement();
     SetAnimatable(aProperty.mProperty,
-                  segment.mFromValue.mGecko,
+                  segment.mFromValue,
                   aFrame, refBox,
                   animSegment->startState());
     SetAnimatable(aProperty.mProperty,
-                  segment.mToValue.mGecko,
+                  segment.mToValue,
                   aFrame, refBox,
                   animSegment->endState());
 
     animSegment->startPortion() = segment.mFromKey;
     animSegment->endPortion() = segment.mToKey;
     animSegment->startComposite() =
       static_cast<uint8_t>(segment.mFromComposite);
     animSegment->endComposite() =
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -122,16 +122,18 @@ SERVO_BINDING_FUNC(Servo_AnimationValues
 SERVO_BINDING_FUNC(Servo_AnimationValues_Interpolate,
                    RawServoAnimationValueStrong,
                    RawServoAnimationValueBorrowed from,
                    RawServoAnimationValueBorrowed to,
                    double progress)
 SERVO_BINDING_FUNC(Servo_AnimationValues_Uncompute,
                    RawServoDeclarationBlockStrong,
                    RawServoAnimationValueBorrowedListBorrowed value)
+SERVO_BINDING_FUNC(Servo_AnimationValues_GetOpacity, float,
+                   RawServoAnimationValueBorrowed value)
 
 // Style attribute
 SERVO_BINDING_FUNC(Servo_ParseStyleAttribute, RawServoDeclarationBlockStrong,
                    const nsACString* data)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_CreateEmpty,
                    RawServoDeclarationBlockStrong)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_Clone, RawServoDeclarationBlockStrong,
                    RawServoDeclarationBlockBorrowed declarations)
--- a/layout/style/StyleAnimationValue.h
+++ b/layout/style/StyleAnimationValue.h
@@ -13,16 +13,17 @@
 #include "mozilla/UniquePtr.h"
 #include "nsStringFwd.h"
 #include "nsStringBuffer.h"
 #include "nsCoord.h"
 #include "nsColor.h"
 #include "nsCSSProps.h"
 #include "nsCSSValue.h"
 #include "nsStyleCoord.h"
+#include "ServoBindings.h"
 
 class nsIFrame;
 class nsStyleContext;
 class gfx3DMatrix;
 struct RawServoDeclarationBlock;
 
 namespace mozilla {
 
@@ -586,16 +587,23 @@ struct AnimationValue
 {
   StyleAnimationValue mGecko;
   RefPtr<RawServoAnimationValue> mServo;
 
   bool operator==(const AnimationValue& aOther) const {
     // FIXME: Bug 1337229: add a deep == impl for RawServoAnimationValue.
     return mGecko == aOther.mGecko && mServo == aOther.mServo;
   }
+
+  bool IsNull() const { return mGecko.IsNull() && !mServo; }
+
+  float GetOpacity() const {
+    return mServo ? Servo_AnimationValues_GetOpacity(mServo)
+                  : mGecko.GetFloatValue();
+  }
 };
 
 struct PropertyStyleAnimationValuePair
 {
   nsCSSPropertyID mProperty;
   AnimationValue mValue;
 };
 } // namespace mozilla