summaryrefslogtreecommitdiff
path: root/Libraries/LibHTML/DOM/ParentNode.h
blob: b563320819bacec5f5acd99298e100991a4d9ab9 (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(Document& document, NodeType type)
        : Node(document, 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);
}