summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Libraries/LibWeb/CSS/Length.cpp12
-rw-r--r--Userland/Libraries/LibWeb/CSS/Length.h3
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleComputer.cpp4
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleProperties.cpp11
4 files changed, 12 insertions, 18 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Length.cpp b/Userland/Libraries/LibWeb/CSS/Length.cpp
index f74bebc9b2..b85657a567 100644
--- a/Userland/Libraries/LibWeb/CSS/Length.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Length.cpp
@@ -40,6 +40,13 @@ Length Length::make_px(float value)
return Length(value, Type::Px);
}
+Length Length::make_calculated(NonnullRefPtr<CalculatedStyleValue> calculated_style_value)
+{
+ Length length { 0, Type::Calculated };
+ length.m_calculated_style = move(calculated_style_value);
+ return length;
+}
+
Length Length::percentage_of(Percentage const& percentage) const
{
if (is_undefined_or_auto()) {
@@ -71,11 +78,6 @@ Length Length::resolved_or_zero(Layout::Node const& layout_node) const
return resolved(make_px(0), layout_node);
}
-void Length::set_calculated_style(CalculatedStyleValue* value)
-{
- m_calculated_style = value;
-}
-
float Length::relative_length_to_px(Gfx::IntRect const& viewport_rect, Gfx::FontMetrics const& font_metrics, float root_font_size) const
{
switch (m_type) {
diff --git a/Userland/Libraries/LibWeb/CSS/Length.h b/Userland/Libraries/LibWeb/CSS/Length.h
index 3f999b2f04..4087d52994 100644
--- a/Userland/Libraries/LibWeb/CSS/Length.h
+++ b/Userland/Libraries/LibWeb/CSS/Length.h
@@ -43,6 +43,7 @@ public:
static Length make_auto();
static Length make_px(float value);
+ static Length make_calculated(NonnullRefPtr<CalculatedStyleValue>);
Length percentage_of(Percentage const&) const;
Length resolved(Length const& fallback_for_undefined, Layout::Node const& layout_node) const;
@@ -131,8 +132,6 @@ public:
return !(*this == other);
}
- void set_calculated_style(CalculatedStyleValue* value);
-
float relative_length_to_px(Gfx::IntRect const& viewport_rect, Gfx::FontMetrics const& font_metrics, float root_font_size) const;
private:
diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
index c3974a186f..41325d09ea 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
@@ -773,9 +773,7 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele
maybe_length = font_size->to_length();
} else if (font_size->is_calculated()) {
- Length length = Length(0, Length::Type::Calculated);
- length.set_calculated_style(verify_cast<CalculatedStyleValue>(font_size.ptr()));
- maybe_length = length;
+ maybe_length = Length::make_calculated(font_size->as_calculated());
}
if (maybe_length.has_value()) {
// FIXME: Support font-size: calc(...)
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())