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

LibWeb: Split out image loading logic from HTMLImageElement

Since more DOM nodes are going to want to load images (<object>, ...)
this patch splits out the image loading logic into an ImageLoader class
and then HTMLImageElement simply has an ImageLoader.

LayoutImage is then given a const ImageLoader& at construction and can
then provide layout and rendering for many kinds of DOM nodes.
This commit is contained in:
Andreas Kling 2020-06-13 22:22:54 +02:00
parent d6d248c328
commit 95d70addd8
7 changed files with 246 additions and 101 deletions

View file

@ -35,19 +35,24 @@ class HTMLImageElement;
class LayoutImage : public LayoutReplaced {
public:
LayoutImage(const HTMLImageElement&, NonnullRefPtr<StyleProperties>);
LayoutImage(const Element&, NonnullRefPtr<StyleProperties>, const ImageLoader&);
virtual ~LayoutImage() override;
virtual void layout(LayoutMode = LayoutMode::Default) override;
virtual void render(RenderingContext&) override;
const HTMLImageElement& node() const { return static_cast<const HTMLImageElement&>(LayoutReplaced::node()); }
const Element& node() const { return static_cast<const Element&>(LayoutReplaced::node()); }
bool renders_as_alt_text() const;
private:
virtual const char* class_name() const override { return "LayoutImage"; }
virtual bool is_image() const override { return true; }
int preferred_width() const;
int preferred_height() const;
const ImageLoader& m_image_loader;
};
template<>