LibWeb/CSS: Don't remove whitespace early when parsing descriptor values
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

This commit is contained in:
Tim Ledbetter 2025-07-03 06:21:50 +01:00 committed by Sam Atkins
parent 9d1373de86
commit af60e36122
Notes: github-actions[bot] 2025-07-03 07:23:40 +00:00
2 changed files with 16 additions and 15 deletions

View file

@ -30,11 +30,7 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descripto
if (unprocessed_tokens.peek_token().is(Token::Type::Semicolon))
break;
// FIXME: Stop removing whitespace here. It's just for compatibility with the property-parsing code.
auto const& token = unprocessed_tokens.consume_a_token();
if (token.is(Token::Type::Whitespace))
continue;
component_values.append(token);
}
@ -64,6 +60,7 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descripto
case DescriptorMetadata::ValueType::CropOrCross: {
// crop || cross
auto first = parse_keyword_value(tokens);
tokens.discard_whitespace();
auto second = parse_keyword_value(tokens);
if (!first)
@ -135,6 +132,8 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descripto
if (first_length->is_length() && first_length->as_length().length().raw_value() < 0)
return nullptr;
tokens.discard_whitespace();
if (auto second_length = parse_length_value(tokens)) {
if (second_length->is_length() && second_length->as_length().length().raw_value() < 0)
return nullptr;
@ -160,6 +159,8 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descripto
return nullptr;
}
tokens.discard_whitespace();
if (auto second_keyword = parse_keyword_value(tokens)) {
if (orientation.is_null() && first_is_one_of(second_keyword->to_keyword(), Keyword::Landscape, Keyword::Portrait)) {
orientation = second_keyword.release_nonnull();