ladybird/Libraries/LibHTML/Layout/LayoutBox.h
Andreas Kling 5a34225999 LibHTML: Implement basic tiled background image support
It's now possible to set a page background image via <body background>.
Also, HtmlView now officially handles rendering the body element's
background (color, image or both.) LayoutBox is responsible for all
other background rendering.

Note that it's not yet possible to use CSS background-image properties
directly, since we can't parse them yet. :^)
2019-10-19 11:49:46 +02:00

41 lines
1.1 KiB
C++

#pragma once
#include <LibHTML/Layout/LayoutNode.h>
class LayoutBox : public LayoutNodeWithStyleAndBoxModelMetrics {
public:
const Rect& rect() const { return m_rect; }
Rect& rect() { return m_rect; }
void set_rect(const Rect& rect) { m_rect = rect; }
int x() const { return rect().x(); }
int y() const { return rect().y(); }
int width() const { return rect().width(); }
int height() const { return rect().height(); }
Size size() const { return rect().size(); }
Point position() const { return rect().location(); }
virtual HitTestResult hit_test(const Point& position) const override;
virtual void set_needs_display() override;
bool is_body() const;
protected:
LayoutBox(const Node* node, NonnullRefPtr<StyleProperties> style)
: LayoutNodeWithStyleAndBoxModelMetrics(node, move(style))
{
}
virtual void render(RenderingContext&) override;
private:
virtual bool is_box() const override { return true; }
Rect m_rect;
};
template<>
inline bool is<LayoutBox>(const LayoutNode& node)
{
return node.is_box();
}