diff --git a/Libraries/LibWebView/ViewImplementation.h b/Libraries/LibWebView/ViewImplementation.h index 17fb9f2b138..918af84b4c9 100644 --- a/Libraries/LibWebView/ViewImplementation.h +++ b/Libraries/LibWebView/ViewImplementation.h @@ -51,6 +51,9 @@ public: void set_url(Badge, URL::URL url) { m_url = move(url); } URL::URL const& url() const { return m_url; } + void set_title(Badge, ByteString title) { m_title = move(title); } + ByteString const& title() const { return m_title; } + String const& handle() const { return m_client_state.client_handle; } void server_did_paint(Badge, i32 bitmap_id, Gfx::IntSize size); @@ -286,6 +289,7 @@ protected: } m_client_state; URL::URL m_url; + ByteString m_title; float m_zoom_level { 1.0 }; float m_device_pixel_ratio { 1.0 }; diff --git a/Libraries/LibWebView/WebContentClient.cpp b/Libraries/LibWebView/WebContentClient.cpp index 8bfee313c22..dbcd12c602a 100644 --- a/Libraries/LibWebView/WebContentClient.cpp +++ b/Libraries/LibWebView/WebContentClient.cpp @@ -142,13 +142,11 @@ void WebContentClient::did_change_title(u64 page_id, ByteString const& title) process->set_title(MUST(String::from_byte_string(title))); if (auto view = view_for_page_id(page_id); view.has_value()) { - if (!view->on_title_change) - return; + auto title_or_url = title.is_empty() ? view->url().to_byte_string() : title; + view->set_title({}, title_or_url); - if (title.is_empty()) - view->on_title_change(view->url().to_byte_string()); - else - view->on_title_change(title); + if (view->on_title_change) + view->on_title_change(title_or_url); } }