mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb/CSS: Make CSSNumericType dump() infallible
This is a remnant of the tiny-OOM-propagation party.
This commit is contained in:
parent
9cbd08a330
commit
0d19007cb5
Notes:
github-actions[bot]
2024-12-21 17:15:32 +00:00
Author: https://github.com/AtkinsSJ
Commit: 0d19007cb5
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2966
3 changed files with 19 additions and 10 deletions
|
@ -479,21 +479,21 @@ bool CSSNumericType::matches_dimension() const
|
|||
return number_of_one_exponents == 0 || number_of_one_exponents == 1;
|
||||
}
|
||||
|
||||
ErrorOr<String> 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<BaseType>(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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <AK/Array.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibWeb/CSS/PropertyID.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
@ -93,7 +94,7 @@ public:
|
|||
|
||||
bool operator==(CSSNumericType const& other) const = default;
|
||||
|
||||
ErrorOr<String> 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<Web::CSS::CSSNumericType> : Formatter<StringView> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Web::CSS::CSSNumericType const& value)
|
||||
{
|
||||
return Formatter<StringView>::format(builder, value.dump());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -159,7 +159,7 @@ OwnPtr<CalculationNode> 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<CalculationNode> 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<CalculationNode> 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<CalculationNode> 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;
|
||||
}
|
||||
)~~~");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue