ladybird/Libraries/LibHTML/CSS/StyleProperties.h
Sergey Bugaev 08c751d130 LibHTML: Add StyleProperties::string_or_fallback()
This is an utility to go with the existing length_or_fallback().
2019-09-28 18:29:42 +02:00

24 lines
749 B
C++

#pragma once
#include <AK/HashMap.h>
#include <AK/NonnullRefPtr.h>
#include <LibHTML/CSS/StyleValue.h>
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;
private:
HashMap<String, NonnullRefPtr<StyleValue>> m_property_values;
};