summaryrefslogtreecommitdiff
path: root/Libraries/LibHTML/TreeNode.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-29 17:40:39 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-29 17:40:39 +0200
commit7912592f89420248f41133026118d9c26b2b0cfb (patch)
treeae8c5cc4b2b6c6f394e454abb34c5241fe1d2118 /Libraries/LibHTML/TreeNode.h
parent402c6de5c929abbb46672791cbef4505d5992c60 (diff)
downloadserenity-7912592f89420248f41133026118d9c26b2b0cfb.zip
LibHTML: Add inserted_into() and removed_from() TreeNode callbacks
These will be called when a Node or LayoutNode is inserted or removed from a tree. They get the parent node as an argument.
Diffstat (limited to 'Libraries/LibHTML/TreeNode.h')
-rw-r--r--Libraries/LibHTML/TreeNode.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/Libraries/LibHTML/TreeNode.h b/Libraries/LibHTML/TreeNode.h
index a4da2f1f9b..36459c5c77 100644
--- a/Libraries/LibHTML/TreeNode.h
+++ b/Libraries/LibHTML/TreeNode.h
@@ -33,7 +33,7 @@ public:
const T* first_child() const { return m_first_child; }
const T* last_child() const { return m_last_child; }
- void append_child(NonnullRefPtr<T> node);
+ void append_child(NonnullRefPtr<T> node, bool call_inserted_into = true);
void donate_all_children_to(T& node);
protected:
@@ -49,16 +49,19 @@ private:
};
template<typename T>
-inline void TreeNode<T>::append_child(NonnullRefPtr<T> node)
+inline void TreeNode<T>::append_child(NonnullRefPtr<T> node, bool call_inserted_into)
{
ASSERT(!node->m_parent);
if (m_last_child)
m_last_child->m_next_sibling = node.ptr();
node->m_previous_sibling = m_last_child;
node->m_parent = static_cast<T*>(this);
- m_last_child = &node.leak_ref();
+ m_last_child = node.ptr();
if (!m_first_child)
m_first_child = m_last_child;
+ if (call_inserted_into)
+ node->inserted_into(static_cast<T&>(*this));
+ (void)node.leak_ref();
}
template<typename T>