mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:28:12 +00:00
LibHTML: Add StyleProperties::string_or_fallback()
This is an utility to go with the existing length_or_fallback().
This commit is contained in:
parent
08d9883306
commit
08c751d130
2 changed files with 9 additions and 0 deletions
|
@ -20,3 +20,11 @@ Length StyleProperties::length_or_fallback(const StringView& property_name, cons
|
|||
return fallback;
|
||||
return value.value()->to_length();
|
||||
}
|
||||
|
||||
String StyleProperties::string_or_fallback(const StringView& property_name, const StringView& fallback) const
|
||||
{
|
||||
auto value = property(property_name);
|
||||
if (!value.has_value())
|
||||
return fallback;
|
||||
return value.value()->to_string();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ public:
|
|||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue