LibHTML: Add StyleProperties::string_or_fallback()

This is an utility to go with the existing length_or_fallback().
This commit is contained in:
Sergey Bugaev 2019-09-25 11:55:04 +03:00 committed by Andreas Kling
commit 08c751d130
Notes: sideshowbarker 2024-07-19 11:56:58 +09:00
2 changed files with 9 additions and 0 deletions

View file

@ -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();
}