diff options
author | Andreas Kling <kling@serenityos.org> | 2020-07-04 20:57:57 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-04 20:57:57 +0200 |
commit | a4b5350aff281680b96e642c19c8f41f2b16b5dd (patch) | |
tree | eae25b7d64ecb55b3410712a7ef669c7fcc7d023 /Demos/WebView | |
parent | 8476e3933b87031c2ad6cbba21709b88fff5742f (diff) | |
download | serenity-a4b5350aff281680b96e642c19c8f41f2b16b5dd.zip |
WebContent: Notify client when web content selection changes
The WebContentView widgets reacts to this by requesting a repaint.
Diffstat (limited to 'Demos/WebView')
-rw-r--r-- | Demos/WebView/WebContentClient.cpp | 6 | ||||
-rw-r--r-- | Demos/WebView/WebContentClient.h | 1 | ||||
-rw-r--r-- | Demos/WebView/WebContentView.cpp | 10 | ||||
-rw-r--r-- | Demos/WebView/WebContentView.h | 3 |
4 files changed, 20 insertions, 0 deletions
diff --git a/Demos/WebView/WebContentClient.cpp b/Demos/WebView/WebContentClient.cpp index 0594c1cf4e..0906edcaa1 100644 --- a/Demos/WebView/WebContentClient.cpp +++ b/Demos/WebView/WebContentClient.cpp @@ -60,3 +60,9 @@ void WebContentClient::handle(const Messages::WebContentClient::DidInvalidateCon // FIXME: Figure out a way to coalesce these messages to reduce unnecessary painting m_view.notify_server_did_invalidate_content_rect({}, message.content_rect()); } + +void WebContentClient::handle(const Messages::WebContentClient::DidChangeSelection&) +{ + dbg() << "handle: WebContentClient::DidChangeSelection!"; + m_view.notify_server_did_change_selection({}); +} diff --git a/Demos/WebView/WebContentClient.h b/Demos/WebView/WebContentClient.h index 738d3ffa94..2e0e6f5358 100644 --- a/Demos/WebView/WebContentClient.h +++ b/Demos/WebView/WebContentClient.h @@ -47,6 +47,7 @@ private: virtual void handle(const Messages::WebContentClient::DidPaint&) override; virtual void handle(const Messages::WebContentClient::DidFinishLoad&) override; virtual void handle(const Messages::WebContentClient::DidInvalidateContentRect&) override; + virtual void handle(const Messages::WebContentClient::DidChangeSelection&) override; WebContentView& m_view; }; diff --git a/Demos/WebView/WebContentView.cpp b/Demos/WebView/WebContentView.cpp index 9bd1fc7a77..0ac909865c 100644 --- a/Demos/WebView/WebContentView.cpp +++ b/Demos/WebView/WebContentView.cpp @@ -87,6 +87,16 @@ void WebContentView::notify_server_did_paint(Badge<WebContentClient>, i32 shbuf_ void WebContentView::notify_server_did_invalidate_content_rect(Badge<WebContentClient>, const Gfx::IntRect& content_rect) { dbg() << "server did invalidate content_rect: " << content_rect << ", current shbuf_id=" << m_bitmap->shbuf_id(); + request_repaint(); +} + +void WebContentView::notify_server_did_change_selection(Badge<WebContentClient>) +{ + request_repaint(); +} + +void WebContentView::request_repaint() +{ client().post_message(Messages::WebContentServer::Paint(m_bitmap->rect(), m_bitmap->shbuf_id())); } diff --git a/Demos/WebView/WebContentView.h b/Demos/WebView/WebContentView.h index c354ba7f33..64734e1c4f 100644 --- a/Demos/WebView/WebContentView.h +++ b/Demos/WebView/WebContentView.h @@ -40,6 +40,7 @@ public: void notify_server_did_paint(Badge<WebContentClient>, i32 shbuf_id); void notify_server_did_invalidate_content_rect(Badge<WebContentClient>, const Gfx::IntRect&); + void notify_server_did_change_selection(Badge<WebContentClient>); private: WebContentView(); @@ -50,6 +51,8 @@ private: virtual void mouseup_event(GUI::MouseEvent&) override; virtual void mousemove_event(GUI::MouseEvent&) override; + void request_repaint(); + WebContentClient& client(); RefPtr<WebContentClient> m_client; |