1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:37:35 +00:00

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
9 changed files with 84 additions and 88 deletions

View file

@ -15,7 +15,7 @@ class ImageBox final : public ReplacedBox {
JS_CELL(ImageBox, ReplacedBox);
public:
ImageBox(DOM::Document&, DOM::Element&, NonnullRefPtr<CSS::StyleProperties>, ImageLoader const&);
ImageBox(DOM::Document&, DOM::Element&, NonnullRefPtr<CSS::StyleProperties>, ImageProvider const&);
virtual ~ImageBox() override;
virtual void prepare_for_replaced_layout() override;
@ -26,15 +26,13 @@ public:
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
auto const& image_loader() const { return m_image_loader; }
auto const& image_provider() const { return m_image_provider; }
auto& image_provider() { return m_image_provider; }
void dom_node_did_update_alt_text(Badge<HTML::HTMLImageElement>);
private:
int preferred_width() const;
int preferred_height() const;
ImageLoader const& m_image_loader;
ImageProvider const& m_image_provider;
Optional<CSSPixels> m_cached_alt_text_width;
};