#pragma once #include #include #include #include class Color; class StyleProperties : public RefCounted { public: static NonnullRefPtr create() { return adopt(*new StyleProperties); } 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); Optional> property(const String& name) const; Length length_or_fallback(const StringView& property_name, const Length& fallback) const; String string_or_fallback(const StringView& property_name, const StringView& fallback) const; Color color_or_fallback(const StringView& property_name, const Document&, Color fallback) const; const Font& font() const { if (!m_font) load_font(); return *m_font; } private: HashMap> m_property_values; void load_font() const; mutable RefPtr m_font; };