LibWeb/DOM: Use a single scroll queue for all events

Corresponds to:
36f05864a6
302490c80c
https://github.com/w3c/csswg-drafts/pull/13238
https://github.com/w3c/csswg-drafts/pull/13239

The latter two are my own corrections which haven't been merged yet.
This commit is contained in:
Sam Atkins
2025-12-18 15:29:19 +00:00
committed by Andreas Kling
parent e3c76d396f
commit cb0c428b3a
Notes: github-actions[bot] 2025-12-19 18:10:15 +00:00
4 changed files with 42 additions and 33 deletions

View File

@@ -2442,20 +2442,23 @@ void perform_url_and_history_update_steps(DOM::Document& document, URL::URL new_
void Navigable::scroll_offset_did_change()
{
// https://w3c.github.io/csswg-drafts/cssom-view-1/#scrolling-events
// Whenever a viewport gets scrolled (whether in response to user interaction or by an API), the user agent must run these steps:
// Whenever a viewport gets scrolled (whether in response to user interaction or by an API), the user agent must
// run these steps:
// 1. Let doc be the viewports associated Document.
auto doc = active_document();
VERIFY(doc);
// 2. If doc is already in docs pending scroll event targets, abort these steps.
for (auto& target : doc->pending_scroll_event_targets()) {
if (target.ptr() == doc)
return;
}
// FIXME: 2. If doc is a snap container, run the steps to update scrollsnapchanging targets for doc with docs eventual
// snap target in the block axis as newBlockTarget and docs eventual snap target in the inline axis as
// newInlineTarget.
// 3. Append doc to docs pending scroll event targets.
doc->pending_scroll_event_targets().append(*doc);
// 3. If (doc, "scroll") is already in docs pending scroll events, abort these steps.
if (doc->pending_scroll_events().contains_slow(DOM::Document::PendingScrollEvent { *doc, EventNames::scroll }))
return;
// 4. Append (doc, "scroll") to docs pending scroll events.
doc->pending_scroll_events().append({ *doc, EventNames::scroll });
}
CSSPixelRect Navigable::to_top_level_rect(CSSPixelRect const& a_rect)