From 6c409310a8615dfe8614386065d7e8975ac76499 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 24 May 2020 21:58:21 +0200 Subject: [PATCH] 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. --- Libraries/LibWeb/TreeNode.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Libraries/LibWeb/TreeNode.h b/Libraries/LibWeb/TreeNode.h index 5d96416b5b..30b7bbe83d 100644 --- a/Libraries/LibWeb/TreeNode.h +++ b/Libraries/LibWeb/TreeNode.h @@ -109,7 +109,7 @@ public: bool is_ancestor_of(const TreeNode&) const; void prepend_child(NonnullRefPtr node); - void append_child(NonnullRefPtr node); + void append_child(NonnullRefPtr node, bool notify = true); NonnullRefPtr remove_child(NonnullRefPtr 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 TreeNode::remove_child(NonnullRefPtr node) } template -inline void TreeNode::append_child(NonnullRefPtr node) +inline void TreeNode::append_child(NonnullRefPtr node, bool notify) { ASSERT(!node->m_parent); @@ -244,10 +244,12 @@ inline void TreeNode::append_child(NonnullRefPtr node) m_last_child = node.ptr(); if (!m_first_child) m_first_child = m_last_child; - node->inserted_into(static_cast(*this)); + if (notify) + node->inserted_into(static_cast(*this)); (void)node.leak_ref(); - static_cast(this)->children_changed(); + if (notify) + static_cast(this)->children_changed(); } template