mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
LibWeb+WebContent: Add on_load_finish hook to web views
This isn't entirely symmetrical with on_load_start as it will also fire on reloads and back/forward navigations. However, it's good enough for some basic use cases, and we can do more sophisticated notifications later on when we need them.
This commit is contained in:
parent
52dbdf4245
commit
eda9fb13cc
12 changed files with 31 additions and 7 deletions
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -274,6 +274,9 @@ void FrameLoader::resource_did_load()
|
|||
ASSERT(is<HTML::HTMLIFrameElement>(*host_element));
|
||||
downcast<HTML::HTMLIFrameElement>(*host_element).content_frame_did_load({});
|
||||
}
|
||||
|
||||
if (auto* page = frame().page())
|
||||
page->client().page_did_finish_loading(url);
|
||||
}
|
||||
|
||||
void FrameLoader::resource_did_fail()
|
||||
|
|
|
@ -209,6 +209,13 @@ void OutOfProcessWebView::notify_server_did_start_loading(Badge<WebContentClient
|
|||
on_load_start(url);
|
||||
}
|
||||
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_finish_loading(Badge<WebContentClient>, const URL& url)
|
||||
{
|
||||
if (on_load_finish)
|
||||
on_load_finish(url);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_context_menu(Badge<WebContentClient>, const Gfx::IntPoint& content_position)
|
||||
{
|
||||
if (on_context_menu_request)
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
void notify_server_did_click_link(Badge<WebContentClient>, const URL&, const String& target, unsigned modifiers);
|
||||
void notify_server_did_middle_click_link(Badge<WebContentClient>, const URL&, const String& target, unsigned modifiers);
|
||||
void notify_server_did_start_loading(Badge<WebContentClient>, const URL&);
|
||||
void notify_server_did_finish_loading(Badge<WebContentClient>, const URL&);
|
||||
void notify_server_did_request_context_menu(Badge<WebContentClient>, const Gfx::IntPoint&);
|
||||
void notify_server_did_request_link_context_menu(Badge<WebContentClient>, const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers);
|
||||
void notify_server_did_request_alert(Badge<WebContentClient>, const String& message);
|
||||
|
|
|
@ -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&) { }
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -42,6 +42,7 @@ public:
|
|||
Function<void(const URL&)> on_link_hover;
|
||||
Function<void(const String&)> on_title_change;
|
||||
Function<void(const URL&)> on_load_start;
|
||||
Function<void(const URL&)> on_load_finish;
|
||||
Function<void(const Gfx::Bitmap&)> on_favicon_change;
|
||||
Function<void(const URL&)> on_url_drop;
|
||||
Function<void(DOM::Document*)> on_set_document;
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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&);
|
||||
|
|
|
@ -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) => ()
|
||||
|
|
Loading…
Add table
Reference in a new issue