1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:48:11 +00:00

LibWeb: Make BrowsingContext ask PageClient when it wants to be scrolled

BrowsingContext shouldn't be scrolling itself, instead it has to update
the layout (to ensure that we have current document metrics, and then
ask the PageClient nicely to scroll it.

This fixes an issue where BrowsingContext sometimes believed itself to
be scrolled, but OOPWV had a different idea.
This commit is contained in:
Andreas Kling 2022-04-06 15:32:38 +02:00
parent 06d97c892b
commit 0f6e1f7a32
3 changed files with 11 additions and 12 deletions

View file

@ -149,16 +149,6 @@ void BrowsingContext::set_size(Gfx::IntSize const& size)
HTML::main_thread_event_loop().schedule();
}
void BrowsingContext::set_viewport_scroll_offset(Gfx::IntPoint const& offset)
{
if (m_viewport_scroll_offset == offset)
return;
m_viewport_scroll_offset = offset;
for (auto* client : m_viewport_clients)
client->browsing_context_did_set_viewport_rect(viewport_rect());
}
void BrowsingContext::set_needs_display()
{
set_needs_display(viewport_rect());
@ -179,6 +169,15 @@ void BrowsingContext::set_needs_display(Gfx::IntRect const& rect)
container()->layout_node()->set_needs_display();
}
void BrowsingContext::scroll_to(Gfx::IntPoint const& position)
{
if (active_document())
active_document()->force_layout();
if (m_page)
m_page->client().page_did_request_scroll_to(position);
}
void BrowsingContext::scroll_to_anchor(String const& fragment)
{
if (!active_document())