mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-22 17:31:58 -05:00
Browser: Display a default favicon and title
This ensures we consistently show a favicon and that we update the title to at least display the page URL when there isn't a <title> tag. We would otherwise continue displaying the previous page's title.
This commit is contained in:
parent
099f18faff
commit
06d1477312
4 changed files with 13 additions and 2 deletions
|
@ -546,6 +546,7 @@ Tab& BrowserWindow::create_new_tab(URL::URL const& url, Web::HTML::ActivateTab a
|
|||
auto& new_tab = m_tab_widget->add_tab<Browser::Tab>("New tab"_string, *this);
|
||||
|
||||
m_tab_widget->set_bar_visible(!is_fullscreen() && m_tab_widget->children().size() > 1);
|
||||
m_tab_widget->set_tab_icon(new_tab, new_tab.icon());
|
||||
|
||||
new_tab.on_title_change = [this, &new_tab](auto& title) {
|
||||
m_tab_widget->set_tab_title(new_tab, String::from_byte_string(title).release_value_but_fixme_should_propagate_errors());
|
||||
|
|
|
@ -11,6 +11,7 @@ ErrorOr<IconBag> IconBag::try_create()
|
|||
{
|
||||
IconBag icon_bag;
|
||||
|
||||
icon_bag.default_favicon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-browser.png"sv));
|
||||
icon_bag.filetype_html = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png"sv));
|
||||
icon_bag.filetype_text = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-text.png"sv));
|
||||
icon_bag.filetype_javascript = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-javascript.png"sv));
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace Browser {
|
|||
struct IconBag final {
|
||||
static ErrorOr<IconBag> try_create();
|
||||
|
||||
RefPtr<Gfx::Bitmap> default_favicon { nullptr };
|
||||
RefPtr<Gfx::Bitmap> filetype_html { nullptr };
|
||||
RefPtr<Gfx::Bitmap> filetype_text { nullptr };
|
||||
RefPtr<Gfx::Bitmap> filetype_javascript { nullptr };
|
||||
|
|
|
@ -112,6 +112,8 @@ Tab::Tab(BrowserWindow& window)
|
|||
{
|
||||
load_from_gml(tab_gml).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
m_icon = g_icon_bag.default_favicon;
|
||||
|
||||
m_toolbar_container = *find_descendant_of_type_named<GUI::ToolbarContainer>("toolbar_container");
|
||||
auto& toolbar = *find_descendant_of_type_named<GUI::Toolbar>("toolbar");
|
||||
|
||||
|
@ -222,10 +224,16 @@ Tab::Tab(BrowserWindow& window)
|
|||
m_history.replace_current(url, title());
|
||||
}
|
||||
|
||||
auto url_serialized = url.serialize();
|
||||
|
||||
m_title = url_serialized;
|
||||
if (on_title_change)
|
||||
on_title_change(m_title);
|
||||
|
||||
update_status();
|
||||
|
||||
m_location_box->set_icon(nullptr);
|
||||
m_location_box->set_text(url.to_byte_string());
|
||||
m_location_box->set_text(url_serialized);
|
||||
|
||||
// don't add to history if back or forward is pressed
|
||||
if (!m_is_history_navigation)
|
||||
|
@ -233,7 +241,7 @@ Tab::Tab(BrowserWindow& window)
|
|||
m_is_history_navigation = false;
|
||||
|
||||
update_actions();
|
||||
update_bookmark_button(url.to_byte_string());
|
||||
update_bookmark_button(url_serialized);
|
||||
|
||||
if (m_dom_inspector_widget)
|
||||
m_dom_inspector_widget->reset();
|
||||
|
|
Loading…
Reference in a new issue