LibWeb: Add a way to opt out of TreeNode::append_child() notifications

This will be used temporarily by the new HTML parser while we're
bringing it up.
This commit is contained in:
Andreas Kling 2020-05-24 21:58:21 +02:00
parent 5d332c1f11
commit 6c409310a8
Notes: sideshowbarker 2024-07-19 06:10:16 +09:00

View file

@ -109,7 +109,7 @@ public:
bool is_ancestor_of(const TreeNode&) const;
void prepend_child(NonnullRefPtr<T> node);
void append_child(NonnullRefPtr<T> node);
void append_child(NonnullRefPtr<T> node, bool notify = true);
NonnullRefPtr<T> remove_child(NonnullRefPtr<T> node);
void donate_all_children_to(T& node);
@ -188,7 +188,7 @@ public:
}
protected:
TreeNode() {}
TreeNode() { }
private:
int m_ref_count { 1 };
@ -230,7 +230,7 @@ inline NonnullRefPtr<T> TreeNode<T>::remove_child(NonnullRefPtr<T> node)
}
template<typename T>
inline void TreeNode<T>::append_child(NonnullRefPtr<T> node)
inline void TreeNode<T>::append_child(NonnullRefPtr<T> node, bool notify)
{
ASSERT(!node->m_parent);
@ -244,10 +244,12 @@ inline void TreeNode<T>::append_child(NonnullRefPtr<T> node)
m_last_child = node.ptr();
if (!m_first_child)
m_first_child = m_last_child;
node->inserted_into(static_cast<T&>(*this));
if (notify)
node->inserted_into(static_cast<T&>(*this));
(void)node.leak_ref();
static_cast<T*>(this)->children_changed();
if (notify)
static_cast<T*>(this)->children_changed();
}
template<typename T>