diff --git a/Libraries/LibWeb/DOM/Node.cpp b/Libraries/LibWeb/DOM/Node.cpp index 55e062f4bc..f5dcc872ce 100644 --- a/Libraries/LibWeb/DOM/Node.cpp +++ b/Libraries/LibWeb/DOM/Node.cpp @@ -199,13 +199,6 @@ RefPtr Node::insert_before(NonnullRefPtr node, RefPtr child, b return node; } -void Node::remove_all_children() -{ - while (RefPtr child = first_child()) { - remove_child(*child); - } -} - void Node::set_document(Badge, Document& document) { if (m_document == &document) diff --git a/Libraries/LibWeb/DOM/Node.h b/Libraries/LibWeb/DOM/Node.h index 8103bbbff6..624b41b951 100644 --- a/Libraries/LibWeb/DOM/Node.h +++ b/Libraries/LibWeb/DOM/Node.h @@ -82,7 +82,6 @@ public: RefPtr append_child(NonnullRefPtr, bool notify = true); RefPtr insert_before(NonnullRefPtr node, RefPtr child, bool notify = true); - void remove_all_children(); virtual RefPtr create_layout_node(); diff --git a/Libraries/LibWeb/TreeNode.h b/Libraries/LibWeb/TreeNode.h index f198e4e231..1673a52dc5 100644 --- a/Libraries/LibWeb/TreeNode.h +++ b/Libraries/LibWeb/TreeNode.h @@ -104,6 +104,8 @@ public: void insert_before(NonnullRefPtr node, RefPtr child, bool notify = true); NonnullRefPtr remove_child(NonnullRefPtr node); + void remove_all_children(); + bool is_child_allowed(const T&) const { return true; } T* next_in_pre_order() @@ -312,6 +314,13 @@ private: T* m_previous_sibling { nullptr }; }; +template +inline void TreeNode::remove_all_children() +{ + while (RefPtr child = first_child()) + remove_child(child.release_nonnull()); +} + template inline NonnullRefPtr TreeNode::remove_child(NonnullRefPtr node) {