LibWeb: Make DecodedImageData an abstract class

The existing implementation moves down into a new subclass called
AnimatedBitmapDecodedImageData.

The purpose of this change is to create an extension point where we can
plug in an SVG renderer. :^)
This commit is contained in:
Andreas Kling 2023-05-20 16:11:36 +02:00
parent f7185dfa91
commit 4ee1e5b224
Notes: sideshowbarker 2024-07-17 02:05:41 +09:00
6 changed files with 108 additions and 61 deletions

View file

@ -14,8 +14,8 @@
#include <LibWeb/Fetch/Fetching/Fetching.h>
#include <LibWeb/Fetch/Infrastructure/FetchController.h>
#include <LibWeb/Fetch/Response.h>
#include <LibWeb/HTML/AnimatedBitmapDecodedImageData.h>
#include <LibWeb/HTML/CORSSettingAttribute.h>
#include <LibWeb/HTML/DecodedImageData.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/HTML/HTMLImageElement.h>
#include <LibWeb/HTML/HTMLLinkElement.h>
@ -530,15 +530,15 @@ void HTMLImageElement::handle_successful_fetch(AK::URL const& url_string, ImageR
return;
}
Vector<DecodedImageData::Frame> frames;
Vector<AnimatedBitmapDecodedImageData::Frame> frames;
for (auto& frame : result.value().frames) {
frames.append(DecodedImageData::Frame {
frames.append(AnimatedBitmapDecodedImageData::Frame {
.bitmap = frame.bitmap,
.duration = static_cast<int>(frame.duration),
});
}
auto image_data = DecodedImageData::create(move(frames), result.value().loop_count, result.value().is_animated).release_value_but_fixme_should_propagate_errors();
auto image_data = AnimatedBitmapDecodedImageData::create(move(frames), result.value().loop_count, result.value().is_animated).release_value_but_fixme_should_propagate_errors();
image_request.set_image_data(image_data);
ListOfAvailableImages::Key key;