LibWeb: Add a getter for the default image bitmap of HTMLImageElement

The default image bitmap is the first frame for animated bitmaps, and
the only frame for non-animated bitmaps.
This commit is contained in:
Idan Horowitz 2025-08-03 20:46:16 +03:00 committed by Jelle Raaijmakers
commit cc0496284b
Notes: github-actions[bot] 2025-08-03 19:49:21 +00:00
2 changed files with 8 additions and 0 deletions

View file

@ -173,6 +173,13 @@ RefPtr<Gfx::ImmutableBitmap> HTMLImageElement::immutable_bitmap() const
return current_image_bitmap();
}
RefPtr<Gfx::ImmutableBitmap> HTMLImageElement::default_image_bitmap(Gfx::IntSize size) const
{
if (auto data = m_current_request->image_data())
return data->bitmap(0, size);
return nullptr;
}
bool HTMLImageElement::is_image_available() const
{
return m_current_request && m_current_request->is_available();