#pragma once #include #include #include #include #include #include class Node; enum class Display { None, Block, Inline, }; class StyledNode : public TreeNode { public: static NonnullRefPtr create(const Node& node) { return adopt(*new StyledNode(&node)); } ~StyledNode(); const Node* node() const { return m_node; } template inline void for_each_child(Callback callback) const { for (auto* node = first_child(); node; node = node->next_sibling()) callback(*node); } template inline void for_each_child(Callback callback) { for (auto* node = first_child(); node; node = node->next_sibling()) callback(*node); } template inline void for_each_property(Callback callback) const { for (auto& it : m_property_values) callback(it.key, *it.value); } void set_property(const String& name, NonnullRefPtr value) { m_property_values.set(name, move(value)); } Optional> property(const String& name) const { auto it = m_property_values.find(name); if (it == m_property_values.end()) return {}; return it->value; } Display display() const; protected: explicit StyledNode(const Node*); private: const Node* m_node { nullptr }; HashMap> m_property_values; };