mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 17:40:27 +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
Notes:
sideshowbarker
2024-07-18 00:54:03 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/8ef25989b6 Pull-request: https://github.com/SerenityOS/serenity/pull/19419
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…
Reference in a new issue