LibWeb: Don't force HTMLImageElement to have a legacy ImageLoader

We achieve this by adding a new Layout::ImageProvider class and having
both HTMLImageElement and HTMLObjectElement inherit from it.

The HTML spec is vague on how object image loading should work, which
is why this first pass is focusing on image elements.
This commit is contained in:
Andreas Kling 2023-05-12 07:17:01 +02:00
parent 3cf73ca0b3
commit c648e24cff
Notes: sideshowbarker 2024-07-17 02:56:25 +09:00
9 changed files with 84 additions and 88 deletions

View file

@ -76,7 +76,7 @@ JS::GCPtr<Layout::Node> HTMLObjectElement::create_layout_node(NonnullRefPtr<CSS:
return nullptr;
case Representation::Image:
if (m_image_loader.has_value() && m_image_loader->has_image())
return heap().allocate_without_realm<Layout::ImageBox>(document(), *this, move(style), *m_image_loader);
return heap().allocate_without_realm<Layout::ImageBox>(document(), *this, move(style), *this);
break;
default:
break;
@ -350,4 +350,16 @@ i32 HTMLObjectElement::default_tab_index_value() const
return 0;
}
RefPtr<Gfx::Bitmap const> HTMLObjectElement::current_image_bitmap() const
{
if (m_image_loader.has_value())
return m_image_loader->bitmap(m_image_loader->current_frame_index());
return nullptr;
}
void HTMLObjectElement::set_visible_in_viewport(bool)
{
// FIXME: Loosen grip on image data when it's not visible, e.g via volatile memory.
}
}