mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-18 14:09:42 +00:00
LibWeb: Use intrinsic size for current_image_bitmap
Currently, ImageProvider::current_image_bitmap takes a Gfx::IntSize argument which determines the size of the returned bitmap. The default value of this argument is 0x0 which causes the function to return nullptr. This behavior is evidently unintuitive enough that it has lead to incorrect usage in multiple places. For example, the 2D canvas drawImage method will never actually draw anything because it calls current_image_bitmap with no arguments. And the naturalWidth and naturalHeight of an image will always return 0 (even after the image has loaded) for the same reason. To correct this and hopefully avoid similar issues in the future, ImageProvider::current_image_bitmap will be renamed to current_image_bitmap_sized, and the default value for the size argument will be removed. For consistency, a similar change will be made to SVGImageElement::default_image_bitmap. The existing current_image_bitmap function will no longer take a size argument. Instead it will always return a bitmap of the image's intrinsic size. This seems to be what most existing callers had already assumed was the function's behavior.
This commit is contained in:
parent
0189553bed
commit
42339be999
Notes:
github-actions[bot]
2025-08-30 13:50:16 +00:00
Author: https://github.com/erik-kz
Commit: 42339be999
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6018
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/kalenikaliaksandr ✅
14 changed files with 35 additions and 27 deletions
|
@ -601,7 +601,7 @@ Optional<CSSPixelFraction> HTMLObjectElement::intrinsic_aspect_ratio() const
|
|||
return {};
|
||||
}
|
||||
|
||||
RefPtr<Gfx::ImmutableBitmap> HTMLObjectElement::current_image_bitmap(Gfx::IntSize size) const
|
||||
RefPtr<Gfx::ImmutableBitmap> HTMLObjectElement::current_image_bitmap_sized(Gfx::IntSize size) const
|
||||
{
|
||||
if (auto image_data = this->image_data())
|
||||
return image_data->bitmap(0, size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue