mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-03 22:59:33 +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
Notes:
sideshowbarker
2024-07-19 11:56:58 +09:00
Author: https://github.com/bugaevc
Commit: 08c751d130
Pull-request: https://github.com/SerenityOS/serenity/pull/609
Reviewed-by: https://github.com/awesomekling ✅
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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue