mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
script: Update animations once per-Document during update_the_rendering()
(#34489)
Before, `update_the_rendering()` would update all animations for all Documents once per-Document. Apart from being generally wrong, the specification says this should be done once per-Document. This theoretically means that `update_the_rendering()` is just doing less work every time it runs. In addition: - Don't redirty animations nodes when running rAF callbacks. They should already be dirty when animations are updated. - Perform a microtask checkpoint while updating animations as dictacted by the specification. - Update comments to reflect the specification text. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
1591a3b506
commit
54761b4f32
3 changed files with 71 additions and 60 deletions
|
@ -1665,8 +1665,10 @@ impl ScriptThread {
|
|||
document.react_to_environment_changes()
|
||||
}
|
||||
|
||||
// Update animations and send events.
|
||||
self.update_animations_and_send_events(can_gc);
|
||||
// > 11. For each doc of docs, update animations and send events for doc, passing
|
||||
// > in relative high resolution time given frameTimestamp and doc's relevant
|
||||
// > global object as the timestamp [WEBANIMATIONS]
|
||||
document.update_animations_and_send_events(can_gc);
|
||||
|
||||
// TODO(#31866): Implement "run the fullscreen steps" from
|
||||
// https://fullscreen.spec.whatwg.org/multipage/#run-the-fullscreen-steps.
|
||||
|
@ -1674,8 +1676,12 @@ impl ScriptThread {
|
|||
// TODO(#31868): Implement the "context lost steps" from
|
||||
// https://html.spec.whatwg.org/multipage/#context-lost-steps.
|
||||
|
||||
// Run the animation frame callbacks.
|
||||
document.tick_all_animations(should_run_rafs, can_gc);
|
||||
// > 14. For each doc of docs, run the animation frame callbacks for doc, passing
|
||||
// > in the relative high resolution time given frameTimestamp and doc's
|
||||
// > relevant global object as the timestamp.
|
||||
if should_run_rafs {
|
||||
document.run_the_animation_frame_callbacks(can_gc);
|
||||
}
|
||||
|
||||
// Run the resize observer steps.
|
||||
let _realm = enter_realm(&*document);
|
||||
|
@ -2050,22 +2056,6 @@ impl ScriptThread {
|
|||
true
|
||||
}
|
||||
|
||||
// Perform step 7.10 from https://html.spec.whatwg.org/multipage/#event-loop-processing-model.
|
||||
// Described at: https://drafts.csswg.org/web-animations-1/#update-animations-and-send-events
|
||||
fn update_animations_and_send_events(&self, can_gc: CanGc) {
|
||||
for (_, document) in self.documents.borrow().iter() {
|
||||
document.update_animation_timeline();
|
||||
document.maybe_mark_animating_nodes_as_dirty();
|
||||
}
|
||||
|
||||
for (_, document) in self.documents.borrow().iter() {
|
||||
let _realm = enter_realm(&*document);
|
||||
document
|
||||
.animations()
|
||||
.send_pending_events(document.window(), can_gc);
|
||||
}
|
||||
}
|
||||
|
||||
fn categorize_msg(&self, msg: &MixedMessage) -> ScriptThreadEventCategory {
|
||||
match *msg {
|
||||
MixedMessage::FromConstellation(ref inner_msg) => match *inner_msg {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue