1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:57:44 +00:00

LibWeb: Make StyleValue::to_string() infallible

This commit is contained in:
Sam Atkins 2023-08-22 14:08:15 +01:00 committed by Sam Atkins
parent ccfe197e5a
commit 7fe97ee6c5
112 changed files with 425 additions and 430 deletions

View file

@ -59,24 +59,23 @@ struct ColorStopListElement {
using LinearColorStopListElement = ColorStopListElement<LengthPercentage>;
using AngularColorStopListElement = ColorStopListElement<AnglePercentage>;
static ErrorOr<void> serialize_color_stop_list(StringBuilder& builder, auto const& color_stop_list)
static void serialize_color_stop_list(StringBuilder& builder, auto const& color_stop_list)
{
bool first = true;
for (auto const& element : color_stop_list) {
if (!first)
TRY(builder.try_append(", "sv));
builder.append(", "sv);
if (element.transition_hint.has_value())
TRY(builder.try_appendff("{}, "sv, element.transition_hint->value.to_string()));
builder.appendff("{}, "sv, element.transition_hint->value.to_string());
TRY(builder.try_append(TRY(element.color_stop.color->to_string())));
builder.append(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, (*position)->to_string()));
builder.appendff(" {}"sv, (*position)->to_string());
}
first = false;
}
return {};
}
}