1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:18:11 +00:00

LibWeb: Make computed flex-grow and flex-shrink always available

These values are not allowed to be absent (auto/none/etc) so we don't
need to use Optional<float> for them. This simplifies some things.
This commit is contained in:
Andreas Kling 2021-10-19 15:22:08 +02:00
parent 19eda59359
commit 07f15aa550
6 changed files with 32 additions and 40 deletions

View file

@ -194,25 +194,22 @@ Optional<CSS::FlexBasisData> StyleProperties::flex_basis() const
return {};
}
Optional<float> StyleProperties::flex_grow_factor() const
float StyleProperties::flex_grow() const
{
auto value = property(CSS::PropertyID::FlexGrow);
if (!value.has_value())
return {};
if (value.value()->has_number())
return value.value()->to_number();
return {};
if (!value.has_value() || !value.value()->has_number())
return 0;
return value.value()->to_number();
}
Optional<float> StyleProperties::flex_shrink_factor() const
float StyleProperties::flex_shrink() const
{
auto value = property(CSS::PropertyID::FlexShrink);
if (!value.has_value())
return {};
if (value.value()->has_number())
return value.value()->to_number();
return {};
if (!value.has_value() || !value.value()->has_number())
return 1;
return value.value()->to_number();
}
Optional<CSS::JustifyContent> StyleProperties::justify_content() const
{
auto value = property(CSS::PropertyID::JustifyContent);