mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:37:34 +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
3 changed files with 9 additions and 8 deletions
|
@ -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
Add a link
Reference in a new issue