mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:17:34 +00:00
LibWeb: Add non-inclusive variants of subtree traversal
This commit is contained in:
parent
ca71ac484b
commit
e56c56128b
1 changed files with 40 additions and 0 deletions
|
@ -191,6 +191,46 @@ public:
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Callback>
|
||||||
|
IterationDecision for_each_in_subtree(Callback callback) const
|
||||||
|
{
|
||||||
|
for (auto* child = first_child(); child; child = child->next_sibling()) {
|
||||||
|
if (child->for_each_in_inclusive_subtree(callback) == IterationDecision::Break)
|
||||||
|
return IterationDecision::Break;
|
||||||
|
}
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Callback>
|
||||||
|
IterationDecision for_each_in_subtree(Callback callback)
|
||||||
|
{
|
||||||
|
for (auto* child = first_child(); child; child = child->next_sibling()) {
|
||||||
|
if (child->for_each_in_inclusive_subtree(callback) == IterationDecision::Break)
|
||||||
|
return IterationDecision::Break;
|
||||||
|
}
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename U, typename Callback>
|
||||||
|
IterationDecision for_each_in_subtree_of_type(Callback callback)
|
||||||
|
{
|
||||||
|
for (auto* child = first_child(); child; child = child->next_sibling()) {
|
||||||
|
if (child->template for_each_in_inclusive_subtree_of_type<U>(callback) == IterationDecision::Break)
|
||||||
|
return IterationDecision::Break;
|
||||||
|
}
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename U, typename Callback>
|
||||||
|
IterationDecision for_each_in_subtree_of_type(Callback callback) const
|
||||||
|
{
|
||||||
|
for (auto* child = first_child(); child; child = child->next_sibling()) {
|
||||||
|
if (child->template for_each_in_inclusive_subtree_of_type<U>(callback) == IterationDecision::Break)
|
||||||
|
return IterationDecision::Break;
|
||||||
|
}
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
void for_each_child(Callback callback) const
|
void for_each_child(Callback callback) const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue