mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:47:43 +00:00
LibWeb: Show correct favicon when default favicon is loaded
Block the replacement of the favicon by the default favicon loader when a favicon that is loaded through a link tag is already active. This way, the favicon in the link tags will be prioritized against the default favicons from `/favicon.ico` or the seranity default icon.
This commit is contained in:
parent
06d9853a8b
commit
69ca27d3d7
2 changed files with 14 additions and 0 deletions
|
@ -339,6 +339,7 @@ public:
|
||||||
|
|
||||||
bool in_removed_last_ref() const { return m_in_removed_last_ref; }
|
bool in_removed_last_ref() const { return m_in_removed_last_ref; }
|
||||||
|
|
||||||
|
bool has_active_favicon() const { return m_active_favicon; }
|
||||||
void check_favicon_after_loading_link_resource();
|
void check_favicon_after_loading_link_resource();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -187,6 +187,10 @@ bool FrameLoader::load(LoadRequest& request, Type type)
|
||||||
if (type == Type::IFrame)
|
if (type == Type::IFrame)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
auto* document = browsing_context().active_document();
|
||||||
|
if (document && document->has_active_favicon())
|
||||||
|
return true;
|
||||||
|
|
||||||
if (url.protocol() == "http" || url.protocol() == "https") {
|
if (url.protocol() == "http" || url.protocol() == "https") {
|
||||||
AK::URL favicon_url;
|
AK::URL favicon_url;
|
||||||
favicon_url.set_protocol(url.protocol());
|
favicon_url.set_protocol(url.protocol());
|
||||||
|
@ -197,6 +201,10 @@ bool FrameLoader::load(LoadRequest& request, Type type)
|
||||||
ResourceLoader::the().load(
|
ResourceLoader::the().load(
|
||||||
favicon_url,
|
favicon_url,
|
||||||
[this, favicon_url](auto data, auto&, auto) {
|
[this, favicon_url](auto data, auto&, auto) {
|
||||||
|
// Always fetch the current document
|
||||||
|
auto* document = this->browsing_context().active_document();
|
||||||
|
if (document && document->has_active_favicon())
|
||||||
|
return;
|
||||||
dbgln_if(SPAM_DEBUG, "Favicon downloaded, {} bytes from {}", data.size(), favicon_url);
|
dbgln_if(SPAM_DEBUG, "Favicon downloaded, {} bytes from {}", data.size(), favicon_url);
|
||||||
if (data.is_empty())
|
if (data.is_empty())
|
||||||
return;
|
return;
|
||||||
|
@ -211,6 +219,11 @@ bool FrameLoader::load(LoadRequest& request, Type type)
|
||||||
load_favicon(favicon_bitmap);
|
load_favicon(favicon_bitmap);
|
||||||
},
|
},
|
||||||
[this](auto&, auto) {
|
[this](auto&, auto) {
|
||||||
|
// Always fetch the current document
|
||||||
|
auto* document = this->browsing_context().active_document();
|
||||||
|
if (document && document->has_active_favicon())
|
||||||
|
return;
|
||||||
|
|
||||||
load_favicon();
|
load_favicon();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue