1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:37:35 +00:00

LibWeb: Replace Length::set_calculated_style() with ::make_calculated()

There's no need to modify the Length's calculated-value after creating
it, so let's make it immutable. :^)
This commit is contained in:
Sam Atkins 2022-01-25 12:11:23 +00:00 committed by Andreas Kling
parent db04b5687d
commit ce0a516e59
4 changed files with 12 additions and 18 deletions

View file

@ -54,11 +54,8 @@ Length StyleProperties::length_or_fallback(CSS::PropertyID id, Length const& fal
return fallback;
auto& value = maybe_value.value();
if (value->is_calculated()) {
Length length = Length(0, Length::Type::Calculated);
length.set_calculated_style(&value->as_calculated());
return length;
}
if (value->is_calculated())
return Length::make_calculated(value->as_calculated());
if (value->has_length())
return value->to_length();
@ -75,9 +72,7 @@ LengthPercentage StyleProperties::length_percentage_or_fallback(CSS::PropertyID
if (value->is_calculated()) {
// FIXME: Handle percentages here
Length length = Length(0, Length::Type::Calculated);
length.set_calculated_style(&value->as_calculated());
return length;
return Length::make_calculated(value->as_calculated());
}
if (value->is_percentage())