summaryrefslogtreecommitdiff
path: root/LibHTML/CSS/StyledNode.h
blob: eaf171e570b9e1a04c55967afe9c4a1620e84191 (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
30
31
32
33
34
35
36
37
#pragma once

#include <AK/HashMap.h>
#include <AK/NonnullRefPtr.h>
#include <AK/AKString.h>
#include <LibHTML/TreeNode.h>
#include <LibHTML/CSS/StyleValue.h>

class Node;

class StyledNode : public TreeNode<StyledNode> {
public:
    ~StyledNode();

    const Node* node() const { return m_node; }

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

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

protected:
    explicit StyledNode(const Node*);

private:
    const Node* m_node { nullptr };
    HashMap<String, NonnullRefPtr<StyleValue>> m_property_values;
};