1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 09:34:57 +09:00

LibWebView: Store the tab title on the ViewImplementation

This will be needed for DevTools, to avoid the need to go into the UI
layer for this information.
This commit is contained in:
Timothy Flynn 2025-02-17 06:43:06 -05:00 committed by Tim Flynn
parent 3904765c4f
commit 49c93d01db
Notes: github-actions[bot] 2025-02-19 13:47:30 +00:00
2 changed files with 8 additions and 6 deletions

View file

@ -51,6 +51,9 @@ public:
void set_url(Badge<WebContentClient>, URL::URL url) { m_url = move(url); }
URL::URL const& url() const { return m_url; }
void set_title(Badge<WebContentClient>, 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<WebContentClient>, 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 };

View file

@ -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);
}
}