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
--- 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,