mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:17:44 +00:00
LibWeb: Parse identifiers last in parse_paint_value()
Previously, using an identifier color like `currentColor` would fail to parse, since we look at ident tokens (and reject unrecognised ones) before trying to parse colors.
This commit is contained in:
parent
a988241f3f
commit
8ef25989b6
1 changed files with 12 additions and 11 deletions
|
@ -4657,6 +4657,18 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_paint_value(TokenStream<ComponentValue
|
|||
{
|
||||
// `<paint> = none | <color> | <url> [none | <color>]? | context-fill | context-stroke`
|
||||
|
||||
if (auto color = TRY(parse_color_value(tokens.peek_token()))) {
|
||||
(void)tokens.next_token();
|
||||
return color;
|
||||
}
|
||||
|
||||
if (auto url = TRY(parse_url_value(tokens.peek_token(), AllowedDataUrlType::Image))) {
|
||||
// FIXME: Accept `[none | <color>]?`
|
||||
(void)tokens.next_token();
|
||||
return url;
|
||||
}
|
||||
|
||||
// NOTE: <color> also accepts identifiers, so we do this identifier check last.
|
||||
if (tokens.peek_token().is(Token::Type::Ident)) {
|
||||
auto maybe_ident = value_id_from_string(tokens.peek_token().token().ident());
|
||||
if (maybe_ident.has_value()) {
|
||||
|
@ -4671,17 +4683,6 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_paint_value(TokenStream<ComponentValue
|
|||
}
|
||||
}
|
||||
|
||||
if (auto color = TRY(parse_color_value(tokens.peek_token()))) {
|
||||
(void)tokens.next_token();
|
||||
return color;
|
||||
}
|
||||
|
||||
if (auto url = TRY(parse_url_value(tokens.peek_token(), AllowedDataUrlType::Image))) {
|
||||
// FIXME: Accept `[none | <color>]?`
|
||||
(void)tokens.next_token();
|
||||
return url;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue