script: Batch scroll event firing (#38222)

The user interaction triggered `scroll` event was initially implemented
in https://github.com/servo/servo/pull/36687.

In triggering the `scroll` event, the event should be batched and
triggered within update the rendering. This serves as a preparatory PR
for the JS API triggered `scroll` event.

Part of: #31665

---------

Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
This commit is contained in:
Jo Steven Novaryo 2025-07-25 01:48:12 +08:00 committed by GitHub
parent eeac336518
commit 1fb782bc38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 107 additions and 11 deletions

View file

@ -1148,7 +1148,7 @@ impl ScriptThread {
document.handle_editing_action(editing_action_event, can_gc);
},
InputEvent::Scroll(scroll_event) => {
document.handle_scroll_event(scroll_event, can_gc);
document.handle_embedder_scroll_event(scroll_event);
},
}
}
@ -1254,9 +1254,6 @@ impl ScriptThread {
// https://html.spec.whatwg.org/multipage/#flush-autofocus-candidates.
self.process_pending_input_events(*pipeline_id, can_gc);
// TODO(#31665): Implement the "run the scroll steps" from
// https://drafts.csswg.org/cssom-view/#document-run-the-scroll-steps.
// > 8. For each doc of docs, run the resize steps for doc. [CSSOMVIEW]
if document.window().run_the_resize_steps(can_gc) {
// Evaluate media queries and report changes.
@ -1269,6 +1266,9 @@ impl ScriptThread {
document.react_to_environment_changes()
}
// > 9. For each doc of docs, run the scroll steps for doc.
document.run_the_scroll_steps(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]