mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-04 09:14:21 +03:00
LibCore: Add CObject::for_each_child(callback).
This commit is contained in:
parent
3654c33c56
commit
906fde8f8c
Notes:
sideshowbarker
2024-07-19 13:55:29 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/906fde8f8c9
@ -100,9 +100,10 @@ void CObject::dump_tree(int indent)
|
||||
}
|
||||
printf("%s{%p}\n", class_name(), this);
|
||||
|
||||
for (auto* child : children()) {
|
||||
child->dump_tree(indent + 2);
|
||||
}
|
||||
for_each_child([&] (auto& child) {
|
||||
child.dump_tree(indent + 2);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
|
||||
void CObject::deferred_invoke(Function<void(CObject&)> invokee)
|
||||
|
@ -20,6 +20,15 @@ public:
|
||||
Vector<CObject*>& children() { return m_children; }
|
||||
const Vector<CObject*>& children() const { return m_children; }
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_child(Callback callback)
|
||||
{
|
||||
for (auto* child : m_children) {
|
||||
if (callback(*child) == IterationDecision::Abort)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CObject* parent() { return m_parent; }
|
||||
const CObject* parent() const { return m_parent; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user