ladybird/Libraries/LibHTML/DOM/HTMLImageElement.h
Andreas Kling 54bd322881 LibHTML: Mark image bitmaps outside the visible viewport as volatile
When the visible viewport rect changes, we walk the layout tree and
check where each LayoutImage is in relation to the viewport rect.
Images outside have their bitmaps marked as volatile.

Note that the bitmaps are managed by ImageDecoder objects. If a bitmap
is purged by the kernel while volatile, we construct a new ImageDecoder
next time we need pixels for the image.
2019-12-18 21:19:04 +01:00

33 lines
956 B
C++

#pragma once
#include <LibDraw/GraphicsBitmap.h>
#include <LibDraw/ImageDecoder.h>
#include <LibHTML/DOM/HTMLElement.h>
class LayoutDocument;
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 ImageDecoder* image_decoder() const { return m_image_decoder; }
void set_volatile(Badge<LayoutDocument>, bool);
private:
void load_image(const String& src);
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) const override;
RefPtr<ImageDecoder> m_image_decoder;
ByteBuffer m_encoded_data;
};