LibWeb/CSS: Store StyleValue pointer instead of string on CSSStyleValue

When setting style to a CSSStyleValue we need to convert it to a
StyleValue. If we already have one, we might as well use it avoid the
work of serialization and re-parsing.

I realised I misunderstood what "constructed from a USVString" means, so
I've adjusted based on that. It does raise a question on what the source
USVString is if that string resulted in multiple CSSStyleValues being
created - see the linked issue.
This commit is contained in:
Sam Atkins 2025-09-19 14:54:23 +01:00 committed by Andreas Kling
commit 2de4fe8104
Notes: github-actions[bot] 2025-10-04 20:58:33 +00:00
6 changed files with 40 additions and 24 deletions

View file

@ -13,7 +13,7 @@ namespace Web::CSS {
GC::Ref<CSSStyleValue> AbstractImageStyleValue::reify(JS::Realm& realm, FlyString const&) const
{
// AD-HOC: There's no spec description of how to reify as a CSSImageValue.
return CSSImageValue::create(realm, to_string(SerializationMode::Normal));
return CSSImageValue::create(realm, *this);
}
}