mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:27:45 +00:00
LibHTML: Add TreeNode<T>::for_each_in_subtree(callback)
This helper invokes a callback for the node and each of its descendants in pre-order.
This commit is contained in:
parent
8acc61f19a
commit
b3a63e1d50
1 changed files with 9 additions and 0 deletions
|
@ -53,6 +53,15 @@ public:
|
|||
|
||||
bool is_child_allowed(const T&) const { return true; }
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_in_subtree(Callback callback)
|
||||
{
|
||||
callback(static_cast<T&>(*this));
|
||||
for (auto* child = first_child(); child; child = child->next_sibling()) {
|
||||
child->for_each_in_subtree(callback);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
TreeNode() {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue