mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-26 09:59:43 +00:00
LibWeb: Do not drop favicon resolution callbacks
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Commit 77f6edaf71 tried to map the promise
returned from the ImageCodecPlugin to the same promise type used for SVG
decoding. However, `map` drops the existing resolution callbacks on the
floor.
Instead, let's keep the ImageCodecPlugin promise alone, and resolve the
returned promise explicitly.
This commit is contained in:
parent
e57176b484
commit
0cae8dd712
Notes:
github-actions[bot]
2025-10-11 07:13:48 +00:00
Author: https://github.com/trflynn89
Commit: 0cae8dd712
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6441
1 changed files with 9 additions and 5 deletions
|
|
@ -600,9 +600,10 @@ void HTMLLinkElement::resource_did_load_favicon()
|
|||
|
||||
static NonnullRefPtr<Core::Promise<bool>> decode_favicon(ReadonlyBytes favicon_data, URL::URL const& favicon_url, GC::Ref<DOM::Document> document)
|
||||
{
|
||||
auto promise = Core::Promise<bool>::construct();
|
||||
|
||||
if (favicon_url.basename().ends_with(".svg"sv)) {
|
||||
auto result = SVG::SVGDecodedImageData::create(document->realm(), document->page(), favicon_url, favicon_data);
|
||||
auto promise = Core::Promise<bool>::construct();
|
||||
if (result.is_error()) {
|
||||
promise->reject(Error::from_string_view("Failed to decode SVG favicon"sv));
|
||||
return promise;
|
||||
|
|
@ -623,11 +624,12 @@ static NonnullRefPtr<Core::Promise<bool>> decode_favicon(ReadonlyBytes favicon_d
|
|||
return promise;
|
||||
}
|
||||
|
||||
auto on_failed_decode = [favicon_url]([[maybe_unused]] Error& error) {
|
||||
auto on_failed_decode = [favicon_url, promise]([[maybe_unused]] Error& error) {
|
||||
dbgln_if(IMAGE_DECODER_DEBUG, "Failed to decode favicon {}: {}", favicon_url, error);
|
||||
promise->reject(move(error));
|
||||
};
|
||||
|
||||
auto on_successful_decode = [document = GC::Root(document)](Web::Platform::DecodedImage& decoded_image) -> ErrorOr<void> {
|
||||
auto on_successful_decode = [document = GC::Root(document), promise](Web::Platform::DecodedImage& decoded_image) -> ErrorOr<void> {
|
||||
auto favicon_bitmap = decoded_image.frames[0].bitmap;
|
||||
dbgln_if(IMAGE_DECODER_DEBUG, "Decoded favicon, {}", favicon_bitmap->size());
|
||||
|
||||
|
|
@ -635,11 +637,13 @@ static NonnullRefPtr<Core::Promise<bool>> decode_favicon(ReadonlyBytes favicon_d
|
|||
if (navigable && navigable->is_traversable())
|
||||
navigable->traversable_navigable()->page().client().page_did_change_favicon(*favicon_bitmap);
|
||||
|
||||
promise->resolve(true);
|
||||
return {};
|
||||
};
|
||||
|
||||
auto promise = Platform::ImageCodecPlugin::the().decode_image(favicon_data, move(on_successful_decode), move(on_failed_decode));
|
||||
return promise->map<bool>([](auto const&) { return true; });
|
||||
(void)Platform::ImageCodecPlugin::the().decode_image(favicon_data, move(on_successful_decode), move(on_failed_decode));
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
bool HTMLLinkElement::load_favicon_and_use_if_window_is_active()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue