diff --git a/Userland/Libraries/LibWeb/CSS/Angle.cpp b/Userland/Libraries/LibWeb/CSS/Angle.cpp index c20544c65d..3c1a533361 100644 --- a/Userland/Libraries/LibWeb/CSS/Angle.cpp +++ b/Userland/Libraries/LibWeb/CSS/Angle.cpp @@ -26,9 +26,9 @@ Angle Angle::percentage_of(Percentage const& percentage) const return Angle { percentage.as_fraction() * m_value, m_type }; } -ErrorOr Angle::to_string() const +String Angle::to_string() const { - return String::formatted("{}deg", to_degrees()); + return MUST(String::formatted("{}deg", to_degrees())); } double Angle::to_degrees() const diff --git a/Userland/Libraries/LibWeb/CSS/Angle.h b/Userland/Libraries/LibWeb/CSS/Angle.h index d400a95625..7602662ca8 100644 --- a/Userland/Libraries/LibWeb/CSS/Angle.h +++ b/Userland/Libraries/LibWeb/CSS/Angle.h @@ -26,7 +26,7 @@ public: static Angle make_degrees(double); Angle percentage_of(Percentage const&) const; - ErrorOr to_string() const; + String to_string() const; double to_degrees() const; double to_radians() const; @@ -64,6 +64,6 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::CSS::Angle const& angle) { - return Formatter::format(builder, TRY(angle.to_string())); + return Formatter::format(builder, angle.to_string()); } }; diff --git a/Userland/Libraries/LibWeb/CSS/CSSKeyframeRule.h b/Userland/Libraries/LibWeb/CSS/CSSKeyframeRule.h index 36d76a8f5c..35231c08c2 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSKeyframeRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSKeyframeRule.h @@ -31,7 +31,7 @@ public: DeprecatedString key_text() const { - return m_key.to_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string(); + return m_key.to_string().to_deprecated_string(); } void set_key_text(DeprecatedString const& key_text) diff --git a/Userland/Libraries/LibWeb/CSS/CalculatedOr.h b/Userland/Libraries/LibWeb/CSS/CalculatedOr.h index 75d8cfe8e0..8c863f4b42 100644 --- a/Userland/Libraries/LibWeb/CSS/CalculatedOr.h +++ b/Userland/Libraries/LibWeb/CSS/CalculatedOr.h @@ -58,10 +58,10 @@ public: }); } - ErrorOr to_string() const + String to_string() const { if (is_calculated()) - return m_value.template get>()->to_string(); + return MUST(m_value.template get>()->to_string()); return m_value.template get().to_string(); } @@ -119,7 +119,7 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::CSS::AngleOrCalculated const& calculated_or) { - return Formatter::format(builder, TRY(calculated_or.to_string())); + return Formatter::format(builder, calculated_or.to_string()); } }; @@ -127,7 +127,7 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::CSS::FrequencyOrCalculated const& calculated_or) { - return Formatter::format(builder, TRY(calculated_or.to_string())); + return Formatter::format(builder, calculated_or.to_string()); } }; @@ -135,7 +135,7 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::CSS::LengthOrCalculated const& calculated_or) { - return Formatter::format(builder, TRY(calculated_or.to_string())); + return Formatter::format(builder, calculated_or.to_string()); } }; @@ -143,7 +143,7 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::CSS::PercentageOrCalculated const& calculated_or) { - return Formatter::format(builder, TRY(calculated_or.to_string())); + return Formatter::format(builder, calculated_or.to_string()); } }; @@ -151,6 +151,6 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::CSS::TimeOrCalculated const& calculated_or) { - return Formatter::format(builder, TRY(calculated_or.to_string())); + return Formatter::format(builder, calculated_or.to_string()); } }; diff --git a/Userland/Libraries/LibWeb/CSS/Display.cpp b/Userland/Libraries/LibWeb/CSS/Display.cpp index b8370d7101..d71a37797e 100644 --- a/Userland/Libraries/LibWeb/CSS/Display.cpp +++ b/Userland/Libraries/LibWeb/CSS/Display.cpp @@ -8,98 +8,98 @@ namespace Web::CSS { -ErrorOr Display::to_string() const +String Display::to_string() const { StringBuilder builder; switch (m_type) { case Type::OutsideAndInside: switch (m_value.outside_inside.outside) { case Outside::Block: - TRY(builder.try_append("block"sv)); + builder.append("block"sv); break; case Outside::Inline: - TRY(builder.try_append("inline"sv)); + builder.append("inline"sv); break; case Outside::RunIn: - TRY(builder.try_append("run-in"sv)); + builder.append("run-in"sv); break; } - TRY(builder.try_append(' ')); + builder.append(' '); switch (m_value.outside_inside.inside) { case Inside::Flow: - TRY(builder.try_append("flow"sv)); + builder.append("flow"sv); break; case Inside::FlowRoot: - TRY(builder.try_append("flow-root"sv)); + builder.append("flow-root"sv); break; case Inside::Table: - TRY(builder.try_append("table"sv)); + builder.append("table"sv); break; case Inside::Flex: - TRY(builder.try_append("flex"sv)); + builder.append("flex"sv); break; case Inside::Grid: - TRY(builder.try_append("grid"sv)); + builder.append("grid"sv); break; case Inside::Ruby: - TRY(builder.try_append("ruby"sv)); + builder.append("ruby"sv); break; } if (m_value.outside_inside.list_item == ListItem::Yes) - TRY(builder.try_append(" list-item"sv)); + builder.append(" list-item"sv); break; case Type::Internal: switch (m_value.internal) { case Internal::TableRowGroup: - TRY(builder.try_append("table-row-group"sv)); + builder.append("table-row-group"sv); break; case Internal::TableHeaderGroup: - TRY(builder.try_append("table-header-group"sv)); + builder.append("table-header-group"sv); break; case Internal::TableFooterGroup: - TRY(builder.try_append("table-footer-group"sv)); + builder.append("table-footer-group"sv); break; case Internal::TableRow: - TRY(builder.try_append("table-row"sv)); + builder.append("table-row"sv); break; case Internal::TableCell: - TRY(builder.try_append("table-cell"sv)); + builder.append("table-cell"sv); break; case Internal::TableColumnGroup: - TRY(builder.try_append("table-column-group"sv)); + builder.append("table-column-group"sv); break; case Internal::TableColumn: - TRY(builder.try_append("table-column"sv)); + builder.append("table-column"sv); break; case Internal::TableCaption: - TRY(builder.try_append("table-caption"sv)); + builder.append("table-caption"sv); break; case Internal::RubyBase: - TRY(builder.try_append("ruby-base"sv)); + builder.append("ruby-base"sv); break; case Internal::RubyText: - TRY(builder.try_append("ruby-text"sv)); + builder.append("ruby-text"sv); break; case Internal::RubyBaseContainer: - TRY(builder.try_append("ruby-base-container"sv)); + builder.append("ruby-base-container"sv); break; case Internal::RubyTextContainer: - TRY(builder.try_append("ruby-text-container"sv)); + builder.append("ruby-text-container"sv); break; } break; case Type::Box: switch (m_value.box) { case Box::Contents: - TRY(builder.try_append("contents"sv)); + builder.append("contents"sv); break; case Box::None: - TRY(builder.try_append("none"sv)); + builder.append("none"sv); break; } break; }; - return builder.to_string(); + return MUST(builder.to_string()); } } diff --git a/Userland/Libraries/LibWeb/CSS/Display.h b/Userland/Libraries/LibWeb/CSS/Display.h index 4d94fedd84..24045f3982 100644 --- a/Userland/Libraries/LibWeb/CSS/Display.h +++ b/Userland/Libraries/LibWeb/CSS/Display.h @@ -16,7 +16,7 @@ public: Display() = default; ~Display() = default; - ErrorOr to_string() const; + String to_string() const; bool operator==(Display const& other) const { diff --git a/Userland/Libraries/LibWeb/CSS/Frequency.cpp b/Userland/Libraries/LibWeb/CSS/Frequency.cpp index df217f8c91..bcbe4fe07b 100644 --- a/Userland/Libraries/LibWeb/CSS/Frequency.cpp +++ b/Userland/Libraries/LibWeb/CSS/Frequency.cpp @@ -25,9 +25,9 @@ Frequency Frequency::percentage_of(Percentage const& percentage) const return Frequency { percentage.as_fraction() * m_value, m_type }; } -ErrorOr Frequency::to_string() const +String Frequency::to_string() const { - return String::formatted("{}hz", to_hertz()); + return MUST(String::formatted("{}hz", to_hertz())); } double Frequency::to_hertz() const diff --git a/Userland/Libraries/LibWeb/CSS/Frequency.h b/Userland/Libraries/LibWeb/CSS/Frequency.h index 14e4f97964..38587935bd 100644 --- a/Userland/Libraries/LibWeb/CSS/Frequency.h +++ b/Userland/Libraries/LibWeb/CSS/Frequency.h @@ -23,7 +23,7 @@ public: static Frequency make_hertz(double); Frequency percentage_of(Percentage const&) const; - ErrorOr to_string() const; + String to_string() const; double to_hertz() const; Type type() const { return m_type; } @@ -59,6 +59,6 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::CSS::Frequency const& frequency) { - return Formatter::format(builder, TRY(frequency.to_string())); + return Formatter::format(builder, frequency.to_string()); } }; diff --git a/Userland/Libraries/LibWeb/CSS/Length.cpp b/Userland/Libraries/LibWeb/CSS/Length.cpp index bc8c27a10d..b398e5784c 100644 --- a/Userland/Libraries/LibWeb/CSS/Length.cpp +++ b/Userland/Libraries/LibWeb/CSS/Length.cpp @@ -186,11 +186,11 @@ CSSPixels Length::to_px(Layout::Node const& layout_node) const return viewport_relative_length_to_px(viewport_rect); } -ErrorOr Length::to_string() const +String Length::to_string() const { if (is_auto()) return "auto"_string; - return String::formatted("{}{}", m_value, unit_name()); + return MUST(String::formatted("{}{}", m_value, unit_name())); } char const* Length::unit_name() const diff --git a/Userland/Libraries/LibWeb/CSS/Length.h b/Userland/Libraries/LibWeb/CSS/Length.h index 3c3d03d79a..aeadd1276c 100644 --- a/Userland/Libraries/LibWeb/CSS/Length.h +++ b/Userland/Libraries/LibWeb/CSS/Length.h @@ -203,7 +203,7 @@ public: } } - ErrorOr to_string() const; + String to_string() const; bool operator==(Length const& other) const { @@ -230,6 +230,6 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::CSS::Length const& length) { - return Formatter::format(builder, TRY(length.to_string())); + return Formatter::format(builder, length.to_string()); } }; diff --git a/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp b/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp index 3e4eea527b..48e4af96ce 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp +++ b/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp @@ -24,11 +24,11 @@ NonnullRefPtr MediaQuery::create_not_all() ErrorOr MediaFeatureValue::to_string() const { return m_value.visit( - [](ValueID const& ident) { return String::from_utf8(string_from_value_id(ident)); }, + [](ValueID const& ident) { return MUST(String::from_utf8(string_from_value_id(ident))); }, [](Length const& length) { return length.to_string(); }, [](Ratio const& ratio) { return ratio.to_string(); }, [](Resolution const& resolution) { return resolution.to_string(); }, - [](float number) { return String::number(number); }); + [](float number) { return MUST(String::number(number)); }); } bool MediaFeatureValue::is_same_type(MediaFeatureValue const& other) const diff --git a/Userland/Libraries/LibWeb/CSS/Number.h b/Userland/Libraries/LibWeb/CSS/Number.h index 832a7d95fc..84c37793a6 100644 --- a/Userland/Libraries/LibWeb/CSS/Number.h +++ b/Userland/Libraries/LibWeb/CSS/Number.h @@ -70,11 +70,11 @@ public: return { Type::Number, m_value / other.m_value }; } - ErrorOr to_string() const + String to_string() const { if (m_type == Type::IntegerWithExplicitSign) - return String::formatted("{:+}", m_value); - return String::number(m_value); + return MUST(String::formatted("{:+}", m_value)); + return MUST(String::number(m_value)); } bool operator==(Number const& other) const @@ -101,6 +101,6 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::CSS::Number const& number) { - return Formatter::format(builder, TRY(number.to_string())); + return Formatter::format(builder, number.to_string()); } }; diff --git a/Userland/Libraries/LibWeb/CSS/Percentage.h b/Userland/Libraries/LibWeb/CSS/Percentage.h index 5040515fec..fa2a88c1a5 100644 --- a/Userland/Libraries/LibWeb/CSS/Percentage.h +++ b/Userland/Libraries/LibWeb/CSS/Percentage.h @@ -26,9 +26,9 @@ public: double value() const { return m_value; } double as_fraction() const { return m_value * 0.01; } - ErrorOr to_string() const + String to_string() const { - return String::formatted("{}%", m_value); + return MUST(String::formatted("{}%", m_value)); } bool operator==(Percentage const& other) const { return m_value == other.m_value; } diff --git a/Userland/Libraries/LibWeb/CSS/PercentageOr.h b/Userland/Libraries/LibWeb/CSS/PercentageOr.h index 2e29be2096..8ca4e0276e 100644 --- a/Userland/Libraries/LibWeb/CSS/PercentageOr.h +++ b/Userland/Libraries/LibWeb/CSS/PercentageOr.h @@ -112,10 +112,10 @@ public: }); } - ErrorOr to_string() const + String to_string() const { if (is_calculated()) - return m_value.template get>()->to_string(); + return MUST(m_value.template get>()->to_string()); if (is_percentage()) return m_value.template get().to_string(); return m_value.template get().to_string(); @@ -218,7 +218,7 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::CSS::Percentage const& percentage) { - return Formatter::format(builder, TRY(percentage.to_string())); + return Formatter::format(builder, percentage.to_string()); } }; @@ -226,7 +226,7 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::CSS::AnglePercentage const& angle_percentage) { - return Formatter::format(builder, TRY(angle_percentage.to_string())); + return Formatter::format(builder, angle_percentage.to_string()); } }; @@ -234,7 +234,7 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::CSS::FrequencyPercentage const& frequency_percentage) { - return Formatter::format(builder, TRY(frequency_percentage.to_string())); + return Formatter::format(builder, frequency_percentage.to_string()); } }; @@ -242,7 +242,7 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::CSS::LengthPercentage const& length_percentage) { - return Formatter::format(builder, TRY(length_percentage.to_string())); + return Formatter::format(builder, length_percentage.to_string()); } }; @@ -250,6 +250,6 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::CSS::TimePercentage const& time_percentage) { - return Formatter::format(builder, TRY(time_percentage.to_string())); + return Formatter::format(builder, time_percentage.to_string()); } }; diff --git a/Userland/Libraries/LibWeb/CSS/Position.cpp b/Userland/Libraries/LibWeb/CSS/Position.cpp index 8e8c7d32db..128d62ccac 100644 --- a/Userland/Libraries/LibWeb/CSS/Position.cpp +++ b/Userland/Libraries/LibWeb/CSS/Position.cpp @@ -56,15 +56,15 @@ CSSPixelPoint PositionValue::resolved(Layout::Node const& node, CSSPixelRect con return CSSPixelPoint { rect.x() + x, rect.y() + y }; } -ErrorOr PositionValue::serialize(StringBuilder& builder) const +void PositionValue::serialize(StringBuilder& builder) const { // Note: This means our serialization with simplify any with explicit edges that are just `top left`. bool has_relative_edges = x_relative_to == HorizontalEdge::Right || y_relative_to == VerticalEdge::Bottom; if (has_relative_edges) - TRY(builder.try_append(x_relative_to == HorizontalEdge::Left ? "left "sv : "right "sv)); - TRY(horizontal_position.visit( - [&](HorizontalPreset preset) -> ErrorOr { - return builder.try_append([&] { + builder.append(x_relative_to == HorizontalEdge::Left ? "left "sv : "right "sv); + horizontal_position.visit( + [&](HorizontalPreset preset) { + builder.append([&] { switch (preset) { case HorizontalPreset::Left: return "left"sv; @@ -77,15 +77,15 @@ ErrorOr PositionValue::serialize(StringBuilder& builder) const } }()); }, - [&](LengthPercentage length_percentage) -> ErrorOr { - return builder.try_appendff(TRY(length_percentage.to_string())); - })); - TRY(builder.try_append(' ')); + [&](LengthPercentage length_percentage) { + builder.append(length_percentage.to_string()); + }); + builder.append(' '); if (has_relative_edges) - TRY(builder.try_append(y_relative_to == VerticalEdge::Top ? "top "sv : "bottom "sv)); - TRY(vertical_position.visit( - [&](VerticalPreset preset) -> ErrorOr { - return builder.try_append([&] { + builder.append(y_relative_to == VerticalEdge::Top ? "top "sv : "bottom "sv); + vertical_position.visit( + [&](VerticalPreset preset) { + builder.append([&] { switch (preset) { case VerticalPreset::Top: return "top"sv; @@ -98,10 +98,9 @@ ErrorOr PositionValue::serialize(StringBuilder& builder) const } }()); }, - [&](LengthPercentage length_percentage) -> ErrorOr { - return builder.try_append(TRY(length_percentage.to_string())); - })); - return {}; + [&](LengthPercentage length_percentage) { + builder.append(length_percentage.to_string()); + }); } } diff --git a/Userland/Libraries/LibWeb/CSS/Position.h b/Userland/Libraries/LibWeb/CSS/Position.h index 321d967e8a..a494a71d08 100644 --- a/Userland/Libraries/LibWeb/CSS/Position.h +++ b/Userland/Libraries/LibWeb/CSS/Position.h @@ -46,7 +46,7 @@ struct PositionValue { VerticalEdge y_relative_to { VerticalEdge::Top }; CSSPixelPoint resolved(Layout::Node const& node, CSSPixelRect const& rect) const; - ErrorOr serialize(StringBuilder&) const; + void serialize(StringBuilder&) const; bool operator==(PositionValue const&) const = default; }; diff --git a/Userland/Libraries/LibWeb/CSS/Ratio.cpp b/Userland/Libraries/LibWeb/CSS/Ratio.cpp index 1895237ca4..7b8c54c94f 100644 --- a/Userland/Libraries/LibWeb/CSS/Ratio.cpp +++ b/Userland/Libraries/LibWeb/CSS/Ratio.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Sam Atkins + * Copyright (c) 2022-2023, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ @@ -22,9 +22,9 @@ bool Ratio::is_degenerate() const || !isfinite(m_second_value) || m_second_value == 0; } -ErrorOr Ratio::to_string() const +String Ratio::to_string() const { - return String::formatted("{} / {}", m_first_value, m_second_value); + return MUST(String::formatted("{} / {}", m_first_value, m_second_value)); } } diff --git a/Userland/Libraries/LibWeb/CSS/Ratio.h b/Userland/Libraries/LibWeb/CSS/Ratio.h index b6f5c627dd..3d77f09e60 100644 --- a/Userland/Libraries/LibWeb/CSS/Ratio.h +++ b/Userland/Libraries/LibWeb/CSS/Ratio.h @@ -17,7 +17,7 @@ public: double value() const { return m_first_value / m_second_value; } bool is_degenerate() const; - ErrorOr to_string() const; + String to_string() const; bool operator==(Ratio const& other) const { diff --git a/Userland/Libraries/LibWeb/CSS/Resolution.cpp b/Userland/Libraries/LibWeb/CSS/Resolution.cpp index f1912fd4f1..1af4072de2 100644 --- a/Userland/Libraries/LibWeb/CSS/Resolution.cpp +++ b/Userland/Libraries/LibWeb/CSS/Resolution.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Sam Atkins + * Copyright (c) 2022-2023, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ @@ -14,9 +14,9 @@ Resolution::Resolution(double value, Type type) { } -ErrorOr Resolution::to_string() const +String Resolution::to_string() const { - return String::formatted("{}dppx", to_dots_per_pixel()); + return MUST(String::formatted("{}dppx", to_dots_per_pixel())); } double Resolution::to_dots_per_pixel() const diff --git a/Userland/Libraries/LibWeb/CSS/Resolution.h b/Userland/Libraries/LibWeb/CSS/Resolution.h index 8daf32721f..31649476e7 100644 --- a/Userland/Libraries/LibWeb/CSS/Resolution.h +++ b/Userland/Libraries/LibWeb/CSS/Resolution.h @@ -23,7 +23,7 @@ public: Resolution(double value, Type type); - ErrorOr to_string() const; + String to_string() const; double to_dots_per_pixel() const; bool operator==(Resolution const& other) const diff --git a/Userland/Libraries/LibWeb/CSS/Serialize.cpp b/Userland/Libraries/LibWeb/CSS/Serialize.cpp index b2dcb2f292..6fa24e4ebd 100644 --- a/Userland/Libraries/LibWeb/CSS/Serialize.cpp +++ b/Userland/Libraries/LibWeb/CSS/Serialize.cpp @@ -131,7 +131,7 @@ void serialize_a_local(StringBuilder& builder, StringView path) void serialize_unicode_ranges(StringBuilder& builder, Vector const& unicode_ranges) { serialize_a_comma_separated_list(builder, unicode_ranges, [](auto& builder, UnicodeRange unicode_range) -> void { - return serialize_a_string(builder, MUST(unicode_range.to_string())); + return serialize_a_string(builder, unicode_range.to_string()); }); } diff --git a/Userland/Libraries/LibWeb/CSS/Size.cpp b/Userland/Libraries/LibWeb/CSS/Size.cpp index 53ccb60f97..e7b828303c 100644 --- a/Userland/Libraries/LibWeb/CSS/Size.cpp +++ b/Userland/Libraries/LibWeb/CSS/Size.cpp @@ -88,7 +88,7 @@ bool Size::contains_percentage() const } } -ErrorOr Size::to_string() const +String Size::to_string() const { switch (m_type) { case Type::Auto: @@ -102,7 +102,7 @@ ErrorOr Size::to_string() const case Type::MaxContent: return "max-content"_string; case Type::FitContent: - return String::formatted("fit-content({})", TRY(m_length_percentage.to_string())); + return MUST(String::formatted("fit-content({})", m_length_percentage.to_string())); case Type::None: return "none"_string; } diff --git a/Userland/Libraries/LibWeb/CSS/Size.h b/Userland/Libraries/LibWeb/CSS/Size.h index 59fe05809d..87b04eb3d6 100644 --- a/Userland/Libraries/LibWeb/CSS/Size.h +++ b/Userland/Libraries/LibWeb/CSS/Size.h @@ -76,7 +76,7 @@ public: return m_length_percentage.length(); } - ErrorOr to_string() const; + String to_string() const; private: Size(Type type, LengthPercentage); @@ -91,6 +91,6 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::CSS::Size const& size) { - return Formatter::format(builder, TRY(size.to_string())); + return Formatter::format(builder, size.to_string()); } }; diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/AbstractImageStyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValues/AbstractImageStyleValue.h index 79777124cd..90e8e632b5 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/AbstractImageStyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/AbstractImageStyleValue.h @@ -67,12 +67,12 @@ static ErrorOr serialize_color_stop_list(StringBuilder& builder, auto cons TRY(builder.try_append(", "sv)); if (element.transition_hint.has_value()) - TRY(builder.try_appendff("{}, "sv, TRY(element.transition_hint->value.to_string()))); + TRY(builder.try_appendff("{}, "sv, element.transition_hint->value.to_string())); TRY(builder.try_append(TRY(element.color_stop.color->to_string()))); for (auto position : Array { &element.color_stop.position, &element.color_stop.second_position }) { if (position->has_value()) - TRY(builder.try_appendff(" {}"sv, TRY((*position)->to_string()))); + TRY(builder.try_appendff(" {}"sv, (*position)->to_string())); } first = false; } diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.cpp index e43c193c9d..cb4b1d63db 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.cpp @@ -20,7 +20,7 @@ BackgroundSizeStyleValue::~BackgroundSizeStyleValue() = default; ErrorOr BackgroundSizeStyleValue::to_string() const { - return String::formatted("{} {}", TRY(m_properties.size_x.to_string()), TRY(m_properties.size_y.to_string())); + return String::formatted("{} {}", m_properties.size_x.to_string(), m_properties.size_y.to_string()); } } diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusShorthandStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusShorthandStyleValue.cpp index 201f26a6b0..a6d32450c8 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusShorthandStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusShorthandStyleValue.cpp @@ -13,7 +13,15 @@ namespace Web::CSS { ErrorOr BorderRadiusShorthandStyleValue::to_string() const { - return String::formatted("{} {} {} {} / {} {} {} {}", TRY(m_properties.top_left->horizontal_radius().to_string()), TRY(m_properties.top_right->horizontal_radius().to_string()), TRY(m_properties.bottom_right->horizontal_radius().to_string()), TRY(m_properties.bottom_left->horizontal_radius().to_string()), TRY(m_properties.top_left->vertical_radius().to_string()), TRY(m_properties.top_right->vertical_radius().to_string()), TRY(m_properties.bottom_right->vertical_radius().to_string()), TRY(m_properties.bottom_left->vertical_radius().to_string())); + return String::formatted("{} {} {} {} / {} {} {} {}", + m_properties.top_left->horizontal_radius().to_string(), + m_properties.top_right->horizontal_radius().to_string(), + m_properties.bottom_right->horizontal_radius().to_string(), + m_properties.bottom_left->horizontal_radius().to_string(), + m_properties.top_left->vertical_radius().to_string(), + m_properties.top_right->vertical_radius().to_string(), + m_properties.bottom_right->vertical_radius().to_string(), + m_properties.bottom_left->vertical_radius().to_string()); } } diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.cpp index 0ade945a95..819390dca1 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.cpp @@ -15,7 +15,7 @@ ErrorOr BorderRadiusStyleValue::to_string() const { if (m_properties.horizontal_radius == m_properties.vertical_radius) return m_properties.horizontal_radius.to_string(); - return String::formatted("{} / {}", TRY(m_properties.horizontal_radius.to_string()), TRY(m_properties.vertical_radius.to_string())); + return String::formatted("{} / {}", m_properties.horizontal_radius.to_string(), m_properties.vertical_radius.to_string()); } ValueComparingNonnullRefPtr BorderRadiusStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp index 41cf50585c..45f8479840 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp @@ -208,7 +208,7 @@ CalculatedStyleValue::CalculationResult NumericCalculationNode::resolve(Optional ErrorOr NumericCalculationNode::dump(StringBuilder& builder, int indent) const { - return builder.try_appendff("{: >{}}NUMERIC({})\n", "", indent, TRY(m_value.visit([](auto& it) { return it.to_string(); }))); + return builder.try_appendff("{: >{}}NUMERIC({})\n", "", indent, m_value.visit([](auto& it) { return it.to_string(); })); } NonnullOwnPtr SumCalculationNode::create(Vector> values) diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/ConicGradientStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/ConicGradientStyleValue.cpp index a685a90f15..2b9848da93 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/ConicGradientStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/ConicGradientStyleValue.cpp @@ -21,12 +21,12 @@ ErrorOr ConicGradientStyleValue::to_string() const bool has_from_angle = false; bool has_at_position = false; if ((has_from_angle = m_properties.from_angle.to_degrees() != 0)) - TRY(builder.try_appendff("from {}", TRY(m_properties.from_angle.to_string()))); + TRY(builder.try_appendff("from {}", m_properties.from_angle.to_string())); if ((has_at_position = m_properties.position != PositionValue::center())) { if (has_from_angle) TRY(builder.try_append(' ')); TRY(builder.try_appendff("at "sv)); - TRY(m_properties.position.serialize(builder)); + m_properties.position.serialize(builder); } if (has_from_angle || has_at_position) TRY(builder.try_append(", "sv)); diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/EdgeStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/EdgeStyleValue.cpp index 2eed8db3db..1da444f5c4 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/EdgeStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/EdgeStyleValue.cpp @@ -24,7 +24,7 @@ ErrorOr EdgeStyleValue::to_string() const VERIFY_NOT_REACHED(); }; - return String::formatted("{} {}", to_string(m_properties.edge), TRY(m_properties.offset.to_string())); + return String::formatted("{} {}", to_string(m_properties.edge), m_properties.offset.to_string()); } } diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.cpp index 39eb069b31..c860cf7f9c 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.cpp @@ -65,14 +65,14 @@ ErrorOr FilterValueListStyleValue::to_string() const [&](Filter::Blur const& blur) -> ErrorOr { TRY(builder.try_append("blur("sv)); if (blur.radius.has_value()) - TRY(builder.try_append(TRY(blur.radius->to_string()))); + TRY(builder.try_append(blur.radius->to_string())); return {}; }, [&](Filter::DropShadow const& drop_shadow) -> ErrorOr { TRY(builder.try_appendff("drop-shadow({} {}"sv, drop_shadow.offset_x, drop_shadow.offset_y)); if (drop_shadow.radius.has_value()) - TRY(builder.try_appendff(" {}", TRY(drop_shadow.radius->to_string()))); + TRY(builder.try_appendff(" {}", drop_shadow.radius->to_string())); if (drop_shadow.color.has_value()) { TRY(builder.try_append(' ')); serialize_a_srgb_value(builder, *drop_shadow.color); @@ -84,7 +84,7 @@ ErrorOr FilterValueListStyleValue::to_string() const if (hue_rotate.angle.has_value()) { TRY(hue_rotate.angle->visit( [&](Angle const& angle) -> ErrorOr { - return builder.try_append(TRY(angle.to_string())); + return builder.try_append(angle.to_string()); }, [&](auto&) -> ErrorOr { return builder.try_append('0'); @@ -115,7 +115,7 @@ ErrorOr FilterValueListStyleValue::to_string() const } }())); if (color.amount.has_value()) - TRY(builder.try_append(TRY(color.amount->to_string()))); + TRY(builder.try_append(color.amount->to_string())); return {}; })); TRY(builder.try_append(')')); diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/LinearGradientStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/LinearGradientStyleValue.cpp index 0a1b244988..b4c4b61b8d 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/LinearGradientStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/LinearGradientStyleValue.cpp @@ -47,7 +47,7 @@ ErrorOr LinearGradientStyleValue::to_string() const return builder.try_appendff("{}{}, "sv, m_properties.gradient_type == GradientType::Standard ? "to "sv : ""sv, side_or_corner_to_string(side_or_corner)); }, [&](Angle const& angle) -> ErrorOr { - return builder.try_appendff("{}, "sv, TRY(angle.to_string())); + return builder.try_appendff("{}, "sv, angle.to_string()); })); TRY(serialize_color_stop_list(builder, m_properties.color_stop_list)); diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/RadialGradientStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/RadialGradientStyleValue.cpp index ad4337eeca..cfe174de42 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/RadialGradientStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/RadialGradientStyleValue.cpp @@ -38,15 +38,15 @@ ErrorOr RadialGradientStyleValue::to_string() const }()); }, [&](CircleSize const& circle_size) -> ErrorOr { - return builder.try_append(TRY(circle_size.radius.to_string())); + return builder.try_append(circle_size.radius.to_string()); }, [&](EllipseSize const& ellipse_size) -> ErrorOr { - return builder.try_appendff("{} {}", TRY(ellipse_size.radius_a.to_string()), TRY(ellipse_size.radius_b.to_string())); + return builder.try_appendff("{} {}", ellipse_size.radius_a.to_string(), ellipse_size.radius_b.to_string()); })); if (m_properties.position != PositionValue::center()) { TRY(builder.try_appendff(" at "sv)); - TRY(m_properties.position.serialize(builder)); + m_properties.position.serialize(builder); } TRY(builder.try_append(", "sv)); diff --git a/Userland/Libraries/LibWeb/CSS/Time.cpp b/Userland/Libraries/LibWeb/CSS/Time.cpp index 8f5ec30d84..c2d811bffc 100644 --- a/Userland/Libraries/LibWeb/CSS/Time.cpp +++ b/Userland/Libraries/LibWeb/CSS/Time.cpp @@ -25,9 +25,9 @@ Time Time::percentage_of(Percentage const& percentage) const return Time { percentage.as_fraction() * m_value, m_type }; } -ErrorOr Time::to_string() const +String Time::to_string() const { - return String::formatted("{}s", to_seconds()); + return MUST(String::formatted("{}s", to_seconds())); } double Time::to_seconds() const diff --git a/Userland/Libraries/LibWeb/CSS/Time.h b/Userland/Libraries/LibWeb/CSS/Time.h index 8fdad6c788..73e37cb732 100644 --- a/Userland/Libraries/LibWeb/CSS/Time.h +++ b/Userland/Libraries/LibWeb/CSS/Time.h @@ -24,7 +24,7 @@ public: static Time make_seconds(double); Time percentage_of(Percentage const&) const; - ErrorOr to_string() const; + String to_string() const; double to_milliseconds() const; double to_seconds() const; @@ -61,6 +61,6 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::CSS::Time const& time) { - return Formatter::format(builder, TRY(time.to_string())); + return Formatter::format(builder, time.to_string()); } }; diff --git a/Userland/Libraries/LibWeb/CSS/UnicodeRange.h b/Userland/Libraries/LibWeb/CSS/UnicodeRange.h index 76c829eae2..9c717775de 100644 --- a/Userland/Libraries/LibWeb/CSS/UnicodeRange.h +++ b/Userland/Libraries/LibWeb/CSS/UnicodeRange.h @@ -29,11 +29,11 @@ public: return m_min_code_point <= code_point && code_point <= m_max_code_point; } - ErrorOr to_string() const + String to_string() const { if (m_min_code_point == m_max_code_point) - return String::formatted("U+{:x}", m_min_code_point); - return String::formatted("U+{:x}-{:x}", m_min_code_point, m_max_code_point); + return MUST(String::formatted("U+{:x}", m_min_code_point)); + return MUST(String::formatted("U+{:x}-{:x}", m_min_code_point, m_max_code_point)); } private: diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 05b085561f..432fc35511 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -352,7 +352,7 @@ JS::GCPtr Element::create_layout_node_for_display_type(DOM::Docume return document.heap().allocate_without_realm(document, element, move(style)); if (display.is_grid_inside()) return document.heap().allocate_without_realm(document, element, move(style)); - dbgln_if(LIBWEB_CSS_DEBUG, "FIXME: Support display: {}", MUST(display.to_string())); + dbgln_if(LIBWEB_CSS_DEBUG, "FIXME: Support display: {}", display.to_string()); return document.heap().allocate_without_realm(document, element, move(style)); } @@ -362,7 +362,7 @@ JS::GCPtr Element::create_layout_node_for_display_type(DOM::Docume if (display.is_flow_inside() || display.is_flow_root_inside() || display.is_contents()) return document.heap().allocate_without_realm(document, element, move(style)); - dbgln("FIXME: CSS display '{}' not implemented yet.", display.to_string().release_value_but_fixme_should_propagate_errors()); + dbgln("FIXME: CSS display '{}' not implemented yet.", display.to_string()); return document.heap().allocate_without_realm(document, element, move(style)); } diff --git a/Userland/Libraries/LibWeb/Dump.cpp b/Userland/Libraries/LibWeb/Dump.cpp index d646df8523..d90b4e09a7 100644 --- a/Userland/Libraries/LibWeb/Dump.cpp +++ b/Userland/Libraries/LibWeb/Dump.cpp @@ -661,7 +661,7 @@ void dump_font_face_rule(StringBuilder& builder, CSS::CSSFontFaceRule const& rul builder.append("unicode-ranges:\n"sv); for (auto const& unicode_range : font_face.unicode_ranges()) { indent(builder, indent_levels + 2); - builder.appendff("{}\n", unicode_range.to_string().release_value_but_fixme_should_propagate_errors()); + builder.appendff("{}\n", unicode_range.to_string()); } }