aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/animations.rs
diff options
context:
space:
mode:
authorbors-servo <servo-ops@mozilla.com>2020-05-21 10:11:45 -0400
committerGitHub <noreply@github.com>2020-05-21 10:11:45 -0400
commit70700c20ed8bc3d82e709a3d48e03d8e16530361 (patch)
tree7eaa9b03598d82ea1f9dd8e71c38cf34688ca09e /components/script/animations.rs
parentc8b6329575d62c912fab5980ac733dd5d9bff260 (diff)
parent873cdd13368d904e4723fec1d60ecc04d9dbe03d (diff)
downloadservo-70700c20ed8bc3d82e709a3d48e03d8e16530361.tar.gz
servo-70700c20ed8bc3d82e709a3d48e03d8e16530361.zip
Auto merge of #26594 - mrobinson:animationiteration, r=jdm
Implement animationiteration event This event is triggered when an animation iterates. This change also moves iteration out of style calculation to an "update animations" which is the next part of having animation event handling match the HTML spec. This change causes a few more tests to pass. Some of the other tests which exercise this functionality require `animationstart` events. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'components/script/animations.rs')
-rw-r--r--components/script/animations.rs31
1 files changed, 29 insertions, 2 deletions
diff --git a/components/script/animations.rs b/components/script/animations.rs
index 91946853f22..0c3f1c68206 100644
--- a/components/script/animations.rs
+++ b/components/script/animations.rs
@@ -35,6 +35,30 @@ impl Animations {
}
}
+ pub(crate) fn update_for_new_timeline_value(
+ &mut self,
+ window: &Window,
+ now: f64,
+ ) -> AnimationsUpdate {
+ let mut update = AnimationsUpdate::new(window.pipeline_id());
+ let mut sets = self.sets.write();
+
+ for set in sets.values_mut() {
+ // When necessary, iterate our running animations to the next iteration.
+ for animation in set.animations.iter_mut() {
+ if animation.iterate_if_necessary(now) {
+ update.add_event(
+ animation.node,
+ animation.name.to_string(),
+ TransitionOrAnimationEventType::AnimationIteration,
+ animation.active_duration(),
+ );
+ }
+ }
+ }
+ update
+ }
+
/// Processes any new animations that were discovered after reflow. Collect messages
/// that trigger events for any animations that changed state.
/// TODO(mrobinson): The specification dictates that this should happen before reflow.
@@ -255,6 +279,9 @@ pub enum TransitionOrAnimationEventType {
TransitionCancel,
/// "The animationend event occurs when the animation finishes"
AnimationEnd,
+ /// "The animationiteration event occurs at the end of each iteration of an
+ /// animation, except when an animationend event would fire at the same time."
+ AnimationIteration,
}
impl TransitionOrAnimationEventType {
@@ -263,7 +290,7 @@ impl TransitionOrAnimationEventType {
pub fn finalizes_transition_or_animation(&self) -> bool {
match *self {
Self::TransitionEnd | Self::TransitionCancel | Self::AnimationEnd => true,
- Self::TransitionRun => false,
+ Self::TransitionRun | Self::AnimationIteration => false,
}
}
@@ -271,7 +298,7 @@ impl TransitionOrAnimationEventType {
pub fn is_transition_event(&self) -> bool {
match *self {
Self::TransitionRun | Self::TransitionEnd | Self::TransitionCancel => true,
- Self::AnimationEnd => false,
+ Self::AnimationEnd | Self::AnimationIteration => false,
}
}
}