diff --git a/Userland/Libraries/LibWeb/TreeNode.h b/Userland/Libraries/LibWeb/TreeNode.h index c26ec46467..5494d71c24 100644 --- a/Userland/Libraries/LibWeb/TreeNode.h +++ b/Userland/Libraries/LibWeb/TreeNode.h @@ -99,10 +99,10 @@ public: bool is_ancestor_of(const TreeNode&) const; + void append_child(NonnullRefPtr node); void prepend_child(NonnullRefPtr node); - void append_child(NonnullRefPtr node, bool notify = true); - void insert_before(NonnullRefPtr node, RefPtr child, bool notify = true); - NonnullRefPtr remove_child(NonnullRefPtr node); + void insert_before(NonnullRefPtr node, RefPtr child); + void remove_child(NonnullRefPtr node); void remove_all_children(); @@ -332,8 +332,9 @@ inline void TreeNode::remove_all_children() remove_child(child.release_nonnull()); } + template -inline NonnullRefPtr TreeNode::remove_child(NonnullRefPtr node) +inline void TreeNode::remove_child(NonnullRefPtr node) { VERIFY(node->m_parent == this); @@ -353,17 +354,11 @@ inline NonnullRefPtr TreeNode::remove_child(NonnullRefPtr node) node->m_previous_sibling = nullptr; node->m_parent = nullptr; - node->removed_from(static_cast(*this)); - node->unref(); - - static_cast(this)->children_changed(); - - return node; } template -inline void TreeNode::append_child(NonnullRefPtr node, bool notify) +inline void TreeNode::append_child(NonnullRefPtr node) { VERIFY(!node->m_parent); @@ -377,26 +372,18 @@ inline void TreeNode::append_child(NonnullRefPtr node, bool notify) m_last_child = node.ptr(); if (!m_first_child) m_first_child = m_last_child; - if (notify) - node->inserted_into(static_cast(*this)); [[maybe_unused]] auto& rc = node.leak_ref(); - - if (notify) - static_cast(this)->children_changed(); } template -inline void TreeNode::insert_before(NonnullRefPtr node, RefPtr child, bool notify) +inline void TreeNode::insert_before(NonnullRefPtr node, RefPtr child) { if (!child) - return append_child(move(node), notify); + return append_child(move(node)); VERIFY(!node->m_parent); VERIFY(child->parent() == this); - if (!static_cast(this)->is_child_allowed(*node)) - return; - node->m_previous_sibling = child->m_previous_sibling; node->m_next_sibling = child; @@ -409,12 +396,7 @@ inline void TreeNode::insert_before(NonnullRefPtr node, RefPtr child, b child->m_previous_sibling = node; node->m_parent = static_cast(this); - if (notify) - node->inserted_into(static_cast(*this)); [[maybe_unused]] auto& rc = node.leak_ref(); - - if (notify) - static_cast(this)->children_changed(); } template