mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +00:00
LibWeb: Implement basic "scroll" events at the document level
This commit is contained in:
parent
07c4bf03b5
commit
da451467b1
6 changed files with 65 additions and 1 deletions
|
@ -320,6 +320,7 @@ void BrowsingContext::set_viewport_rect(Gfx::IntRect const& rect)
|
|||
|
||||
if (m_viewport_scroll_offset != rect.location()) {
|
||||
m_viewport_scroll_offset = rect.location();
|
||||
scroll_offset_did_change();
|
||||
did_change = true;
|
||||
}
|
||||
|
||||
|
@ -785,4 +786,23 @@ DOM::Document* BrowsingContext::active_document()
|
|||
return m_active_document.cell();
|
||||
}
|
||||
|
||||
void BrowsingContext::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:
|
||||
|
||||
// 1. Let doc be the viewport’s associated Document.
|
||||
auto* doc = active_document();
|
||||
VERIFY(doc);
|
||||
|
||||
// 2. If doc is already in doc’s pending scroll event targets, abort these steps.
|
||||
for (auto& target : doc->pending_scroll_event_targets()) {
|
||||
if (target.ptr() == doc)
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. Append doc to doc’s pending scroll event targets.
|
||||
doc->pending_scroll_event_targets().append(*doc);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue