LibWeb/CSS: Rewrite CSS Parser core methods according to new spec

CSS Syntax 3 (https://drafts.csswg.org/css-syntax) has changed
significantly since we implemented it a couple of years ago. Just about
every parsing algorithm has been rewritten in terms of the new token
stream concept, and to support nested styles. As all of those
algorithms call into each other, this is an unfortunately chonky diff.

As part of this, the transitory types (Declaration, Function, AtRule...)
have been rewritten. That's both because we have new requirements of
what they should be and contain, and also because the spec asks us to
create and then gradually modify them in place, which is easier if they
are plain structs.
This commit is contained in:
Sam Atkins 2024-10-11 11:17:10 +01:00 committed by Andreas Kling
parent f11c0e6cc0
commit e0be17e4fb
Notes: github-actions[bot] 2024-10-14 06:09:33 +00:00
24 changed files with 1126 additions and 1278 deletions

View file

@ -118,7 +118,7 @@ static Optional<RoundingStrategy> parse_rounding_strategy(Vector<ComponentValue>
OwnPtr<CalculationNode> Parser::parse_math_function(PropertyID property_id, Function const& function)
{
TokenStream stream { function.values() };
TokenStream stream { function.value };
auto arguments = parse_a_comma_separated_list_of_component_values(stream);
)~~~");
@ -129,7 +129,7 @@ OwnPtr<CalculationNode> Parser::parse_math_function(PropertyID property_id, Func
auto function_generator = generator.fork();
function_generator.set("name:lowercase", name);
function_generator.set("name:titlecase", title_casify(name));
function_generator.appendln(" if (function.name().equals_ignoring_ascii_case(\"@name:lowercase@\"sv)) {");
function_generator.appendln(" if (function.name.equals_ignoring_ascii_case(\"@name:lowercase@\"sv)) {");
if (function_data.get_bool("is-variadic"sv).value_or(false)) {
// Variadic function
function_generator.append(R"~~~(