mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
WebContent: Allow the WebContent process to trigger repaints
After layout, we may want to repaint the page, so we now listen for the PageClient::page_did_invalidate() notification and use it to drive a client-side repaint. Note that an invalidation request from LibWeb makes a full roundtrip to the WebContent client and back since the client drives painting.
This commit is contained in:
parent
c45c5ded34
commit
0bac2ad3b3
Notes:
sideshowbarker
2024-07-19 05:35:31 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/0bac2ad3b3c
8 changed files with 36 additions and 6 deletions
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -69,6 +69,12 @@ void WebContentView::notify_server_did_paint(Badge<WebContentClient>, i32 shbuf_
|
|||
update();
|
||||
}
|
||||
|
||||
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();
|
||||
client().post_message(Messages::WebContentServer::Paint(m_bitmap->rect(), m_bitmap->shbuf_id()));
|
||||
}
|
||||
|
||||
WebContentClient& WebContentView::client()
|
||||
{
|
||||
return *m_client;
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
void load(const URL&);
|
||||
|
||||
void notify_server_did_paint(Badge<WebContentClient>, i32 shbuf_id);
|
||||
void notify_server_did_invalidate_content_rect(Badge<WebContentClient>, const Gfx::IntRect&);
|
||||
|
||||
private:
|
||||
WebContentView();
|
||||
|
|
|
@ -38,7 +38,7 @@ static HashMap<int, RefPtr<ClientConnection>> s_connections;
|
|||
|
||||
ClientConnection::ClientConnection(Core::LocalSocket& socket, int client_id)
|
||||
: IPC::ClientConnection<WebContentServerEndpoint>(*this, socket, client_id)
|
||||
, m_page_host(PageHost::create())
|
||||
, m_page_host(PageHost::create(*this))
|
||||
{
|
||||
s_connections.set(client_id, *this);
|
||||
}
|
||||
|
|
|
@ -25,16 +25,19 @@
|
|||
*/
|
||||
|
||||
#include "PageHost.h"
|
||||
#include "ClientConnection.h"
|
||||
#include <AK/SharedBuffer.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibGfx/SystemTheme.h>
|
||||
#include <LibWeb/Frame/Frame.h>
|
||||
#include <LibWeb/Layout/LayoutDocument.h>
|
||||
#include <WebContent/WebContentClientEndpoint.h>
|
||||
|
||||
namespace WebContent {
|
||||
|
||||
PageHost::PageHost()
|
||||
: m_page(make<Web::Page>(*this))
|
||||
PageHost::PageHost(ClientConnection& client)
|
||||
: m_client(client)
|
||||
, m_page(make<Web::Page>(*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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,12 +30,14 @@
|
|||
|
||||
namespace WebContent {
|
||||
|
||||
class ClientConnection;
|
||||
|
||||
class PageHost : public Web::PageClient {
|
||||
AK_MAKE_NONCOPYABLE(PageHost);
|
||||
AK_MAKE_NONMOVABLE(PageHost);
|
||||
|
||||
public:
|
||||
static NonnullOwnPtr<PageHost> create() { return adopt_own(*new PageHost); }
|
||||
static NonnullOwnPtr<PageHost> 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<Web::Page> m_page;
|
||||
RefPtr<Gfx::PaletteImpl> m_palette_impl;
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
endpoint WebContentClient = 90
|
||||
{
|
||||
DidFinishLoad(URL url) =|
|
||||
|
||||
DidPaint(Gfx::IntRect content_rect, i32 shbuf_id) =|
|
||||
DidInvalidateContentRect(Gfx::IntRect content_rect) =|
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue