1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 01:44:58 +00:00

LibWeb: Make ImageBox ask ImageProvider for intrinsic size and ratio

This paves the way for ImageProvider to have something vector-based
underneath. :^)
This commit is contained in:
Andreas Kling 2023-05-20 16:27:31 +02:00
parent 4ee1e5b224
commit 8d3240d633
9 changed files with 71 additions and 18 deletions

View file

@ -350,6 +350,27 @@ i32 HTMLObjectElement::default_tab_index_value() const
return 0;
}
Optional<CSSPixels> HTMLObjectElement::intrinsic_width() const
{
if (m_image_loader.has_value())
return m_image_loader->bitmap(0)->width();
return {};
}
Optional<CSSPixels> HTMLObjectElement::intrinsic_height() const
{
if (m_image_loader.has_value())
return m_image_loader->bitmap(0)->height();
return {};
}
Optional<float> HTMLObjectElement::intrinsic_aspect_ratio() const
{
if (m_image_loader.has_value())
return static_cast<float>(m_image_loader->bitmap(0)->width()) / static_cast<float>(m_image_loader->bitmap(0)->height());
return {};
}
RefPtr<Gfx::Bitmap const> HTMLObjectElement::current_image_bitmap() const
{
if (m_image_loader.has_value())