ladybird/Libraries/LibHTML/CSS/StyleProperties.h
Andreas Kling 62cbaa74f3 LibHTML: Respect the CSS "color" property for text
Also remove the color values from the ComputedStyle object and get them
via StyleProperties instead.

At the moment, we only handle colors that Color::from_string() parses.
2019-09-28 22:57:46 +02:00

27 lines
847 B
C++

#pragma once
#include <AK/HashMap.h>
#include <AK/NonnullRefPtr.h>
#include <LibHTML/CSS/StyleValue.h>
class Color;
class StyleProperties {
public:
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, Color fallback) const;
private:
HashMap<String, NonnullRefPtr<StyleValue>> m_property_values;
};