summaryrefslogtreecommitdiff
path: root/Libraries/LibHTML/DOM/ParentNode.h
blob: 9773cb31a26633edba87c7e4a7eb172e104dea3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#pragma once

#include <LibHTML/DOM/Node.h>

class ParentNode : public Node {
public:
    template<typename F> void for_each_child(F) const;
    template<typename F> void for_each_child(F);

protected:
    explicit ParentNode(NodeType type)
        : Node(type)
    {
    }
};

template<typename Callback>
inline void ParentNode::for_each_child(Callback callback) const
{
    for (auto* node = first_child(); node; node = node->next_sibling())
        callback(*node);
}

template<typename Callback>
inline void ParentNode::for_each_child(Callback callback)
{
    for (auto* node = first_child(); node; node = node->next_sibling())
        callback(*node);
}