2019-06-15 18:55:47 +02:00
|
|
|
#pragma once
|
|
|
|
|
2019-06-15 23:41:15 +02:00
|
|
|
#include <LibHTML/DOM/Node.h>
|
2019-06-15 18:55:47 +02:00
|
|
|
|
|
|
|
class ParentNode : public Node {
|
|
|
|
public:
|
2019-06-15 22:49:44 +02:00
|
|
|
template<typename F> void for_each_child(F) const;
|
2019-06-15 18:55:47 +02:00
|
|
|
template<typename F> void for_each_child(F);
|
|
|
|
|
|
|
|
protected:
|
2019-09-29 11:43:07 +02:00
|
|
|
explicit ParentNode(Document& document, NodeType type)
|
|
|
|
: Node(document, type)
|
2019-06-15 18:55:47 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-06-15 22:49:44 +02:00
|
|
|
template<typename Callback>
|
|
|
|
inline void ParentNode::for_each_child(Callback callback) const
|
2019-06-15 18:55:47 +02:00
|
|
|
{
|
2019-06-15 22:49:44 +02:00
|
|
|
for (auto* node = first_child(); node; node = node->next_sibling())
|
|
|
|
callback(*node);
|
2019-06-15 18:55:47 +02:00
|
|
|
}
|
|
|
|
|
2019-06-15 22:49:44 +02:00
|
|
|
template<typename Callback>
|
|
|
|
inline void ParentNode::for_each_child(Callback callback)
|
|
|
|
{
|
|
|
|
for (auto* node = first_child(); node; node = node->next_sibling())
|
|
|
|
callback(*node);
|
|
|
|
}
|