diff --git a/Libraries/LibWeb/CSS/CSSNumericType.cpp b/Libraries/LibWeb/CSS/CSSNumericType.cpp index b568e5192cd..883b2ccd8f7 100644 --- a/Libraries/LibWeb/CSS/CSSNumericType.cpp +++ b/Libraries/LibWeb/CSS/CSSNumericType.cpp @@ -479,21 +479,21 @@ bool CSSNumericType::matches_dimension() const return number_of_one_exponents == 0 || number_of_one_exponents == 1; } -ErrorOr CSSNumericType::dump() const +String CSSNumericType::dump() const { StringBuilder builder; - TRY(builder.try_appendff("{{ hint: {}", m_percent_hint.map([](auto base_type) { return base_type_name(base_type); }))); + builder.appendff("{{ hint: {}", m_percent_hint.map([](auto base_type) { return base_type_name(base_type); })); for (auto i = 0; i < to_underlying(BaseType::__Count); ++i) { auto base_type = static_cast(i); auto type_exponent = exponent(base_type); if (type_exponent.has_value()) - TRY(builder.try_appendff(", \"{}\" → {}", base_type_name(base_type), type_exponent.value())); + builder.appendff(", \"{}\" → {}", base_type_name(base_type), type_exponent.value()); } - TRY(builder.try_append(" }"sv)); - return builder.to_string(); + builder.append(" }"sv); + return builder.to_string_without_validation(); } } diff --git a/Libraries/LibWeb/CSS/CSSNumericType.h b/Libraries/LibWeb/CSS/CSSNumericType.h index b00a0de9c8a..680fb00dfb8 100644 --- a/Libraries/LibWeb/CSS/CSSNumericType.h +++ b/Libraries/LibWeb/CSS/CSSNumericType.h @@ -8,6 +8,7 @@ #include #include +#include #include namespace Web::CSS { @@ -93,7 +94,7 @@ public: bool operator==(CSSNumericType const& other) const = default; - ErrorOr dump() const; + String dump() const; private: bool contains_all_the_non_zero_entries_of_other_with_the_same_value(CSSNumericType const& other) const; @@ -112,3 +113,11 @@ private: }; } + +template<> +struct AK::Formatter : Formatter { + ErrorOr format(FormatBuilder& builder, Web::CSS::CSSNumericType const& value) + { + return Formatter::format(builder, value.dump()); + } +}; diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMathFunctions.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMathFunctions.cpp index 40b8bbf4300..4f240b69de7 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMathFunctions.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMathFunctions.cpp @@ -159,7 +159,7 @@ OwnPtr Parser::parse_math_function(PropertyID property_id, Func function_generator.set("type_check", generate_calculation_type_check("argument_type"sv, parameter_type_string)); function_generator.append(R"~~~( if (!(@type_check@)) { - dbgln_if(CSS_PARSER_DEBUG, "@name:lowercase@() argument #{} type ({}) is not an accepted type", parsed_arguments.size(), MUST(argument_type.dump())); + dbgln_if(CSS_PARSER_DEBUG, "@name:lowercase@() argument #{} type ({}) is not an accepted type", parsed_arguments.size(), argument_type.dump()); return nullptr; } @@ -167,7 +167,7 @@ OwnPtr Parser::parse_math_function(PropertyID property_id, Func determined_argument_type = move(argument_type); } else { if (determined_argument_type != argument_type) { - dbgln_if(CSS_PARSER_DEBUG, "@name:lowercase@() argument #{} type ({}) doesn't match type of previous arguments ({})", parsed_arguments.size(), MUST(argument_type.dump()), MUST(determined_argument_type.dump())); + dbgln_if(CSS_PARSER_DEBUG, "@name:lowercase@() argument #{} type ({}) doesn't match type of previous arguments ({})", parsed_arguments.size(), argument_type.dump(), determined_argument_type.dump()); return nullptr; } } @@ -287,7 +287,7 @@ OwnPtr Parser::parse_math_function(PropertyID property_id, Func auto argument_type_@parameter_index@ = maybe_argument_type_@parameter_index@.release_value(); if (!(@type_check@)) { - dbgln_if(CSS_PARSER_DEBUG, "@name:lowercase@() argument '@parameter_name@' type ({}) is not an accepted type", MUST(argument_type_@parameter_index@.dump())); + dbgln_if(CSS_PARSER_DEBUG, "@name:lowercase@() argument '@parameter_name@' type ({}) is not an accepted type", argument_type_@parameter_index@.dump()); return nullptr; } )~~~"); @@ -297,7 +297,7 @@ OwnPtr Parser::parse_math_function(PropertyID property_id, Func if (previous_parameter_type_string == parameter_type_string) { parameter_generator.append(R"~~~( if (argument_type_@parameter_index@ != previous_argument_type) { - dbgln_if(CSS_PARSER_DEBUG, "@name:lowercase@() argument '@parameter_name@' type ({}) doesn't match type of previous arguments ({})", MUST(argument_type_@parameter_index@.dump()), MUST(previous_argument_type.dump())); + dbgln_if(CSS_PARSER_DEBUG, "@name:lowercase@() argument '@parameter_name@' type ({}) doesn't match type of previous arguments ({})", argument_type_@parameter_index@.dump(), previous_argument_type.dump()); return nullptr; } )~~~");