LibWeb: Support '<zero>' in '<color-stop-angle>`

`<color-stop-angle> = [ <angle-percentage> | <zero> ]{1,2}` but we were
previously parsing instead as `<angle-percentage>{1,2}`.
This commit is contained in:
Callum Law 2025-10-17 17:25:04 +13:00 committed by Tim Ledbetter
parent cc2c8e8615
commit cdbf4f49e1
Notes: github-actions[bot] 2025-10-17 07:38:48 +00:00
2 changed files with 15 additions and 5 deletions

View file

@ -126,7 +126,18 @@ Optional<Vector<AngularColorStopListElement>> Parser::parse_angular_color_stop_l
// <angular-color-stop> , [ <angular-color-hint>? , <angular-color-stop> ]# // <angular-color-stop> , [ <angular-color-hint>? , <angular-color-stop> ]#
return parse_color_stop_list<AngularColorStopListElement>( return parse_color_stop_list<AngularColorStopListElement>(
tokens, tokens,
[&](auto& it) { return parse_angle_percentage(it); }); [&](TokenStream<ComponentValue>& it) -> Optional<AnglePercentage> {
if (tokens.next_token().is(Token::Type::Number)) {
auto transaction = tokens.begin_transaction();
auto numeric_value = tokens.consume_a_token().token().number_value();
if (numeric_value == 0) {
transaction.commit();
return Angle::make_degrees(0);
}
}
return parse_angle_percentage(it);
});
} }
Optional<InterpolationMethod> Parser::parse_interpolation_method(TokenStream<ComponentValue>& tokens) Optional<InterpolationMethod> Parser::parse_interpolation_method(TokenStream<ComponentValue>& tokens)

View file

@ -2,8 +2,7 @@ Harness status: OK
Found 162 tests Found 162 tests
160 Pass 162 Pass
2 Fail
Pass linear-gradient() [ unparsable ] Pass linear-gradient() [ unparsable ]
Pass linear-gradient(black, 25%) [ unparsable ] Pass linear-gradient(black, 25%) [ unparsable ]
Pass linear-gradient(black, invalid) [ unparsable ] Pass linear-gradient(black, invalid) [ unparsable ]
@ -125,7 +124,7 @@ Pass conic-gradient(0%, black, white) [ unparsable ]
Pass conic-gradient(black) [ parsable ] Pass conic-gradient(black) [ parsable ]
Pass conic-gradient(black 0%) [ parsable ] Pass conic-gradient(black 0%) [ parsable ]
Pass conic-gradient(black, white) [ parsable ] Pass conic-gradient(black, white) [ parsable ]
Fail conic-gradient(black 0, white) [ parsable ] Pass conic-gradient(black 0, white) [ parsable ]
Pass conic-gradient(black 0%, white) [ parsable ] Pass conic-gradient(black 0%, white) [ parsable ]
Pass conic-gradient(black 0%, white 100%) [ parsable ] Pass conic-gradient(black 0%, white 100%) [ parsable ]
Pass conic-gradient(black, green, white) [ parsable ] Pass conic-gradient(black, green, white) [ parsable ]
@ -152,7 +151,7 @@ Pass repeating-conic-gradient(0%, black, white) [ unparsable ]
Pass repeating-conic-gradient(black) [ parsable ] Pass repeating-conic-gradient(black) [ parsable ]
Pass repeating-conic-gradient(black 0%) [ parsable ] Pass repeating-conic-gradient(black 0%) [ parsable ]
Pass repeating-conic-gradient(black, white) [ parsable ] Pass repeating-conic-gradient(black, white) [ parsable ]
Fail repeating-conic-gradient(black 0, white) [ parsable ] Pass repeating-conic-gradient(black 0, white) [ parsable ]
Pass repeating-conic-gradient(black 0%, white) [ parsable ] Pass repeating-conic-gradient(black 0%, white) [ parsable ]
Pass repeating-conic-gradient(black 0%, white 100%) [ parsable ] Pass repeating-conic-gradient(black 0%, white 100%) [ parsable ]
Pass repeating-conic-gradient(black, green, white) [ parsable ] Pass repeating-conic-gradient(black, green, white) [ parsable ]