1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:17:45 +00:00

LibWeb: Use Optional instead of undefined-lengths for widths/heights

This commit is contained in:
Sam Atkins 2022-02-18 15:10:11 +00:00 committed by Andreas Kling
parent 699b48ccc8
commit 5b2482a939
10 changed files with 126 additions and 92 deletions

View file

@ -64,10 +64,15 @@ Length StyleProperties::length_or_fallback(CSS::PropertyID id, Length const& fal
}
LengthPercentage StyleProperties::length_percentage_or_fallback(CSS::PropertyID id, LengthPercentage const& fallback) const
{
return length_percentage(id).value_or(fallback);
}
Optional<LengthPercentage> StyleProperties::length_percentage(CSS::PropertyID id) const
{
auto maybe_value = property(id);
if (!maybe_value.has_value())
return fallback;
return {};
auto& value = maybe_value.value();
if (value->is_calculated())
@ -79,7 +84,7 @@ LengthPercentage StyleProperties::length_percentage_or_fallback(CSS::PropertyID
if (value->has_length())
return value->to_length();
return fallback;
return {};
}
LengthBox StyleProperties::length_box(CSS::PropertyID left_id, CSS::PropertyID top_id, CSS::PropertyID right_id, CSS::PropertyID bottom_id, const CSS::Length& default_value) const