LibWeb/CSS: Let Properties.json specify whether to strip whitespace

Removing all whitespace before parsing StyleValues seemed like a good
idea back when I did it, but causes issues. Serialization cares about
whether there was whitespace or not, and we also weren't removing
whitespace from inside blocks and functions so it was inconsistent
whether we needed to deal with whitespace or not.

So currently, some parsing code is conscious of whitespace, some isn't,
and some tries to be but is incorrect. Rather than try to fix all of
this in a single large, messy change, this commit introduces
a "strip-whitespace" flag to Properties.json. We can then disable
whitespace-stripping a few properties at a time and debug any issues
more easily. Eventually (hopefully soon), this will go away entirely.
This commit is contained in:
Sam Atkins 2025-10-28 13:21:07 +00:00
parent abcc5bc16d
commit 6d38ad32cb
Notes: github-actions[bot] 2025-11-03 11:30:27 +00:00
3 changed files with 385 additions and 1 deletions

View file

@ -474,7 +474,7 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue const>> Parser::parse_css_value(Pr
}
// FIXME: Stop removing whitespace here. It's less helpful than it seems.
if (property_id != PropertyID::Custom && token.is(Token::Type::Whitespace))
if (property_requires_whitespace_stripped_before_parsing(property_id) && token.is(Token::Type::Whitespace))
continue;
if (token.is_function())