ladybird/Libraries/LibHTML/DOM/HTMLImageElement.h
Andreas Kling 18fa662eb2 LibHTML: Use ImageLoader for <img> elements to defer bitmap decoding
We now wait until the pixels are actually needed before fully decoding
images in <img> elements.

This needs some more work and is currently a bit memory-wasteful since
we'll hang on to the raw image data forever.
2019-10-15 21:53:08 +02:00

30 lines
917 B
C++

#pragma once
#include <LibDraw/GraphicsBitmap.h>
#include <LibDraw/ImageLoader.h>
#include <LibHTML/DOM/HTMLElement.h>
class HTMLImageElement : public HTMLElement {
public:
HTMLImageElement(Document&, const String& tag_name);
virtual ~HTMLImageElement() override;
virtual void parse_attribute(const String& name, const String& value) override;
String alt() const { return attribute("alt"); }
String src() const { return attribute("src"); }
int preferred_width() const;
int preferred_height() const;
const GraphicsBitmap* bitmap() const;
const ImageLoader* image_loader() const { return m_image_loader; }
private:
void load_image(const String& src);
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) const override;
RefPtr<ImageLoader> m_image_loader;
mutable RefPtr<GraphicsBitmap> m_bitmap;
ByteBuffer m_image_data;
};