diff options
author | Martin Robinson <mrobinson@igalia.com> | 2020-06-22 16:18:29 +0200 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2020-06-24 17:19:25 +0200 |
commit | 954b5177f077103f967c916ad702275c4ca43f50 (patch) | |
tree | af2c338cda6fc79f00ee94f414a571570838e562 /components/script/animations.rs | |
parent | 99d409f15d86a7afe4ca2ad3b4f8fda7670dec84 (diff) | |
download | servo-954b5177f077103f967c916ad702275c4ca43f50.tar.gz servo-954b5177f077103f967c916ad702275c4ca43f50.zip |
animations: Finish support for fractional iteration counts
This change also improves support for creating animations with negative
delays, as that is necessary to test support for fractional iteration
lengths.
This change also adjusts existing Servo animation tests which assumed
that advancing to the exact moment of the end of the animation would be
considered "before the end." With this change, this moment is "after the
end."
Fixes: #14858
Diffstat (limited to 'components/script/animations.rs')
-rw-r--r-- | components/script/animations.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/components/script/animations.rs b/components/script/animations.rs index bddbac14966..854a06a1e12 100644 --- a/components/script/animations.rs +++ b/components/script/animations.rs @@ -365,7 +365,7 @@ impl Animations { now: f64, pipeline_id: PipelineId, ) { - let num_iterations = match animation.iteration_state { + let iteration_index = match animation.iteration_state { KeyframesIterationState::Finite(current, _) | KeyframesIterationState::Infinite(current) => current, }; @@ -381,10 +381,14 @@ impl Animations { TransitionOrAnimationEventType::AnimationStart => { (-animation.delay).max(0.).min(active_duration) }, - TransitionOrAnimationEventType::AnimationIteration | - TransitionOrAnimationEventType::AnimationEnd => num_iterations * animation.duration, + TransitionOrAnimationEventType::AnimationIteration => { + iteration_index * animation.duration + }, + TransitionOrAnimationEventType::AnimationEnd => { + (iteration_index * animation.duration) + animation.current_iteration_duration() + }, TransitionOrAnimationEventType::AnimationCancel => { - (num_iterations * animation.duration) + (now - animation.started_at).max(0.) + (iteration_index * animation.duration) + (now - animation.started_at).max(0.) }, _ => unreachable!(), } |