From c917a59abe6338ef72be4fe1e13ecda83e6e0064 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Mon, 21 Nov 2022 15:22:26 -0500 Subject: [PATCH] LibWeb+WebContent: Virtualize PageClient methods needed for all clients --- Userland/Libraries/LibWeb/Page/Page.h | 3 +++ Userland/Services/WebContent/PageHost.h | 6 +++--- Userland/Utilities/headless-browser.cpp | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibWeb/Page/Page.h b/Userland/Libraries/LibWeb/Page/Page.h index 135281691d6..b00f2c6ca10 100644 --- a/Userland/Libraries/LibWeb/Page/Page.h +++ b/Userland/Libraries/LibWeb/Page/Page.h @@ -133,10 +133,13 @@ private: class PageClient { public: + virtual Page& page() = 0; + virtual Page const& page() const = 0; virtual bool is_connection_open() const = 0; virtual Gfx::Palette palette() const = 0; virtual Gfx::IntRect screen_rect() const = 0; virtual CSS::PreferredColorScheme preferred_color_scheme() const = 0; + virtual void paint(Gfx::IntRect const&, Gfx::Bitmap&) = 0; virtual void page_did_change_title(String const&) { } virtual void page_did_start_loading(const AK::URL&) { } virtual void page_did_create_main_document() { } diff --git a/Userland/Services/WebContent/PageHost.h b/Userland/Services/WebContent/PageHost.h index ed70439f00d..197b55e6b94 100644 --- a/Userland/Services/WebContent/PageHost.h +++ b/Userland/Services/WebContent/PageHost.h @@ -23,10 +23,10 @@ public: static NonnullOwnPtr create(ConnectionFromClient& client) { return adopt_own(*new PageHost(client)); } virtual ~PageHost(); - Web::Page& page() { return *m_page; } - Web::Page const& page() const { return *m_page; } + virtual Web::Page& page() override { return *m_page; } + virtual Web::Page const& page() const override { return *m_page; } - void paint(Gfx::IntRect const& content_rect, Gfx::Bitmap&); + virtual void paint(Gfx::IntRect const& content_rect, Gfx::Bitmap&) override; void set_palette_impl(Gfx::PaletteImpl const&); void set_viewport_rect(Gfx::IntRect const&); diff --git a/Userland/Utilities/headless-browser.cpp b/Userland/Utilities/headless-browser.cpp index 8721a90be08..82c95c59ad7 100644 --- a/Userland/Utilities/headless-browser.cpp +++ b/Userland/Utilities/headless-browser.cpp @@ -55,8 +55,8 @@ public: return adopt_own(*new HeadlessBrowserPageClient()); } - Web::Page& page() { return *m_page; } - Web::Page const& page() const { return *m_page; } + virtual Web::Page& page() override { return *m_page; } + virtual Web::Page const& page() const override { return *m_page; } Web::Layout::InitialContainingBlock* layout_root() { @@ -71,7 +71,7 @@ public: page().load(url); } - void paint(Gfx::IntRect const& content_rect, Gfx::Bitmap& target) + virtual void paint(Gfx::IntRect const& content_rect, Gfx::Bitmap& target) override { Gfx::Painter painter(target);