script: Fire scroll event whenever JS scrolled (#38321)

Implement JS scroll event firing compliant to
https://drafts.csswg.org/cssom-view/#scrolling-events. Basically
whenever, the an element or the viewport is scrolled, we will fire a
scroll event. The changes push a scroll event whenever an API causes a
scroll position to change.

Testing: New WPT tests for basic APIs.
Part of: https://github.com/servo/servo/issues/31665

---------

Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
This commit is contained in:
Jo Steven Novaryo 2025-08-01 15:30:22 +08:00 committed by GitHub
parent 372e5eae59
commit a063b5e78a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 407 additions and 74 deletions

View file

@ -1295,8 +1295,14 @@ impl ScriptThread {
self.process_pending_input_events(*pipeline_id, can_gc);
// > 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.
let resized = document.window().run_the_resize_steps(can_gc);
// > 9. For each doc of docs, run the scroll steps for doc.
document.run_the_scroll_steps(can_gc);
// Media queries is only relevant when there are resizing.
if resized {
// 10. For each doc of docs, evaluate media queries and report changes for doc.
document
.window()
.evaluate_media_queries_and_report_changes(can_gc);
@ -1306,9 +1312,6 @@ 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]