ladybird/Libraries/LibHTML/CSS/StyleProperties.h
Andreas Kling 847072c2b1 LibHTML: Respect the link color set via <body link>
The default style for "a" tags now has { color: -libhtml-link; }.
We implement this vendor-specific property by querying the containing
document for the appropriate link color.

Currently we only use the basic link color, but in the future this can
be extended to remember visited links, etc.
2019-10-06 10:25:08 +02:00

29 lines
993 B
C++

#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;
};