diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index e89805750a..bbd481d79e 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -2353,7 +2353,7 @@ CSSPixels StyleComputer::parent_or_root_element_line_height(DOM::Element const* return computed_values->line_height(viewport_rect(), parent_font_metrics, m_root_element_font_metrics); } -ErrorOr StyleComputer::absolutize_values(StyleProperties& style, DOM::Element const* element, Optional pseudo_element) const +void StyleComputer::absolutize_values(StyleProperties& style, DOM::Element const* element, Optional pseudo_element) const { auto parent_or_root_line_height = parent_or_root_element_line_height(element, pseudo_element); @@ -2385,9 +2385,8 @@ ErrorOr StyleComputer::absolutize_values(StyleProperties& style, DOM::Elem auto& value_slot = style.m_property_values[i]; if (!value_slot.has_value()) continue; - value_slot->style = TRY(value_slot->style->absolutized(viewport_rect(), font_metrics, m_root_element_font_metrics)); + value_slot->style = value_slot->style->absolutized(viewport_rect(), font_metrics, m_root_element_font_metrics); } - return {}; } enum class BoxTypeTransformation { @@ -2487,7 +2486,7 @@ NonnullRefPtr StyleComputer::create_document_style() const auto style = StyleProperties::create(); compute_font(style, nullptr, {}); compute_defaulted_values(style, nullptr, {}); - absolutize_values(style, nullptr, {}).release_value_but_fixme_should_propagate_errors(); + absolutize_values(style, nullptr, {}); style->set_property(CSS::PropertyID::Width, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect().width())), nullptr); style->set_property(CSS::PropertyID::Height, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect().height())), nullptr); style->set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::Block)), nullptr); @@ -2521,7 +2520,7 @@ ErrorOr> StyleComputer::compute_style_impl(DOM::Element& compute_font(style, &element, pseudo_element); // 3. Absolutize values, turning font/viewport relative lengths into absolute lengths - TRY(absolutize_values(style, &element, pseudo_element)); + absolutize_values(style, &element, pseudo_element); // 4. Default the values, applying inheritance and 'initial' as needed compute_defaulted_values(style, &element, pseudo_element); diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.h b/Userland/Libraries/LibWeb/CSS/StyleComputer.h index b3fe525de0..cf2a1c0f74 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.h +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.h @@ -148,7 +148,7 @@ private: RefPtr font_matching_algorithm(FontFaceKey const& key, float font_size_in_pt) const; void compute_font(StyleProperties&, DOM::Element const*, Optional) const; void compute_defaulted_values(StyleProperties&, DOM::Element const*, Optional) const; - ErrorOr absolutize_values(StyleProperties&, DOM::Element const*, Optional) const; + void absolutize_values(StyleProperties&, DOM::Element const*, Optional) const; void transform_box_type_if_needed(StyleProperties&, DOM::Element const&, Optional) const; void compute_defaulted_property_value(StyleProperties&, DOM::Element const*, CSS::PropertyID, Optional) const; diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp index 46f29588e0..f4f80dccb9 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -410,7 +410,7 @@ StyleValueList const& StyleValue::as_value_list() const return static_cast(*this); } -ErrorOr> StyleValue::absolutized(CSSPixelRect const&, Length::FontMetrics const&, Length::FontMetrics const&) const +ValueComparingNonnullRefPtr StyleValue::absolutized(CSSPixelRect const&, Length::FontMetrics const&, Length::FontMetrics const&) const { return *this; } diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index cf8181a44a..c921e8d1d2 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -323,7 +323,7 @@ public: bool has_auto() const; virtual bool has_color() const { return false; } - virtual ErrorOr> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const; + virtual ValueComparingNonnullRefPtr absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const; virtual Color to_color(Optional) const { return {}; } ValueID to_identifier() const; diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.cpp index 030849788b..0ade945a95 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.cpp @@ -18,7 +18,7 @@ ErrorOr BorderRadiusStyleValue::to_string() const return String::formatted("{} / {}", TRY(m_properties.horizontal_radius.to_string()), TRY(m_properties.vertical_radius.to_string())); } -ErrorOr> BorderRadiusStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const +ValueComparingNonnullRefPtr BorderRadiusStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const { if (m_properties.horizontal_radius.is_percentage() && m_properties.vertical_radius.is_percentage()) return *this; diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h index b5de4a3575..59f7a61834 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h @@ -38,7 +38,7 @@ private: { } - virtual ErrorOr> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override; + virtual ValueComparingNonnullRefPtr absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override; struct Properties { bool is_elliptical; diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/LengthStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/LengthStyleValue.cpp index 06a317b66d..4f20c72156 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/LengthStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/LengthStyleValue.cpp @@ -27,7 +27,7 @@ ValueComparingNonnullRefPtr LengthStyleValue::create(Length co return adopt_ref(*new (nothrow) LengthStyleValue(length)); } -ErrorOr> LengthStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const +ValueComparingNonnullRefPtr LengthStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const { if (auto length = m_length.absolutize(viewport_rect, font_metrics, root_font_metrics); length.has_value()) return LengthStyleValue::create(length.release_value()); diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/LengthStyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValues/LengthStyleValue.h index b2c615c37e..928bcb83ed 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/LengthStyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/LengthStyleValue.h @@ -21,7 +21,7 @@ public: Length const& length() const { return m_length; } virtual ErrorOr to_string() const override { return m_length.to_string(); } - virtual ErrorOr> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override; + virtual ValueComparingNonnullRefPtr absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override; bool properties_equal(LengthStyleValue const& other) const { return m_length == other.m_length; } diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.cpp index d6516f6a31..932983ec66 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.cpp @@ -20,12 +20,12 @@ ErrorOr ShadowStyleValue::to_string() const return builder.to_string(); } -ErrorOr> ShadowStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const +ValueComparingNonnullRefPtr ShadowStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const { - auto absolutized_offset_x = TRY(m_properties.offset_x->absolutized(viewport_rect, font_metrics, root_font_metrics)); - auto absolutized_offset_y = TRY(m_properties.offset_y->absolutized(viewport_rect, font_metrics, root_font_metrics)); - auto absolutized_blur_radius = TRY(m_properties.blur_radius->absolutized(viewport_rect, font_metrics, root_font_metrics)); - auto absolutized_spread_distance = TRY(m_properties.spread_distance->absolutized(viewport_rect, font_metrics, root_font_metrics)); + auto absolutized_offset_x = m_properties.offset_x->absolutized(viewport_rect, font_metrics, root_font_metrics); + auto absolutized_offset_y = m_properties.offset_y->absolutized(viewport_rect, font_metrics, root_font_metrics); + auto absolutized_blur_radius = m_properties.blur_radius->absolutized(viewport_rect, font_metrics, root_font_metrics); + auto absolutized_spread_distance = m_properties.spread_distance->absolutized(viewport_rect, font_metrics, root_font_metrics); return ShadowStyleValue::create(m_properties.color, absolutized_offset_x, absolutized_offset_y, absolutized_blur_radius, absolutized_spread_distance, m_properties.placement); } diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.h index b7a6a564c9..f90224549d 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/ShadowStyleValue.h @@ -65,7 +65,7 @@ private: { } - virtual ErrorOr> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override; + virtual ValueComparingNonnullRefPtr absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override; struct Properties { Color color;