diff options
author | bors-servo <servo-ops@mozilla.com> | 2020-05-21 10:11:45 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-21 10:11:45 -0400 |
commit | 70700c20ed8bc3d82e709a3d48e03d8e16530361 (patch) | |
tree | 7eaa9b03598d82ea1f9dd8e71c38cf34688ca09e /components/script/dom | |
parent | c8b6329575d62c912fab5980ac733dd5d9bff260 (diff) | |
parent | 873cdd13368d904e4723fec1d60ecc04d9dbe03d (diff) | |
download | servo-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/dom')
-rw-r--r-- | components/script/dom/document.rs | 22 | ||||
-rw-r--r-- | components/script/dom/macros.rs | 1 | ||||
-rw-r--r-- | components/script/dom/webidls/EventHandler.webidl | 1 | ||||
-rw-r--r-- | components/script/dom/window.rs | 13 |
4 files changed, 29 insertions, 8 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index dfdfd53bd28..b0271e159de 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -3750,12 +3750,26 @@ impl Document { .collect() } - pub(crate) fn advance_animation_timeline_for_testing(&self, delta: f64) { + pub(crate) fn advance_animation_timeline_for_testing(&self, delta: f64) -> AnimationsUpdate { self.animation_timeline.borrow_mut().advance_specific(delta); + let current_timeline_value = self.current_animation_timeline_value(); + self.animations + .borrow_mut() + .update_for_new_timeline_value(&self.window, current_timeline_value) } - pub(crate) fn update_animation_timeline(&self) { - self.animation_timeline.borrow_mut().update(); + pub(crate) fn update_animation_timeline(&self) -> AnimationsUpdate { + // Only update the time if it isn't being managed by a test. + if !pref!(layout.animations.test.enabled) { + self.animation_timeline.borrow_mut().update(); + } + + // We still want to update the animations, because our timeline + // value might have been advanced previously via the TestBinding. + let current_timeline_value = self.current_animation_timeline_value(); + self.animations + .borrow_mut() + .update_for_new_timeline_value(&self.window, current_timeline_value) } pub(crate) fn current_animation_timeline_value(&self) -> f64 { @@ -3766,7 +3780,7 @@ impl Document { self.animations.borrow() } - pub(crate) fn update_animations(&self) -> AnimationsUpdate { + pub(crate) fn update_animations_post_reflow(&self) -> AnimationsUpdate { self.animations .borrow_mut() .do_post_reflow_update(&self.window, self.current_animation_timeline_value()) diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs index 871e831dc82..5a32b36996b 100644 --- a/components/script/dom/macros.rs +++ b/components/script/dom/macros.rs @@ -443,6 +443,7 @@ macro_rules! global_event_handlers( (NoOnload) => ( event_handler!(abort, GetOnabort, SetOnabort); event_handler!(animationend, GetOnanimationend, SetOnanimationend); + event_handler!(animationiteration, GetOnanimationiteration, SetOnanimationiteration); event_handler!(cancel, GetOncancel, SetOncancel); event_handler!(canplay, GetOncanplay, SetOncanplay); event_handler!(canplaythrough, GetOncanplaythrough, SetOncanplaythrough); diff --git a/components/script/dom/webidls/EventHandler.webidl b/components/script/dom/webidls/EventHandler.webidl index b5617564fbc..57138967792 100644 --- a/components/script/dom/webidls/EventHandler.webidl +++ b/components/script/dom/webidls/EventHandler.webidl @@ -93,6 +93,7 @@ interface mixin GlobalEventHandlers { // https://drafts.csswg.org/css-animations/#interface-globaleventhandlers-idl partial interface mixin GlobalEventHandlers { attribute EventHandler onanimationend; + attribute EventHandler onanimationiteration; }; // https://drafts.csswg.org/css-transitions/#interface-globaleventhandlers-idl diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 946bcdcfea9..a6965155588 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -1578,10 +1578,15 @@ impl Window { /// Prepares to tick animations and then does a reflow which also advances the /// layout animation clock. - pub fn advance_animation_clock(&self, delta: i32) { + #[allow(unsafe_code)] + pub fn advance_animation_clock(&self, delta_ms: i32) { let pipeline_id = self.upcast::<GlobalScope>().pipeline_id(); - self.Document() - .advance_animation_timeline_for_testing(delta as f64 / 1000.); + let update = self + .Document() + .advance_animation_timeline_for_testing(delta_ms as f64 / 1000.); + unsafe { + ScriptThread::process_animations_update(update); + } ScriptThread::handle_tick_all_animations_for_testing(pipeline_id); } @@ -1747,7 +1752,7 @@ impl Window { } } - let update = document.update_animations(); + let update = document.update_animations_post_reflow(); unsafe { ScriptThread::process_animations_update(update); } |