mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
LibWeb: Move remove_all_children() from Node to TreeNode<T>
This is useful in all tree types.
This commit is contained in:
parent
fe9de4b55c
commit
75829c1b81
Notes:
sideshowbarker
2024-07-19 00:03:39 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/75829c1b814
3 changed files with 9 additions and 8 deletions
|
@ -199,13 +199,6 @@ RefPtr<Node> Node::insert_before(NonnullRefPtr<Node> node, RefPtr<Node> child, b
|
|||
return node;
|
||||
}
|
||||
|
||||
void Node::remove_all_children()
|
||||
{
|
||||
while (RefPtr<Node> child = first_child()) {
|
||||
remove_child(*child);
|
||||
}
|
||||
}
|
||||
|
||||
void Node::set_document(Badge<Document>, Document& document)
|
||||
{
|
||||
if (m_document == &document)
|
||||
|
|
|
@ -82,7 +82,6 @@ public:
|
|||
|
||||
RefPtr<Node> append_child(NonnullRefPtr<Node>, bool notify = true);
|
||||
RefPtr<Node> insert_before(NonnullRefPtr<Node> node, RefPtr<Node> child, bool notify = true);
|
||||
void remove_all_children();
|
||||
|
||||
virtual RefPtr<Layout::Node> create_layout_node();
|
||||
|
||||
|
|
|
@ -104,6 +104,8 @@ public:
|
|||
void insert_before(NonnullRefPtr<T> node, RefPtr<T> child, bool notify = true);
|
||||
NonnullRefPtr<T> remove_child(NonnullRefPtr<T> 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<typename T>
|
||||
inline void TreeNode<T>::remove_all_children()
|
||||
{
|
||||
while (RefPtr<T> child = first_child())
|
||||
remove_child(child.release_nonnull());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline NonnullRefPtr<T> TreeNode<T>::remove_child(NonnullRefPtr<T> node)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue