summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-04-06 15:32:38 +0200
committerAndreas Kling <kling@serenityos.org>2022-04-06 19:35:08 +0200
commit0f6e1f7a326d3b13ed3639b970027c821e6251e6 (patch)
tree008f1962540ef62d6770d92aafc8af0b3da81eaa /Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
parent06d97c892b6d69e6bcfb5769f7d6b8880d4584ad (diff)
downloadserenity-0f6e1f7a326d3b13ed3639b970027c821e6251e6.zip
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.
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp')
-rw-r--r--Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
index 80a7c0454a..2e68a8b447 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
@@ -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())