mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #26659 - mrobinson:events, r=jdm
Add support for remaining animation and transition events This PR adds support for remaining animation and transitions events. There are two commits here. The first is a bit more complicated: it reworks how rooting is done for animating nodes. Instead of having the `ScriptThread` try to track which animations are active via events (which can be inaccurate), it just maintains roots for nodes that are actually present in the animations- -related data structures. The second commit adds support for the new events. Unfortunately, the existing events tests either rely on the Web Animations API or other behavior (for example, that changing animation delay restarts an animation). Since those two things are out-of-scope for this change, I've forked some of the WPT tests, removed the reliance on the Web Animations API, and added them to Servo's internal tests. --- <!-- 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 - [x] These changes fix #21564. - [x] There are tests for these changes OR <!-- 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. -->
This commit is contained in:
commit
93a6c37836
31 changed files with 763 additions and 399 deletions
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::animation_timeline::AnimationTimeline;
|
||||
use crate::animations::{Animations, AnimationsUpdate};
|
||||
use crate::animations::Animations;
|
||||
use crate::document_loader::{DocumentLoader, LoadType};
|
||||
use crate::dom::attr::Attr;
|
||||
use crate::dom::beforeunloadevent::BeforeUnloadEvent;
|
||||
|
@ -3750,15 +3750,15 @@ impl Document {
|
|||
.collect()
|
||||
}
|
||||
|
||||
pub(crate) fn advance_animation_timeline_for_testing(&self, delta: f64) -> AnimationsUpdate {
|
||||
pub(crate) fn advance_animation_timeline_for_testing(&self, delta: f64) {
|
||||
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)
|
||||
.borrow()
|
||||
.update_for_new_timeline_value(&self.window, current_timeline_value);
|
||||
}
|
||||
|
||||
pub(crate) fn update_animation_timeline(&self) -> AnimationsUpdate {
|
||||
pub(crate) fn update_animation_timeline(&self) {
|
||||
// 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();
|
||||
|
@ -3768,8 +3768,8 @@ impl Document {
|
|||
// 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)
|
||||
.borrow()
|
||||
.update_for_new_timeline_value(&self.window, current_timeline_value);
|
||||
}
|
||||
|
||||
pub(crate) fn current_animation_timeline_value(&self) -> f64 {
|
||||
|
@ -3780,10 +3780,10 @@ impl Document {
|
|||
self.animations.borrow()
|
||||
}
|
||||
|
||||
pub(crate) fn update_animations_post_reflow(&self) -> AnimationsUpdate {
|
||||
pub(crate) fn update_animations_post_reflow(&self) {
|
||||
self.animations
|
||||
.borrow_mut()
|
||||
.do_post_reflow_update(&self.window, self.current_animation_timeline_value())
|
||||
.borrow()
|
||||
.do_post_reflow_update(&self.window, self.current_animation_timeline_value());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::cell::{DomRefCell, Ref};
|
||||
use crate::dom::bindings::codegen::Bindings::DocumentBinding::{
|
||||
DocumentMethods, DocumentReadyState,
|
||||
};
|
||||
|
@ -410,6 +410,10 @@ impl Window {
|
|||
unsafe { JSContext::from_ptr(self.js_runtime.borrow().as_ref().unwrap().cx()) }
|
||||
}
|
||||
|
||||
pub fn get_js_runtime(&self) -> Ref<Option<Rc<Runtime>>> {
|
||||
self.js_runtime.borrow()
|
||||
}
|
||||
|
||||
pub fn main_thread_script_chan(&self) -> &Sender<MainThreadScriptMsg> {
|
||||
&self.script_chan.0
|
||||
}
|
||||
|
@ -1581,12 +1585,8 @@ impl Window {
|
|||
#[allow(unsafe_code)]
|
||||
pub fn advance_animation_clock(&self, delta_ms: i32) {
|
||||
let pipeline_id = self.upcast::<GlobalScope>().pipeline_id();
|
||||
let update = self
|
||||
.Document()
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1752,10 +1752,7 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
let update = document.update_animations_post_reflow();
|
||||
unsafe {
|
||||
ScriptThread::process_animations_update(update);
|
||||
}
|
||||
document.update_animations_post_reflow();
|
||||
|
||||
true
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue