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.

(cherry picked from commit e0be17e4fbf1870f35614d0cde8f63e72f78bd16;
amended to tweak test expectation due to serenity not yet having
LadybirdBrowser/ladybird#1603)
This commit is contained in:
Sam Atkins
2024-10-11 11:17:10 +01:00
committed by Nico Weber
parent 059539d691
commit fe9ab2c91e
25 changed files with 1127 additions and 1279 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"~~~(