summaryrefslogtreecommitdiff
path: root/Libraries/LibHTML/Layout/LayoutBox.h
blob: f66be675719b87d5d4124a9d1c04aa71deb9fb52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#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;

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();
}