summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-07-05 15:43:43 +0200
committerAndreas Kling <kling@serenityos.org>2020-07-05 15:57:07 +0200
commit131bc8fd31a43c385e04d4d634e1dda180bbff24 (patch)
tree116c64b3a2638c617e7f92159636ea099f4a14b8
parent56d14d57013af3d1f7efbf957b2632b0390d2e0f (diff)
downloadserenity-131bc8fd31a43c385e04d4d634e1dda180bbff24.zip
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.
-rw-r--r--Demos/WebView/WebContentClient.cpp8
-rw-r--r--Demos/WebView/WebContentClient.h1
-rw-r--r--Demos/WebView/WebContentView.cpp5
-rw-r--r--Demos/WebView/WebContentView.h1
-rw-r--r--Services/WebContent/PageHost.cpp5
-rw-r--r--Services/WebContent/PageHost.h1
-rw-r--r--Services/WebContent/WebContentClient.ipc1
7 files changed, 22 insertions, 0 deletions
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<WebContentClient>, con
on_title_change(title);
}
+void WebContentView::notify_server_did_request_scroll_into_view(Badge<WebContentClient>, 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<WebContentClient>, const Gfx::IntRect&);
void notify_server_did_change_selection(Badge<WebContentClient>);
void notify_server_did_change_title(Badge<WebContentClient>, const String&);
+ void notify_server_did_request_scroll_into_view(Badge<WebContentClient>, const Gfx::IntRect&);
private:
WebContentView();
diff --git a/Services/WebContent/PageHost.cpp b/Services/WebContent/PageHost.cpp
index 0bd5702451..d72a4bc945 100644
--- a/Services/WebContent/PageHost.cpp
+++ b/Services/WebContent/PageHost.cpp
@@ -129,4 +129,9 @@ void PageHost::page_did_change_title(const String& title)
m_client.post_message(Messages::WebContentClient::DidChangeTitle(title));
}
+void PageHost::page_did_request_scroll_into_view(const Gfx::IntRect& rect)
+{
+ m_client.post_message(Messages::WebContentClient::DidRequestScrollIntoView(rect));
+}
+
}
diff --git a/Services/WebContent/PageHost.h b/Services/WebContent/PageHost.h
index 8c9a611211..14b2e41b2f 100644
--- a/Services/WebContent/PageHost.h
+++ b/Services/WebContent/PageHost.h
@@ -55,6 +55,7 @@ private:
virtual void page_did_change_selection() override;
virtual void page_did_layout() override;
virtual void page_did_change_title(const String&) override;
+ virtual void page_did_request_scroll_into_view(const Gfx::IntRect&) override;
explicit PageHost(ClientConnection&);
diff --git a/Services/WebContent/WebContentClient.ipc b/Services/WebContent/WebContentClient.ipc
index 567298f3f3..8ea47bf9f0 100644
--- a/Services/WebContent/WebContentClient.ipc
+++ b/Services/WebContent/WebContentClient.ipc
@@ -6,4 +6,5 @@ endpoint WebContentClient = 90
DidChangeSelection() =|
DidLayout(Gfx::IntSize content_size) =|
DidChangeTitle(String title) =|
+ DidRequestScrollIntoView(Gfx::IntRect rect) =|
}