diff --git a/Libraries/LibWeb/InProcessWebView.cpp b/Libraries/LibWeb/InProcessWebView.cpp index 40f33b32e3..8701583145 100644 --- a/Libraries/LibWeb/InProcessWebView.cpp +++ b/Libraries/LibWeb/InProcessWebView.cpp @@ -150,6 +150,12 @@ void InProcessWebView::page_did_start_loading(const URL& url) on_load_start(url); } +void InProcessWebView::page_did_finish_loading(const URL& url) +{ + if (on_load_finish) + on_load_finish(url); +} + void InProcessWebView::page_did_change_selection() { update(); diff --git a/Libraries/LibWeb/InProcessWebView.h b/Libraries/LibWeb/InProcessWebView.h index 7194836b9d..084c3a01c4 100644 --- a/Libraries/LibWeb/InProcessWebView.h +++ b/Libraries/LibWeb/InProcessWebView.h @@ -88,6 +88,7 @@ private: virtual void page_did_change_title(const String&) override; virtual void page_did_set_document_in_main_frame(DOM::Document*) override; virtual void page_did_start_loading(const URL&) override; + virtual void page_did_finish_loading(const URL&) override; virtual void page_did_change_selection() override; virtual void page_did_request_cursor_change(Gfx::StandardCursor) override; virtual void page_did_request_context_menu(const Gfx::IntPoint&) override; diff --git a/Libraries/LibWeb/Loader/FrameLoader.cpp b/Libraries/LibWeb/Loader/FrameLoader.cpp index c5c417e7cc..9df29cf52e 100644 --- a/Libraries/LibWeb/Loader/FrameLoader.cpp +++ b/Libraries/LibWeb/Loader/FrameLoader.cpp @@ -274,6 +274,9 @@ void FrameLoader::resource_did_load() ASSERT(is(*host_element)); downcast(*host_element).content_frame_did_load({}); } + + if (auto* page = frame().page()) + page->client().page_did_finish_loading(url); } void FrameLoader::resource_did_fail() diff --git a/Libraries/LibWeb/OutOfProcessWebView.cpp b/Libraries/LibWeb/OutOfProcessWebView.cpp index 736f523233..64206d301b 100644 --- a/Libraries/LibWeb/OutOfProcessWebView.cpp +++ b/Libraries/LibWeb/OutOfProcessWebView.cpp @@ -209,6 +209,13 @@ void OutOfProcessWebView::notify_server_did_start_loading(Badge, const URL& url) +{ + if (on_load_finish) + on_load_finish(url); +} + void OutOfProcessWebView::notify_server_did_request_context_menu(Badge, const Gfx::IntPoint& content_position) { if (on_context_menu_request) diff --git a/Libraries/LibWeb/OutOfProcessWebView.h b/Libraries/LibWeb/OutOfProcessWebView.h index f610a40bdf..5779d6f6da 100644 --- a/Libraries/LibWeb/OutOfProcessWebView.h +++ b/Libraries/LibWeb/OutOfProcessWebView.h @@ -60,6 +60,7 @@ public: void notify_server_did_click_link(Badge, const URL&, const String& target, unsigned modifiers); void notify_server_did_middle_click_link(Badge, const URL&, const String& target, unsigned modifiers); void notify_server_did_start_loading(Badge, const URL&); + void notify_server_did_finish_loading(Badge, const URL&); void notify_server_did_request_context_menu(Badge, const Gfx::IntPoint&); void notify_server_did_request_link_context_menu(Badge, const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers); void notify_server_did_request_alert(Badge, const String& message); diff --git a/Libraries/LibWeb/Page/Page.h b/Libraries/LibWeb/Page/Page.h index 8fa1719d2e..5d7325d283 100644 --- a/Libraries/LibWeb/Page/Page.h +++ b/Libraries/LibWeb/Page/Page.h @@ -85,6 +85,7 @@ public: virtual void page_did_set_document_in_main_frame(DOM::Document*) { } virtual void page_did_change_title(const String&) { } virtual void page_did_start_loading(const URL&) { } + virtual void page_did_finish_loading(const URL&) { } virtual void page_did_change_selection() { } virtual void page_did_request_cursor_change(Gfx::StandardCursor) { } virtual void page_did_request_context_menu(const Gfx::IntPoint&) { } diff --git a/Libraries/LibWeb/WebContentClient.cpp b/Libraries/LibWeb/WebContentClient.cpp index 5a679ab068..0c09cb92af 100644 --- a/Libraries/LibWeb/WebContentClient.cpp +++ b/Libraries/LibWeb/WebContentClient.cpp @@ -52,11 +52,9 @@ void WebContentClient::handle(const Messages::WebContentClient::DidPaint& messag m_view.notify_server_did_paint({}, message.shbuf_id()); } -void WebContentClient::handle([[maybe_unused]] const Messages::WebContentClient::DidFinishLoad& message) +void WebContentClient::handle([[maybe_unused]] const Messages::WebContentClient::DidFinishLoading& message) { -#ifdef DEBUG_SPAM - dbg() << "handle: WebContentClient::DidFinishLoad! url=" << message.url(); -#endif + m_view.notify_server_did_finish_loading({}, message.url()); } void WebContentClient::handle(const Messages::WebContentClient::DidInvalidateContentRect& message) diff --git a/Libraries/LibWeb/WebContentClient.h b/Libraries/LibWeb/WebContentClient.h index c712b193b7..2078882578 100644 --- a/Libraries/LibWeb/WebContentClient.h +++ b/Libraries/LibWeb/WebContentClient.h @@ -47,7 +47,7 @@ private: WebContentClient(OutOfProcessWebView&); virtual void handle(const Messages::WebContentClient::DidPaint&) override; - virtual void handle(const Messages::WebContentClient::DidFinishLoad&) override; + virtual void handle(const Messages::WebContentClient::DidFinishLoading&) override; virtual void handle(const Messages::WebContentClient::DidInvalidateContentRect&) override; virtual void handle(const Messages::WebContentClient::DidChangeSelection&) override; virtual void handle(const Messages::WebContentClient::DidLayout&) override; diff --git a/Libraries/LibWeb/WebViewHooks.h b/Libraries/LibWeb/WebViewHooks.h index d93655bcea..198526e019 100644 --- a/Libraries/LibWeb/WebViewHooks.h +++ b/Libraries/LibWeb/WebViewHooks.h @@ -42,6 +42,7 @@ public: Function on_link_hover; Function on_title_change; Function on_load_start; + Function on_load_finish; Function on_favicon_change; Function on_url_drop; Function on_set_document; diff --git a/Services/WebContent/PageHost.cpp b/Services/WebContent/PageHost.cpp index 5e8952143c..6dc8adcb3c 100644 --- a/Services/WebContent/PageHost.cpp +++ b/Services/WebContent/PageHost.cpp @@ -159,6 +159,11 @@ void PageHost::page_did_start_loading(const URL& url) m_client.post_message(Messages::WebContentClient::DidStartLoading(url)); } +void PageHost::page_did_finish_loading(const URL& url) +{ + m_client.post_message(Messages::WebContentClient::DidFinishLoading(url)); +} + void PageHost::page_did_request_context_menu(const Gfx::IntPoint& content_position) { m_client.post_message(Messages::WebContentClient::DidRequestContextMenu(content_position)); diff --git a/Services/WebContent/PageHost.h b/Services/WebContent/PageHost.h index 91db8debef..0ee9e393d9 100644 --- a/Services/WebContent/PageHost.h +++ b/Services/WebContent/PageHost.h @@ -63,6 +63,7 @@ private: virtual void page_did_request_context_menu(const Gfx::IntPoint&) override; virtual void page_did_request_link_context_menu(const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers) override; virtual void page_did_start_loading(const URL&) override; + virtual void page_did_finish_loading(const URL&) override; virtual void page_did_request_alert(const String&) override; explicit PageHost(ClientConnection&); diff --git a/Services/WebContent/WebContentClient.ipc b/Services/WebContent/WebContentClient.ipc index 2b88944cfd..10008a765c 100644 --- a/Services/WebContent/WebContentClient.ipc +++ b/Services/WebContent/WebContentClient.ipc @@ -1,6 +1,7 @@ endpoint WebContentClient = 90 { - DidFinishLoad(URL url) =| + DidStartLoading(URL url) =| + DidFinishLoading(URL url) =| DidPaint(Gfx::IntRect content_rect, i32 shbuf_id) =| DidInvalidateContentRect(Gfx::IntRect content_rect) =| DidChangeSelection() =| @@ -11,7 +12,6 @@ endpoint WebContentClient = 90 DidUnhoverLink() =| DidClickLink(URL url, String target, unsigned modifiers) =| DidMiddleClickLink(URL url, String target, unsigned modifiers) =| - DidStartLoading(URL url) =| DidRequestContextMenu(Gfx::IntPoint content_position) =| DidRequestLinkContextMenu(Gfx::IntPoint content_position, URL url, String target, unsigned modifiers) =| DidRequestAlert(String message) => ()