mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb: Add non-inclusive variants of subtree traversal
This commit is contained in:
parent
ca71ac484b
commit
e56c56128b
Notes:
sideshowbarker
2024-07-18 20:42:53 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/e56c56128b7 Pull-request: https://github.com/SerenityOS/serenity/pull/6158
1 changed files with 40 additions and 0 deletions
|
@ -191,6 +191,46 @@ public:
|
|||
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>
|
||||
void for_each_child(Callback callback) const
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue