1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:17:44 +00:00

LibWeb: Use image's intrinsic dimensions when checking their usability

Instead of the rendered dimensions.
This commit is contained in:
Idan Horowitz 2022-03-05 17:08:28 +02:00 committed by Andreas Kling
parent d084f8d90a
commit 24cf56896b

View file

@ -604,10 +604,13 @@ DOM::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasImag
// HTMLOrSVGImageElement
[](HTMLImageElement const& image_element) -> DOM::ExceptionOr<Optional<CanvasImageSourceUsability>> {
// FIXME: If image's current request's state is broken, then throw an "InvalidStateError" DOMException.
// FIXME: If image is not fully decodable, then return bad.
// If image is not fully decodable, then return bad.
if (!image_element.bitmap())
return { CanvasImageSourceUsability::Bad };
// If image has an intrinsic width or intrinsic height (or both) equal to zero, then return bad.
if (image_element.width() == 0 || image_element.height() == 0)
if (image_element.bitmap()->width() == 0 || image_element.bitmap()->height() == 0)
return { CanvasImageSourceUsability::Bad };
return Optional<CanvasImageSourceUsability> {};
},