mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:27:35 +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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -129,6 +129,8 @@ private:
|
|||
|
||||
void reset_cursor_blink_cycle();
|
||||
|
||||
void scroll_offset_did_change();
|
||||
|
||||
WeakPtr<Page> m_page;
|
||||
|
||||
FrameLoader m_loader;
|
||||
|
|
|
@ -169,7 +169,10 @@ void EventLoop::process()
|
|||
document.run_the_resize_steps();
|
||||
});
|
||||
|
||||
// FIXME: 8. For each fully active Document in docs, run the scroll steps for that Document, passing in now as the timestamp. [CSSOMVIEW]
|
||||
// 8. For each fully active Document in docs, run the scroll steps for that Document, passing in now as the timestamp. [CSSOMVIEW]
|
||||
for_each_fully_active_document_in_docs([&](DOM::Document& document) {
|
||||
document.run_the_scroll_steps();
|
||||
});
|
||||
|
||||
// 9. For each fully active Document in docs, evaluate media queries and report changes for that Document, passing in now as the timestamp. [CSSOMVIEW]
|
||||
for_each_fully_active_document_in_docs([&](DOM::Document& document) {
|
||||
|
|
|
@ -49,6 +49,7 @@ namespace Web::HTML::EventNames {
|
|||
__ENUMERATE_HTML_EVENT(readystatechange) \
|
||||
__ENUMERATE_HTML_EVENT(rejectionhandled) \
|
||||
__ENUMERATE_HTML_EVENT(reset) \
|
||||
__ENUMERATE_HTML_EVENT(scroll) \
|
||||
__ENUMERATE_HTML_EVENT(securitypolicyviolation) \
|
||||
__ENUMERATE_HTML_EVENT(select) \
|
||||
__ENUMERATE_HTML_EVENT(slotchange) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue