blob: 3fbb8ab1db7e92dd3bde4ae40939ee822f858bcb (
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 <AK/HashMap.h>
#include <AK/NonnullRefPtr.h>
#include <LibHTML/CSS/StyleValue.h>
class Color;
class StyleProperties : public RefCounted<StyleProperties> {
public:
static NonnullRefPtr<StyleProperties> create() { return adopt(*new StyleProperties); }
template<typename Callback>
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<StyleValue> value);
Optional<NonnullRefPtr<StyleValue>> 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;
private:
HashMap<String, NonnullRefPtr<StyleValue>> m_property_values;
};
|