diff --git a/Userland/Libraries/LibWeb/HTML/SharedImageRequest.cpp b/Userland/Libraries/LibWeb/HTML/SharedImageRequest.cpp index 7715175b6c2..50e7a33f507 100644 --- a/Userland/Libraries/LibWeb/HTML/SharedImageRequest.cpp +++ b/Userland/Libraries/LibWeb/HTML/SharedImageRequest.cpp @@ -145,14 +145,6 @@ void SharedImageRequest::handle_successful_fetch(URL::URL const& url_string, Str bool const is_svg_image = mime_type == "image/svg+xml"sv || url_string.basename().ends_with(".svg"sv); - auto handle_failed_decode = [strong_this = JS::Handle(*this)](Error&) -> void { - strong_this->m_state = State::Failed; - for (auto& callback : strong_this->m_callbacks) { - if (callback.on_fail) - callback.on_fail->function()(); - } - }; - auto handle_successful_decode = [](SharedImageRequest& self) { self.m_state = State::Finished; for (auto& callback : self.m_callbacks) { @@ -165,7 +157,7 @@ void SharedImageRequest::handle_successful_fetch(URL::URL const& url_string, Str if (is_svg_image) { auto result = SVG::SVGDecodedImageData::create(m_document->realm(), m_page, url_string, data); if (result.is_error()) { - handle_failed_decode(result.error()); + handle_failed_fetch(); } else { m_image_data = result.release_value(); handle_successful_decode(*this); @@ -186,6 +178,10 @@ void SharedImageRequest::handle_successful_fetch(URL::URL const& url_string, Str return {}; }; + auto handle_failed_decode = [strong_this = JS::Handle(*this)](Error&) -> void { + strong_this->handle_failed_fetch(); + }; + (void)Web::Platform::ImageCodecPlugin::the().decode_image(data.bytes(), move(handle_successful_bitmap_decode), move(handle_failed_decode)); }