LibWeb: Do not send every decoded favicon to the UI process
If a page contains multiple <link rel="icon"> elements, we would send each of them to the UI process. We would then just use whichever was sent last as the favicon in the UI. We now only send the favicon that was chosen for the document. This will either be the largest icon decoded from a link element, or the singular fallback icon.
This commit is contained in:
parent
5f3ea017f5
commit
47b6f5e607
2 changed files with 10 additions and 9 deletions
|
|
@ -5014,8 +5014,12 @@ void Document::check_favicon_after_loading_link_resource()
|
|||
}
|
||||
}
|
||||
|
||||
if (!largest_icon)
|
||||
if (largest_icon) {
|
||||
if (auto navigable = this->navigable(); navigable && navigable->is_traversable())
|
||||
navigable->traversable_navigable()->page().client().page_did_change_favicon(*largest_icon);
|
||||
} else {
|
||||
dbgln_if(SPAM_DEBUG, "No favicon found to be used");
|
||||
}
|
||||
}
|
||||
|
||||
void Document::set_window(HTML::Window& window)
|
||||
|
|
|
|||
|
|
@ -948,9 +948,6 @@ static NonnullRefPtr<Core::Promise<NonnullRefPtr<Gfx::Bitmap const>>> decode_fav
|
|||
promise->reject(Error::from_string_view("Failed to get bitmap from SVG favicon"sv));
|
||||
return promise;
|
||||
}
|
||||
auto navigable = document->navigable();
|
||||
if (navigable && navigable->is_traversable())
|
||||
navigable->traversable_navigable()->page().client().page_did_change_favicon(decoded_frame->bitmap());
|
||||
|
||||
promise->resolve(decoded_frame->bitmap_ref());
|
||||
return promise;
|
||||
|
|
@ -965,10 +962,6 @@ static NonnullRefPtr<Core::Promise<NonnullRefPtr<Gfx::Bitmap const>>> decode_fav
|
|||
auto favicon_bitmap = decoded_image.frames[0].bitmap;
|
||||
dbgln_if(IMAGE_DECODER_DEBUG, "Decoded favicon, {}", favicon_bitmap->size());
|
||||
|
||||
auto navigable = document->navigable();
|
||||
if (navigable && navigable->is_traversable())
|
||||
navigable->traversable_navigable()->page().client().page_did_change_favicon(*favicon_bitmap);
|
||||
|
||||
promise->resolve(favicon_bitmap.release_nonnull());
|
||||
return {};
|
||||
};
|
||||
|
|
@ -1043,7 +1036,11 @@ void HTMLLinkElement::load_fallback_favicon_if_needed(GC::Ref<DOM::Document> doc
|
|||
auto global = GC::Ref { realm.global_object() };
|
||||
|
||||
auto process_body = GC::create_function(realm.heap(), [document, request](ByteBuffer body) {
|
||||
(void)decode_favicon(body, request->url(), document);
|
||||
decode_favicon(body, request->url(), document)
|
||||
->when_resolved(GC::weak_callback(*document, [](DOM::Document& document, NonnullRefPtr<Gfx::Bitmap const>& favicon) {
|
||||
if (auto navigable = document.navigable(); navigable && navigable->is_traversable())
|
||||
navigable->traversable_navigable()->page().client().page_did_change_favicon(*favicon);
|
||||
}));
|
||||
});
|
||||
auto process_body_error = GC::create_function(realm.heap(), [](JS::Value) {
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue