summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-01-25 12:11:23 +0000
committerAndreas Kling <kling@serenityos.org>2022-02-04 13:52:02 +0100
commitce0a516e59ad6bb40e4ef2f9314471004b571ac8 (patch)
tree09588ce7e85f3eeb897d7266dcbb344d5fc4ec47 /Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
parentdb04b5687d4b15c4f51b3e30e386acb95c7221bd (diff)
downloadserenity-ce0a516e59ad6bb40e4ef2f9314471004b571ac8.zip
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. :^)
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/StyleProperties.cpp')
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleProperties.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
index e53e9c5b85..5a76672d0c 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
@@ -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())