Explorar el Código

Ladybird: Reset the default favicon when starting a new page load

This matches the AppKit chrome. This resets the favicon so that we do
not keep using the previous site's favicon if the new site does not have
one.
Timothy Flynn hace 1 año
padre
commit
8ff3cd6d76
Se han modificado 2 ficheros con 14 adiciones y 1 borrados
  1. 10 1
      Ladybird/Qt/Tab.cpp
  2. 4 0
      Userland/Applications/Browser/Tab.cpp

+ 10 - 1
Ladybird/Qt/Tab.cpp

@@ -42,6 +42,12 @@
 
 
 namespace Ladybird {
 namespace Ladybird {
 
 
+static QIcon default_favicon()
+{
+    static QIcon icon = load_icon_from_uri("resource://icons/16x16/app-browser.png"sv);
+    return icon;
+}
+
 static QIcon create_tvg_icon_with_theme_colors(QString name, QPalette const& palette)
 static QIcon create_tvg_icon_with_theme_colors(QString name, QPalette const& palette)
 {
 {
     auto path = QString(":/Icons/%1.tvg").arg(name);
     auto path = QString(":/Icons/%1.tvg").arg(name);
@@ -83,7 +89,7 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St
 
 
     recreate_toolbar_icons();
     recreate_toolbar_icons();
 
 
-    m_favicon = load_icon_from_uri("resource://icons/16x16/app-browser.png"sv);
+    m_favicon = default_favicon();
 
 
     m_toolbar->addAction(&m_window->go_back_action());
     m_toolbar->addAction(&m_window->go_back_action());
     m_toolbar->addAction(&m_window->go_forward_action());
     m_toolbar->addAction(&m_window->go_forward_action());
@@ -136,6 +142,9 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St
         m_title = url_serialized;
         m_title = url_serialized;
         emit title_changed(tab_index(), url_serialized);
         emit title_changed(tab_index(), url_serialized);
 
 
+        m_favicon = default_favicon();
+        emit favicon_changed(tab_index(), m_favicon);
+
         m_location_edit->setText(url_serialized);
         m_location_edit->setText(url_serialized);
         m_location_edit->setCursorPosition(0);
         m_location_edit->setCursorPosition(0);
 
 

+ 4 - 0
Userland/Applications/Browser/Tab.cpp

@@ -231,6 +231,10 @@ Tab::Tab(BrowserWindow& window)
         if (on_title_change)
         if (on_title_change)
             on_title_change(m_title);
             on_title_change(m_title);
 
 
+        m_icon = g_icon_bag.default_favicon;
+        if (on_favicon_change)
+            on_favicon_change(*m_icon);
+
         update_status();
         update_status();
 
 
         m_location_box->set_icon(nullptr);
         m_location_box->set_icon(nullptr);