Bug 1311257 - Move stuff of KeyframeEffectReadOnly::ComposeStyleRule in Rust. r?heycam draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Thu, 06 Apr 2017 10:34:51 +0900
changeset 556566 77211d4304ba7e702c12b6b44700265778e1c462
parent 556565 3868ec2d1d3afc2e9d87c8b95da8ec3c05692b19
child 556567 b53a15e99910b212e528f43f086a3f9d98ca9a5e
push id52584
push userhikezoe@mozilla.com
push dateThu, 06 Apr 2017 03:01:12 +0000
reviewersheycam
bugs1311257
milestone55.0a1
Bug 1311257 - Move stuff of KeyframeEffectReadOnly::ComposeStyleRule in Rust. r?heycam After this, we will implement additive or accumulative calculation in this Rust function. MozReview-Commit-ID: 4xAvLz1oTIZ
dom/animation/KeyframeEffectReadOnly.cpp
layout/style/ServoBindingList.h
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -666,68 +666,28 @@ void
 KeyframeEffectReadOnly::ComposeStyleRule(
   const RawServoAnimationValueMap& aAnimationValues,
   const AnimationProperty& aProperty,
   const AnimationPropertySegment& aSegment,
   const ComputedTiming& aComputedTiming)
 {
   // Bug 1329878 - Stylo: Implement accumulate and addition on Servo
   // AnimationValue.
-  RawServoAnimationValue* servoFromValue = aSegment.mFromValue.mServo;
-  RawServoAnimationValue* servoToValue = aSegment.mToValue.mServo;
 
   // For unsupported or non-animatable animation types, we get nullptrs.
-  if (!servoFromValue || !servoToValue) {
+  if (!aSegment.mFromValue.mServo|| !aSegment.mToValue.mServo) {
     NS_ERROR("Compose style for unsupported or non-animatable property, "
              "so get invalid RawServoAnimationValues");
     return;
   }
 
-  // Special handling for zero-length segments
-  if (aSegment.mToKey == aSegment.mFromKey) {
-    if (aComputedTiming.mProgress.Value() < 0) {
-      Servo_AnimationValueMap_Push(&aAnimationValues,
-                                   aProperty.mProperty,
-                                   servoFromValue);
-    } else {
-      Servo_AnimationValueMap_Push(&aAnimationValues,
-                                   aProperty.mProperty,
-                                   servoToValue);
-    }
-    return;
-  }
-
-  double positionInSegment =
-    (aComputedTiming.mProgress.Value() - aSegment.mFromKey) /
-    (aSegment.mToKey - aSegment.mFromKey);
-  double valuePosition =
-    ComputedTimingFunction::GetPortion(aSegment.mTimingFunction,
-                                       positionInSegment,
-                                       aComputedTiming.mBeforeFlag);
-
-  MOZ_ASSERT(IsFinite(valuePosition), "Position value should be finite");
-
-  RefPtr<RawServoAnimationValue> interpolated =
-    Servo_AnimationValues_Interpolate(servoFromValue,
-                                      servoToValue,
-                                      valuePosition).Consume();
-
-  if (interpolated) {
-    Servo_AnimationValueMap_Push(&aAnimationValues,
-                                 aProperty.mProperty,
-                                 interpolated);
-  } else if (valuePosition < 0.5) {
-    Servo_AnimationValueMap_Push(&aAnimationValues,
-                                 aProperty.mProperty,
-                                 servoFromValue);
-  } else {
-    Servo_AnimationValueMap_Push(&aAnimationValues,
-                                 aProperty.mProperty,
-                                 servoToValue);
-  }
+  Servo_AnimationCompose(&aAnimationValues,
+                         aProperty.mProperty,
+                         &aSegment,
+                         &aComputedTiming);
 }
 
 template<typename ComposeAnimationResult>
 void
 KeyframeEffectReadOnly::ComposeStyle(
   ComposeAnimationResult&& aComposeResult,
   const nsCSSPropertyIDSet& aPropertiesToSkip)
 {
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -199,16 +199,21 @@ SERVO_BINDING_FUNC(Servo_DeclarationBloc
                    const nsACString* value, bool is_important,
                    RawGeckoURLExtraData* data)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_RemoveProperty, void,
                    RawServoDeclarationBlockBorrowed declarations,
                    const nsACString* property)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_RemovePropertyById, void,
                    RawServoDeclarationBlockBorrowed declarations,
                    nsCSSPropertyID property)
+SERVO_BINDING_FUNC(Servo_AnimationCompose, void,
+                   RawServoAnimationValueMapBorrowed,
+                   nsCSSPropertyID property,
+                   RawGeckoAnimationPropertySegmentBorrowed,
+                   RawGeckoComputedTimingBorrowed)
 
 // presentation attributes
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_PropertyIsSet, bool,
                    RawServoDeclarationBlockBorrowed declarations,
                    nsCSSPropertyID property)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetIdentStringValue, void,
                    RawServoDeclarationBlockBorrowed declarations,
                    nsCSSPropertyID property,