LibWeb/CSS: Expose method for parsing a type of StyleValue

In a few places, user code wants to parse a `<color>` or `<length>` etc,
but we didn't have a way to do so, so they would do something
similar-ish instead, like parse the value of the `color` property.
Let's make that available instead.
This commit is contained in:
Sam Atkins 2025-11-13 14:04:00 +00:00
parent fd559341e3
commit 7aef3245ea
Notes: github-actions[bot] 2025-11-14 09:56:40 +00:00
3 changed files with 16 additions and 0 deletions

View file

@ -80,6 +80,13 @@ RefPtr<CSS::StyleValue const> parse_css_value(CSS::Parser::ParsingParams const&
return CSS::Parser::Parser::create(context, string).parse_as_css_value(property_id);
}
RefPtr<CSS::StyleValue const> parse_css_type(CSS::Parser::ParsingParams const& context, StringView string, CSS::ValueType value_type)
{
if (string.is_empty())
return nullptr;
return CSS::Parser::Parser::create(context, string).parse_as_type(value_type);
}
RefPtr<CSS::StyleValue const> parse_css_descriptor(CSS::Parser::ParsingParams const& parsing_params, CSS::AtRuleID at_rule_id, CSS::DescriptorID descriptor_id, StringView string)
{
if (string.is_empty())