From 83414af9f3feb01e3afddfe05a472d1f83d0bcff Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 8 Sep 2021 11:44:36 +0100 Subject: [PATCH] LibWeb+WebContent: Add WebContentClient::did_request_scroll_to() call This call sets the absolute scroll position for the window. --- Userland/Libraries/LibWeb/OutOfProcessWebView.cpp | 6 ++++++ Userland/Libraries/LibWeb/OutOfProcessWebView.h | 1 + Userland/Libraries/LibWeb/Page/Page.h | 1 + Userland/Libraries/LibWeb/WebContentClient.cpp | 5 +++++ Userland/Libraries/LibWeb/WebContentClient.h | 1 + Userland/Services/WebContent/PageHost.cpp | 5 +++++ Userland/Services/WebContent/PageHost.h | 1 + Userland/Services/WebContent/WebContentClient.ipc | 1 + 8 files changed, 21 insertions(+) diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp index 241173070fd..6eec7399ca4 100644 --- a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp @@ -241,6 +241,12 @@ void OutOfProcessWebView::notify_server_did_request_scroll(Badge, Gfx::IntPoint const& scroll_position) +{ + horizontal_scrollbar().set_value(scroll_position.x()); + vertical_scrollbar().set_value(scroll_position.y()); +} + void OutOfProcessWebView::notify_server_did_request_scroll_into_view(Badge, const Gfx::IntRect& rect) { scroll_into_view(rect, true, true); diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.h b/Userland/Libraries/LibWeb/OutOfProcessWebView.h index 3eef0e87c1c..ed1a1d45763 100644 --- a/Userland/Libraries/LibWeb/OutOfProcessWebView.h +++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.h @@ -58,6 +58,7 @@ public: void notify_server_did_request_cursor_change(Badge, Gfx::StandardCursor cursor); void notify_server_did_change_title(Badge, const String&); void notify_server_did_request_scroll(Badge, i32, i32); + void notify_server_did_request_scroll_to(Badge, Gfx::IntPoint const&); void notify_server_did_request_scroll_into_view(Badge, const Gfx::IntRect&); void notify_server_did_enter_tooltip_area(Badge, const Gfx::IntPoint&, const String&); void notify_server_did_leave_tooltip_area(Badge); diff --git a/Userland/Libraries/LibWeb/Page/Page.h b/Userland/Libraries/LibWeb/Page/Page.h index a172a3ace6f..120294b0d91 100644 --- a/Userland/Libraries/LibWeb/Page/Page.h +++ b/Userland/Libraries/LibWeb/Page/Page.h @@ -86,6 +86,7 @@ public: virtual void page_did_change_favicon(const Gfx::Bitmap&) { } virtual void page_did_layout() { } virtual void page_did_request_scroll(i32, i32) { } + virtual void page_did_request_scroll_to(Gfx::IntPoint const&) { } virtual void page_did_request_scroll_into_view(const Gfx::IntRect&) { } virtual void page_did_request_alert(const String&) { } virtual bool page_did_request_confirm(const String&) { return false; } diff --git a/Userland/Libraries/LibWeb/WebContentClient.cpp b/Userland/Libraries/LibWeb/WebContentClient.cpp index be1fe180826..34a34487acf 100644 --- a/Userland/Libraries/LibWeb/WebContentClient.cpp +++ b/Userland/Libraries/LibWeb/WebContentClient.cpp @@ -73,6 +73,11 @@ void WebContentClient::did_request_scroll(i32 x_delta, i32 y_delta) m_view.notify_server_did_request_scroll({}, x_delta, y_delta); } +void WebContentClient::did_request_scroll_to(Gfx::IntPoint const& scroll_position) +{ + m_view.notify_server_did_request_scroll_to({}, scroll_position); +} + void WebContentClient::did_request_scroll_into_view(Gfx::IntRect const& rect) { dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidRequestScrollIntoView! rect={}", rect); diff --git a/Userland/Libraries/LibWeb/WebContentClient.h b/Userland/Libraries/LibWeb/WebContentClient.h index a80f3253034..b22fcdb400c 100644 --- a/Userland/Libraries/LibWeb/WebContentClient.h +++ b/Userland/Libraries/LibWeb/WebContentClient.h @@ -37,6 +37,7 @@ private: virtual void did_layout(Gfx::IntSize const&) override; virtual void did_change_title(String const&) override; virtual void did_request_scroll(i32, i32) override; + virtual void did_request_scroll_to(Gfx::IntPoint const&) override; virtual void did_request_scroll_into_view(Gfx::IntRect const&) override; virtual void did_enter_tooltip_area(Gfx::IntPoint const&, String const&) override; virtual void did_leave_tooltip_area() override; diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp index 42bf80e8a69..0b2f0a4ae69 100644 --- a/Userland/Services/WebContent/PageHost.cpp +++ b/Userland/Services/WebContent/PageHost.cpp @@ -109,6 +109,11 @@ void PageHost::page_did_request_scroll(i32 x_delta, i32 y_delta) m_client.async_did_request_scroll(x_delta, y_delta); } +void PageHost::page_did_request_scroll_to(Gfx::IntPoint const& scroll_position) +{ + m_client.async_did_request_scroll_to(scroll_position); +} + void PageHost::page_did_request_scroll_into_view(const Gfx::IntRect& rect) { m_client.async_did_request_scroll_into_view(rect); diff --git a/Userland/Services/WebContent/PageHost.h b/Userland/Services/WebContent/PageHost.h index 535f862191b..ef4b48208a4 100644 --- a/Userland/Services/WebContent/PageHost.h +++ b/Userland/Services/WebContent/PageHost.h @@ -42,6 +42,7 @@ private: virtual void page_did_layout() override; virtual void page_did_change_title(const String&) override; virtual void page_did_request_scroll(i32, i32) override; + virtual void page_did_request_scroll_to(Gfx::IntPoint const&) override; virtual void page_did_request_scroll_into_view(const Gfx::IntRect&) override; virtual void page_did_enter_tooltip_area(const Gfx::IntPoint&, const String&) override; virtual void page_did_leave_tooltip_area() override; diff --git a/Userland/Services/WebContent/WebContentClient.ipc b/Userland/Services/WebContent/WebContentClient.ipc index 3a2905ff9a1..4bf8178037d 100644 --- a/Userland/Services/WebContent/WebContentClient.ipc +++ b/Userland/Services/WebContent/WebContentClient.ipc @@ -13,6 +13,7 @@ endpoint WebContentClient did_layout(Gfx::IntSize content_size) =| did_change_title(String title) =| did_request_scroll(i32 x_delta, i32 y_delta) =| + did_request_scroll_to(Gfx::IntPoint scroll_position) =| did_request_scroll_into_view(Gfx::IntRect rect) =| did_enter_tooltip_area(Gfx::IntPoint content_position, String title) =| did_leave_tooltip_area() =|