summaryrefslogtreecommitdiff
path: root/LibHTML/Layout/LayoutNode.cpp
blob: 2e441bdfc123bff9762263c01387057fa8e803e9 (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
40
#include <LibHTML/Layout/LayoutNode.h>

LayoutNode::LayoutNode(const Node* node)
    : m_node(node)
{
}

LayoutNode::~LayoutNode()
{
}

void LayoutNode::retain()
{
    ASSERT(m_retain_count);
    ++m_retain_count;
}

void LayoutNode::release()
{
    ASSERT(m_retain_count);
    if (!--m_retain_count)
        delete this;
}

void LayoutNode::append_child(Retained<LayoutNode> node)
{
    if (m_last_child)
        m_last_child->set_next_sibling(node.ptr());
    node->m_parent_node = this;
    m_last_child = &node.leak_ref();
    if (!m_first_child)
        m_first_child = m_last_child;
}

void LayoutNode::layout()
{
    for_each_child([](auto& child) {
        child.layout();
    });
}