LibWeb: Convert callers of ImageCodecPlugin to the async API

The HTMLLinkElement caller is a bit hairy, so we shove an await() in
there temporarily. This is sure to cause fun times for anyone debugging
task/microtask execution order.
This commit is contained in:
Andrew Kaster 2024-04-19 15:55:54 -06:00 committed by Andrew Kaster
commit 651e78fedb
Notes: sideshowbarker 2024-07-17 05:58:46 +09:00
7 changed files with 78 additions and 71 deletions

View file

@ -182,11 +182,14 @@ WebIDL::ExceptionOr<void> HTMLVideoElement::determine_element_poster_frame(Optio
m_fetch_controller = nullptr;
// 6. If an image is thus obtained, the poster frame is that image. Otherwise, there is no poster frame.
auto image = Platform::ImageCodecPlugin::the().decode_image(image_data);
if (!image.has_value() || image->frames.is_empty())
return;
m_poster_frame = move(image.release_value().frames[0].bitmap);
(void)Platform::ImageCodecPlugin::the().decode_image(
image_data,
[strong_this = JS::Handle(*this)](Web::Platform::DecodedImage& image) -> ErrorOr<void> {
if (!image.frames.is_empty())
strong_this->m_poster_frame = move(image.frames[0].bitmap);
return {};
},
[](auto&) {});
});
VERIFY(response->body());