mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +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
Notes:
sideshowbarker
2024-07-19 11:38:21 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b3a63e1d503
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…
Reference in a new issue