mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 19:47:42 +00:00
LibHTML: Add a simple TreeNode<T> template for making trees.
We'll be making a lot of trees here, so let's share code during bootstrap. Eventually some of these classes are gonna want custom trees but for now we can just fit them all into the same clothes.
This commit is contained in:
parent
e9b619c4aa
commit
8adae51b35
8 changed files with 68 additions and 109 deletions
|
@ -9,29 +9,6 @@ LayoutNode::~LayoutNode()
|
|||
{
|
||||
}
|
||||
|
||||
void LayoutNode::ref()
|
||||
{
|
||||
ASSERT(m_retain_count);
|
||||
++m_retain_count;
|
||||
}
|
||||
|
||||
void LayoutNode::deref()
|
||||
{
|
||||
ASSERT(m_retain_count);
|
||||
if (!--m_retain_count)
|
||||
delete this;
|
||||
}
|
||||
|
||||
void LayoutNode::append_child(NonnullRefPtr<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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue