mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:07:35 +00:00
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.
This commit is contained in:
parent
402c6de5c9
commit
7912592f89
4 changed files with 26 additions and 5 deletions
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue