mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-29 21:57:18 +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());
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue