Ladybird: Simplify ImageCodecPluginLadybird a bit

No behavior change.
This commit is contained in:
Nico Weber 2023-06-01 21:07:55 -04:00 committed by Sam Atkins
parent c9b8af70bf
commit f3a58f3a5a

View file

@ -21,22 +21,15 @@ Optional<Web::Platform::DecodedImage> ImageCodecPluginLadybird::decode_image(Rea
return {};
}
bool had_errors = false;
Vector<Web::Platform::Frame> frames;
for (size_t i = 0; i < decoder->frame_count(); ++i) {
auto frame_or_error = decoder->frame(i);
if (frame_or_error.is_error()) {
frames.append({ {}, 0 });
had_errors = true;
} else {
auto frame = frame_or_error.release_value();
frames.append({ move(frame.image), static_cast<size_t>(frame.duration) });
}
if (frame_or_error.is_error())
return {};
auto frame = frame_or_error.release_value();
frames.append({ move(frame.image), static_cast<size_t>(frame.duration) });
}
if (had_errors)
return {};
return Web::Platform::DecodedImage {
decoder->is_animated(),
static_cast<u32>(decoder->loop_count()),