From 682a5f9b704bd6135d19060e3416e86d0669c78c Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sat, 20 May 2023 11:04:02 -0400 Subject: [PATCH] Ladybird+LibWebView: Move APIs which only repaint to LibWebView We can easily add hooks to notify the browsers of these events if any implementation-specific handling is needed in the future, but for now, these only repaint the client, which we can do in ViewImplementation. --- Ladybird/AppKit/UI/LadybirdWebViewBridge.cpp | 10 ---------- Ladybird/AppKit/UI/LadybirdWebViewBridge.h | 2 -- Ladybird/Qt/WebContentView.cpp | 10 ---------- Ladybird/Qt/WebContentView.h | 2 -- Userland/Libraries/LibWebView/OutOfProcessWebView.cpp | 10 ---------- Userland/Libraries/LibWebView/OutOfProcessWebView.h | 2 -- Userland/Libraries/LibWebView/ViewImplementation.cpp | 10 ++++++++++ Userland/Libraries/LibWebView/ViewImplementation.h | 4 ++-- Userland/Libraries/LibWebView/WebContentClient.cpp | 4 ++-- Userland/Utilities/headless-browser.cpp | 2 -- 10 files changed, 14 insertions(+), 42 deletions(-) diff --git a/Ladybird/AppKit/UI/LadybirdWebViewBridge.cpp b/Ladybird/AppKit/UI/LadybirdWebViewBridge.cpp index 4307379fc5..2e710ea917 100644 --- a/Ladybird/AppKit/UI/LadybirdWebViewBridge.cpp +++ b/Ladybird/AppKit/UI/LadybirdWebViewBridge.cpp @@ -112,16 +112,6 @@ void WebViewBridge::notify_server_did_layout(Badge, G } } -void WebViewBridge::notify_server_did_invalidate_content_rect(Badge, Gfx::IntRect const&) -{ - request_repaint(); -} - -void WebViewBridge::notify_server_did_change_selection(Badge) -{ - request_repaint(); -} - void WebViewBridge::notify_server_did_request_cursor_change(Badge, Gfx::StandardCursor cursor) { if (on_cursor_change) diff --git a/Ladybird/AppKit/UI/LadybirdWebViewBridge.h b/Ladybird/AppKit/UI/LadybirdWebViewBridge.h index 11832ec21f..8821f42ff2 100644 --- a/Ladybird/AppKit/UI/LadybirdWebViewBridge.h +++ b/Ladybird/AppKit/UI/LadybirdWebViewBridge.h @@ -62,8 +62,6 @@ private: WebViewBridge(Vector screen_rects, float device_pixel_ratio, Optional webdriver_content_ipc_path); virtual void notify_server_did_layout(Badge, Gfx::IntSize content_size) override; - virtual void notify_server_did_invalidate_content_rect(Badge, Gfx::IntRect const&) override; - virtual void notify_server_did_change_selection(Badge) override; virtual void notify_server_did_request_cursor_change(Badge, Gfx::StandardCursor cursor) override; virtual void notify_server_did_request_scroll(Badge, i32, i32) override; virtual void notify_server_did_request_scroll_to(Badge, Gfx::IntPoint) override; diff --git a/Ladybird/Qt/WebContentView.cpp b/Ladybird/Qt/WebContentView.cpp index 9847f233ce..2311342a1c 100644 --- a/Ladybird/Qt/WebContentView.cpp +++ b/Ladybird/Qt/WebContentView.cpp @@ -591,16 +591,6 @@ void WebContentView::create_client(WebView::EnableCallgrindProfiling enable_call client().async_connect_to_webdriver(m_webdriver_content_ipc_path); } -void WebContentView::notify_server_did_invalidate_content_rect(Badge, [[maybe_unused]] Gfx::IntRect const& content_rect) -{ - request_repaint(); -} - -void WebContentView::notify_server_did_change_selection(Badge) -{ - request_repaint(); -} - void WebContentView::notify_server_did_request_cursor_change(Badge, Gfx::StandardCursor cursor) { switch (cursor) { diff --git a/Ladybird/Qt/WebContentView.h b/Ladybird/Qt/WebContentView.h index da9fed6e5f..e8ff7b1087 100644 --- a/Ladybird/Qt/WebContentView.h +++ b/Ladybird/Qt/WebContentView.h @@ -77,8 +77,6 @@ public: void update_palette(PaletteMode = PaletteMode::Default); virtual void notify_server_did_layout(Badge, Gfx::IntSize content_size) override; - virtual void notify_server_did_invalidate_content_rect(Badge, Gfx::IntRect const&) override; - virtual void notify_server_did_change_selection(Badge) override; virtual void notify_server_did_request_cursor_change(Badge, Gfx::StandardCursor cursor) override; virtual void notify_server_did_request_scroll(Badge, i32, i32) override; virtual void notify_server_did_request_scroll_to(Badge, Gfx::IntPoint) override; diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp index 4a390c2a73..f78898a626 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp @@ -179,16 +179,6 @@ void OutOfProcessWebView::screen_rects_change_event(GUI::ScreenRectsChangeEvent& client().async_update_screen_rects(event.rects(), event.main_screen_index()); } -void OutOfProcessWebView::notify_server_did_invalidate_content_rect(Badge, [[maybe_unused]] Gfx::IntRect const& content_rect) -{ - request_repaint(); -} - -void OutOfProcessWebView::notify_server_did_change_selection(Badge) -{ - request_repaint(); -} - void OutOfProcessWebView::notify_server_did_request_cursor_change(Badge, Gfx::StandardCursor cursor) { set_override_cursor(cursor); diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.h b/Userland/Libraries/LibWebView/OutOfProcessWebView.h index c8d61a0d89..daf7405dfb 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.h +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.h @@ -83,8 +83,6 @@ private: virtual void create_client(EnableCallgrindProfiling = EnableCallgrindProfiling::No) override; virtual void update_zoom() override; virtual void notify_server_did_layout(Badge, Gfx::IntSize content_size) override; - virtual void notify_server_did_invalidate_content_rect(Badge, Gfx::IntRect const&) override; - virtual void notify_server_did_change_selection(Badge) override; virtual void notify_server_did_request_cursor_change(Badge, Gfx::StandardCursor cursor) override; virtual void notify_server_did_request_scroll(Badge, i32, i32) override; virtual void notify_server_did_request_scroll_to(Badge, Gfx::IntPoint) override; diff --git a/Userland/Libraries/LibWebView/ViewImplementation.cpp b/Userland/Libraries/LibWebView/ViewImplementation.cpp index 79a76686f1..89b9b32c6b 100644 --- a/Userland/Libraries/LibWebView/ViewImplementation.cpp +++ b/Userland/Libraries/LibWebView/ViewImplementation.cpp @@ -70,6 +70,16 @@ void ViewImplementation::server_did_paint(Badge, i32 bitmap_id } } +void ViewImplementation::server_did_invalidate_content_rect(Badge, Gfx::IntRect) +{ + request_repaint(); +} + +void ViewImplementation::server_did_change_selection(Badge) +{ + request_repaint(); +} + void ViewImplementation::load(AK::URL const& url) { m_url = url; diff --git a/Userland/Libraries/LibWebView/ViewImplementation.h b/Userland/Libraries/LibWebView/ViewImplementation.h index 8a2fee65e1..33e52e0d8e 100644 --- a/Userland/Libraries/LibWebView/ViewImplementation.h +++ b/Userland/Libraries/LibWebView/ViewImplementation.h @@ -48,6 +48,8 @@ public: String const& handle() const { return m_client_state.client_handle; } void server_did_paint(Badge, i32 bitmap_id, Gfx::IntSize size); + void server_did_invalidate_content_rect(Badge, Gfx::IntRect rect); + void server_did_change_selection(Badge); void load(AK::URL const&); void load_html(StringView, AK::URL const&); @@ -138,8 +140,6 @@ public: Function on_fullscreen_window; virtual void notify_server_did_layout(Badge, Gfx::IntSize content_size) = 0; - virtual void notify_server_did_invalidate_content_rect(Badge, Gfx::IntRect const&) = 0; - virtual void notify_server_did_change_selection(Badge) = 0; virtual void notify_server_did_request_cursor_change(Badge, Gfx::StandardCursor cursor) = 0; virtual void notify_server_did_request_scroll(Badge, i32, i32) = 0; virtual void notify_server_did_request_scroll_to(Badge, Gfx::IntPoint) = 0; diff --git a/Userland/Libraries/LibWebView/WebContentClient.cpp b/Userland/Libraries/LibWebView/WebContentClient.cpp index 4bc124c9d4..419a99865b 100644 --- a/Userland/Libraries/LibWebView/WebContentClient.cpp +++ b/Userland/Libraries/LibWebView/WebContentClient.cpp @@ -67,13 +67,13 @@ void WebContentClient::did_invalidate_content_rect(Gfx::IntRect const& content_r dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidInvalidateContentRect! content_rect={}", content_rect); // FIXME: Figure out a way to coalesce these messages to reduce unnecessary painting - m_view.notify_server_did_invalidate_content_rect({}, content_rect); + m_view.server_did_invalidate_content_rect({}, content_rect); } void WebContentClient::did_change_selection() { dbgln_if(SPAM_DEBUG, "handle: WebContentClient::DidChangeSelection!"); - m_view.notify_server_did_change_selection({}); + m_view.server_did_change_selection({}); } void WebContentClient::did_request_cursor_change(i32 cursor_type) diff --git a/Userland/Utilities/headless-browser.cpp b/Userland/Utilities/headless-browser.cpp index 0d51b9791f..555d678c66 100644 --- a/Userland/Utilities/headless-browser.cpp +++ b/Userland/Utilities/headless-browser.cpp @@ -103,8 +103,6 @@ private: HeadlessWebContentView() = default; void notify_server_did_layout(Badge, Gfx::IntSize) override { } - void notify_server_did_invalidate_content_rect(Badge, Gfx::IntRect const&) override { } - void notify_server_did_change_selection(Badge) override { } void notify_server_did_request_cursor_change(Badge, Gfx::StandardCursor) override { } void notify_server_did_request_scroll(Badge, i32, i32) override { } void notify_server_did_request_scroll_to(Badge, Gfx::IntPoint) override { }