LibWeb: Store CSS color name in CSSRGB

When serializing an sRGB color value that originated from a named color,
it should return the color name converted to ASCII lowercase. This
requires storing the color name (if it has one).

This change also requires explicitly removing the color names when
computing style, because computed color values do not retain their name.
It also requires removing a caching optimization in create_from_color(),
because adding the name means that the cached value might be wrong.

This fixes some WPT subtests, and also required updating some of our own
tests.
This commit is contained in:
Milo van der Tier 2024-11-24 18:47:15 +01:00 committed by Andreas Kling
commit 6bb8bf189f
Notes: github-actions[bot] 2024-11-25 10:52:53 +00:00
16 changed files with 133 additions and 69 deletions

View file

@ -3413,7 +3413,7 @@ RefPtr<CSSStyleValue> Parser::parse_color_value(TokenStream<ComponentValue>& tok
auto color = Color::from_string(ident);
if (color.has_value()) {
transaction.commit();
return CSSColorValue::create_from_color(color.release_value());
return CSSColorValue::create_from_color(color.release_value(), ident);
}
// Otherwise, fall through to the hashless-hex-color case
}