diff --git a/Ladybird/AppKit/UI/LadybirdWebViewBridge.cpp b/Ladybird/AppKit/UI/LadybirdWebViewBridge.cpp index 25966f9750..4307379fc5 100644 --- a/Ladybird/AppKit/UI/LadybirdWebViewBridge.cpp +++ b/Ladybird/AppKit/UI/LadybirdWebViewBridge.cpp @@ -112,26 +112,6 @@ void WebViewBridge::notify_server_did_layout(Badge, G } } -void WebViewBridge::notify_server_did_paint(Badge, i32 bitmap_id, Gfx::IntSize size) -{ - if (m_client_state.back_bitmap.id == bitmap_id) { - m_client_state.has_usable_bitmap = true; - m_client_state.back_bitmap.pending_paints--; - m_client_state.back_bitmap.last_painted_size = size; - swap(m_client_state.back_bitmap, m_client_state.front_bitmap); - // We don't need the backup bitmap anymore, so drop it. - m_backup_bitmap = nullptr; - - if (on_ready_to_paint) - on_ready_to_paint(); - - if (m_client_state.got_repaint_requests_while_painting) { - m_client_state.got_repaint_requests_while_painting = false; - request_repaint(); - } - } -} - void WebViewBridge::notify_server_did_invalidate_content_rect(Badge, Gfx::IntRect const&) { request_repaint(); diff --git a/Ladybird/AppKit/UI/LadybirdWebViewBridge.h b/Ladybird/AppKit/UI/LadybirdWebViewBridge.h index 799af0df07..11832ec21f 100644 --- a/Ladybird/AppKit/UI/LadybirdWebViewBridge.h +++ b/Ladybird/AppKit/UI/LadybirdWebViewBridge.h @@ -50,7 +50,6 @@ public: Optional paintable(); Function on_layout; - Function on_ready_to_paint; Function on_scroll; @@ -63,7 +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_paint(Badge, i32 bitmap_id, Gfx::IntSize) 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; diff --git a/Ladybird/Qt/WebContentView.cpp b/Ladybird/Qt/WebContentView.cpp index 41eb0cccad..9847f233ce 100644 --- a/Ladybird/Qt/WebContentView.cpp +++ b/Ladybird/Qt/WebContentView.cpp @@ -75,6 +75,10 @@ WebContentView::WebContentView(StringView webdriver_content_ipc_path, WebView::E }); create_client(enable_callgrind_profiling); + + on_ready_to_paint = [this]() { + viewport()->update(); + }; } WebContentView::~WebContentView() = default; @@ -587,24 +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_paint(Badge, i32 bitmap_id, Gfx::IntSize size) -{ - if (m_client_state.back_bitmap.id == bitmap_id) { - m_client_state.has_usable_bitmap = true; - m_client_state.back_bitmap.pending_paints--; - m_client_state.back_bitmap.last_painted_size = size; - swap(m_client_state.back_bitmap, m_client_state.front_bitmap); - // We don't need the backup bitmap anymore, so drop it. - m_backup_bitmap = nullptr; - viewport()->update(); - - if (m_client_state.got_repaint_requests_while_painting) { - m_client_state.got_repaint_requests_while_painting = false; - request_repaint(); - } - } -} - void WebContentView::notify_server_did_invalidate_content_rect(Badge, [[maybe_unused]] Gfx::IntRect const& content_rect) { request_repaint(); diff --git a/Ladybird/Qt/WebContentView.h b/Ladybird/Qt/WebContentView.h index 7b737d9f5d..da9fed6e5f 100644 --- a/Ladybird/Qt/WebContentView.h +++ b/Ladybird/Qt/WebContentView.h @@ -77,7 +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_paint(Badge, i32 bitmap_id, Gfx::IntSize) 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; diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp index 167a465a5c..4a390c2a73 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp @@ -29,6 +29,10 @@ OutOfProcessWebView::OutOfProcessWebView() create_client(); + on_ready_to_paint = [this]() { + update(); + }; + on_request_file = [this](auto const& path, auto request_id) { auto file = FileSystemAccessClient::Client::the().request_file_read_only_approved(window(), path); @@ -175,24 +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_paint(Badge, i32 bitmap_id, Gfx::IntSize size) -{ - if (m_client_state.back_bitmap.id == bitmap_id) { - m_client_state.has_usable_bitmap = true; - m_client_state.back_bitmap.pending_paints--; - m_client_state.back_bitmap.last_painted_size = size; - swap(m_client_state.back_bitmap, m_client_state.front_bitmap); - // We don't need the backup bitmap anymore, so drop it. - m_backup_bitmap = nullptr; - update(); - - if (m_client_state.got_repaint_requests_while_painting) { - m_client_state.got_repaint_requests_while_painting = false; - request_repaint(); - } - } -} - void OutOfProcessWebView::notify_server_did_invalidate_content_rect(Badge, [[maybe_unused]] Gfx::IntRect const& content_rect) { request_repaint(); diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.h b/Userland/Libraries/LibWebView/OutOfProcessWebView.h index b6b7a46dee..c8d61a0d89 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.h +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.h @@ -83,7 +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_paint(Badge, i32 bitmap_id, Gfx::IntSize) 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; diff --git a/Userland/Libraries/LibWebView/ViewImplementation.cpp b/Userland/Libraries/LibWebView/ViewImplementation.cpp index a5fd85804f..79a76686f1 100644 --- a/Userland/Libraries/LibWebView/ViewImplementation.cpp +++ b/Userland/Libraries/LibWebView/ViewImplementation.cpp @@ -48,6 +48,28 @@ WebContentClient const& ViewImplementation::client() const return *m_client_state.client; } +void ViewImplementation::server_did_paint(Badge, i32 bitmap_id, Gfx::IntSize size) +{ + if (m_client_state.back_bitmap.id != bitmap_id) + return; + + m_client_state.has_usable_bitmap = true; + m_client_state.back_bitmap.pending_paints--; + m_client_state.back_bitmap.last_painted_size = size; + swap(m_client_state.back_bitmap, m_client_state.front_bitmap); + + // We don't need the backup bitmap anymore, so drop it. + m_backup_bitmap = nullptr; + + if (on_ready_to_paint) + on_ready_to_paint(); + + if (m_client_state.got_repaint_requests_while_painting) { + m_client_state.got_repaint_requests_while_painting = false; + 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 fd529be845..8a2fee65e1 100644 --- a/Userland/Libraries/LibWebView/ViewImplementation.h +++ b/Userland/Libraries/LibWebView/ViewImplementation.h @@ -47,6 +47,8 @@ public: String const& handle() const { return m_client_state.client_handle; } + void server_did_paint(Badge, i32 bitmap_id, Gfx::IntSize size); + void load(AK::URL const&); void load_html(StringView, AK::URL const&); void load_empty_document(); @@ -90,6 +92,7 @@ public: }; ErrorOr take_screenshot(ScreenshotType); + Function on_ready_to_paint; Function on_new_tab; Function on_activate_tab; Function on_close; @@ -135,7 +138,6 @@ public: Function on_fullscreen_window; virtual void notify_server_did_layout(Badge, Gfx::IntSize content_size) = 0; - virtual void notify_server_did_paint(Badge, i32 bitmap_id, Gfx::IntSize) = 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; diff --git a/Userland/Libraries/LibWebView/WebContentClient.cpp b/Userland/Libraries/LibWebView/WebContentClient.cpp index 9bef4e8690..4bc124c9d4 100644 --- a/Userland/Libraries/LibWebView/WebContentClient.cpp +++ b/Userland/Libraries/LibWebView/WebContentClient.cpp @@ -25,7 +25,7 @@ void WebContentClient::die() void WebContentClient::did_paint(Gfx::IntRect const& rect, i32 bitmap_id) { - m_view.notify_server_did_paint({}, bitmap_id, rect.size()); + m_view.server_did_paint({}, bitmap_id, rect.size()); } void WebContentClient::did_start_loading(AK::URL const& url, bool is_redirect) diff --git a/Userland/Utilities/headless-browser.cpp b/Userland/Utilities/headless-browser.cpp index a1b0ad0f32..0d51b9791f 100644 --- a/Userland/Utilities/headless-browser.cpp +++ b/Userland/Utilities/headless-browser.cpp @@ -103,7 +103,6 @@ private: HeadlessWebContentView() = default; void notify_server_did_layout(Badge, Gfx::IntSize) override { } - void notify_server_did_paint(Badge, i32, 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 { }