From 131bc8fd31a43c385e04d4d634e1dda180bbff24 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 5 Jul 2020 15:43:43 +0200 Subject: WebContent: Plumb scroll-into-view requests from server to client The WebContentView widget will now be able to react to scroll-into-view requests from the WebContent process. --- Demos/WebView/WebContentClient.cpp | 8 ++++++++ Demos/WebView/WebContentClient.h | 1 + Demos/WebView/WebContentView.cpp | 5 +++++ Demos/WebView/WebContentView.h | 1 + 4 files changed, 15 insertions(+) (limited to 'Demos') diff --git a/Demos/WebView/WebContentClient.cpp b/Demos/WebView/WebContentClient.cpp index e39df2c24a..7d799c9c2c 100644 --- a/Demos/WebView/WebContentClient.cpp +++ b/Demos/WebView/WebContentClient.cpp @@ -90,3 +90,11 @@ void WebContentClient::handle(const Messages::WebContentClient::DidChangeTitle& #endif m_view.notify_server_did_change_title({}, message.title()); } + +void WebContentClient::handle(const Messages::WebContentClient::DidRequestScrollIntoView& message) +{ +#ifdef DEBUG_SPAM + dbg() << "handle: WebContentClient::DidRequestScrollIntoView! rect=" << message.rect(); +#endif + m_view.notify_server_did_request_scroll_into_view({}, message.rect()); +} diff --git a/Demos/WebView/WebContentClient.h b/Demos/WebView/WebContentClient.h index e0c6948a0b..f7aaa6ddf5 100644 --- a/Demos/WebView/WebContentClient.h +++ b/Demos/WebView/WebContentClient.h @@ -50,6 +50,7 @@ private: virtual void handle(const Messages::WebContentClient::DidChangeSelection&) override; virtual void handle(const Messages::WebContentClient::DidLayout&) override; virtual void handle(const Messages::WebContentClient::DidChangeTitle&) override; + virtual void handle(const Messages::WebContentClient::DidRequestScrollIntoView&) override; WebContentView& m_view; }; diff --git a/Demos/WebView/WebContentView.cpp b/Demos/WebView/WebContentView.cpp index 47d226d585..97e5ddf0e8 100644 --- a/Demos/WebView/WebContentView.cpp +++ b/Demos/WebView/WebContentView.cpp @@ -115,6 +115,11 @@ void WebContentView::notify_server_did_change_title(Badge, con on_title_change(title); } +void WebContentView::notify_server_did_request_scroll_into_view(Badge, const Gfx::IntRect& rect) +{ + scroll_into_view(rect, true, true); +} + void WebContentView::did_scroll() { client().post_message(Messages::WebContentServer::SetViewportRect(visible_content_rect())); diff --git a/Demos/WebView/WebContentView.h b/Demos/WebView/WebContentView.h index 3fc7745984..4805bf6654 100644 --- a/Demos/WebView/WebContentView.h +++ b/Demos/WebView/WebContentView.h @@ -46,6 +46,7 @@ public: void notify_server_did_invalidate_content_rect(Badge, const Gfx::IntRect&); void notify_server_did_change_selection(Badge); void notify_server_did_change_title(Badge, const String&); + void notify_server_did_request_scroll_into_view(Badge, const Gfx::IntRect&); private: WebContentView(); -- cgit v1.2.3