diff --git a/Demos/WebView/WebContentClient.cpp b/Demos/WebView/WebContentClient.cpp index 1f2c847e099..98ab9dcda82 100644 --- a/Demos/WebView/WebContentClient.cpp +++ b/Demos/WebView/WebContentClient.cpp @@ -51,3 +51,11 @@ void WebContentClient::handle(const Messages::WebContentClient::DidFinishLoad& m { dbg() << "handle: WebContentClient::DidFinishLoad! url=" << message.url(); } + +void WebContentClient::handle(const Messages::WebContentClient::DidInvalidateContentRect& message) +{ + dbg() << "handle: WebContentClient::DidInvalidateContentRect! content_rect=" << message.content_rect(); + + // FIXME: Figure out a way to coalesce these messages to reduce unnecessary painting + m_view.notify_server_did_invalidate_content_rect({}, message.content_rect()); +} diff --git a/Demos/WebView/WebContentClient.h b/Demos/WebView/WebContentClient.h index ed9e9b41f48..738d3ffa947 100644 --- a/Demos/WebView/WebContentClient.h +++ b/Demos/WebView/WebContentClient.h @@ -46,6 +46,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; WebContentView& m_view; }; diff --git a/Demos/WebView/WebContentView.cpp b/Demos/WebView/WebContentView.cpp index 0cb87d5dae3..4461ed37971 100644 --- a/Demos/WebView/WebContentView.cpp +++ b/Demos/WebView/WebContentView.cpp @@ -69,6 +69,12 @@ void WebContentView::notify_server_did_paint(Badge, i32 shbuf_ update(); } +void WebContentView::notify_server_did_invalidate_content_rect(Badge, const Gfx::IntRect& content_rect) +{ + dbg() << "server did invalidate content_rect: " << content_rect << ", current shbuf_id=" << m_bitmap->shbuf_id(); + client().post_message(Messages::WebContentServer::Paint(m_bitmap->rect(), m_bitmap->shbuf_id())); +} + WebContentClient& WebContentView::client() { return *m_client; diff --git a/Demos/WebView/WebContentView.h b/Demos/WebView/WebContentView.h index 353b9d9c02f..022cbf3d1fd 100644 --- a/Demos/WebView/WebContentView.h +++ b/Demos/WebView/WebContentView.h @@ -39,6 +39,7 @@ public: void load(const URL&); void notify_server_did_paint(Badge, i32 shbuf_id); + void notify_server_did_invalidate_content_rect(Badge, const Gfx::IntRect&); private: WebContentView(); diff --git a/Services/WebContent/ClientConnection.cpp b/Services/WebContent/ClientConnection.cpp index d750f0968ae..4b84d340a0f 100644 --- a/Services/WebContent/ClientConnection.cpp +++ b/Services/WebContent/ClientConnection.cpp @@ -38,7 +38,7 @@ static HashMap> s_connections; ClientConnection::ClientConnection(Core::LocalSocket& socket, int client_id) : IPC::ClientConnection(*this, socket, client_id) - , m_page_host(PageHost::create()) + , m_page_host(PageHost::create(*this)) { s_connections.set(client_id, *this); } diff --git a/Services/WebContent/PageHost.cpp b/Services/WebContent/PageHost.cpp index fdcf3e16c45..202df976a57 100644 --- a/Services/WebContent/PageHost.cpp +++ b/Services/WebContent/PageHost.cpp @@ -25,16 +25,19 @@ */ #include "PageHost.h" +#include "ClientConnection.h" #include #include #include #include #include +#include namespace WebContent { -PageHost::PageHost() - : m_page(make(*this)) +PageHost::PageHost(ClientConnection& client) + : m_client(client) + , m_page(make(*this)) { setup_palette(); } @@ -96,4 +99,9 @@ void PageHost::set_viewport_rect(const Gfx::IntRect& rect) page().main_frame().set_viewport_rect(rect); } +void PageHost::page_did_invalidate(const Gfx::IntRect& content_rect) +{ + m_client.post_message(Messages::WebContentClient::DidInvalidateContentRect(content_rect)); +} + } diff --git a/Services/WebContent/PageHost.h b/Services/WebContent/PageHost.h index dd9908b94e9..ef4c74843e2 100644 --- a/Services/WebContent/PageHost.h +++ b/Services/WebContent/PageHost.h @@ -30,12 +30,14 @@ namespace WebContent { +class ClientConnection; + class PageHost : public Web::PageClient { AK_MAKE_NONCOPYABLE(PageHost); AK_MAKE_NONMOVABLE(PageHost); public: - static NonnullOwnPtr create() { return adopt_own(*new PageHost); } + static NonnullOwnPtr create(ClientConnection& client) { return adopt_own(*new PageHost(client)); } virtual ~PageHost(); Web::Page& page() { return *m_page; } @@ -47,11 +49,15 @@ public: void set_viewport_rect(const Gfx::IntRect&); private: - PageHost(); + // ^PageHost + virtual void page_did_invalidate(const Gfx::IntRect&) override; + + explicit PageHost(ClientConnection&); Gfx::Palette palette() const; void setup_palette(); + ClientConnection& m_client; NonnullOwnPtr m_page; RefPtr m_palette_impl; }; diff --git a/Services/WebContent/WebContentClient.ipc b/Services/WebContent/WebContentClient.ipc index 62298383329..cde1a62f5f1 100644 --- a/Services/WebContent/WebContentClient.ipc +++ b/Services/WebContent/WebContentClient.ipc @@ -1,6 +1,6 @@ endpoint WebContentClient = 90 { DidFinishLoad(URL url) =| - DidPaint(Gfx::IntRect content_rect, i32 shbuf_id) =| + DidInvalidateContentRect(Gfx::IntRect content_rect) =| }