1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:37:35 +00:00

LibWeb: Allow HTMLObjectElement to convert a Resource to ImageResource

HTMLObjectElement, when implemented according to the spec, does not know
the resource type specified by the 'data' attribute until after it has
actually loaded (i.e. it may be an image, XML document, etc.). Currently
we always use ImageLoader within HTMLObjectElement to load the object,
but will need to use ResourceLoader instead to generically load data.

However, ImageLoader / ImageResource have image-specific functionality
that HTMLObjectElement still needs if the resource turns out to be an
image. This patch will allow (only) HTMLObjectElement to convert the
generic Resource to an ImageResource as needed.
This commit is contained in:
Timothy Flynn 2022-03-23 08:20:41 -04:00 committed by Andreas Kling
parent eb1d7e8076
commit 90829fe880
6 changed files with 36 additions and 0 deletions

View file

@ -10,11 +10,21 @@
namespace Web {
NonnullRefPtr<ImageResource> ImageResource::convert_from_resource(Resource& resource)
{
return adopt_ref(*new ImageResource(resource));
}
ImageResource::ImageResource(const LoadRequest& request)
: Resource(Type::Image, request)
{
}
ImageResource::ImageResource(Resource& resource)
: Resource(Type::Image, resource)
{
}
ImageResource::~ImageResource() = default;
int ImageResource::frame_duration(size_t frame_index) const