1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:38:12 +00:00

LibWeb: Parse double-position linear-gradient() color stops

The only accepted syntax for these seems to be
<color> <length percentage> <length percentage>, no other order.

But that's just gathered from looking at other browsers as though
these are supported by all major browsers, they don't appear in
the W3C spec.
This commit is contained in:
MacDue 2022-08-22 21:37:53 +01:00 committed by Andreas Kling
parent ec3d8a7a18
commit 3a1f8d714a
4 changed files with 30 additions and 22 deletions

View file

@ -1512,8 +1512,9 @@ String LinearGradientStyleValue::to_string() const
}
serialize_a_srgb_value(builder, element.color_stop.color);
if (element.color_stop.length.has_value()) {
builder.appendff(" {}"sv, element.color_stop.length->to_string());
for (auto position : Array { &element.color_stop.position, &element.color_stop.second_position }) {
if (position->has_value())
builder.appendff(" {}"sv, (*position)->to_string());
}
first = false;
}
@ -1537,7 +1538,7 @@ static bool operator==(GradientColorHint a, GradientColorHint b)
static bool operator==(GradientColorStop a, GradientColorStop b)
{
return a.color == b.color && a.length == b.length;
return a.color == b.color && a.position == b.position && a.second_position == b.second_position;
}
static bool operator==(ColorStopListElement a, ColorStopListElement b)