1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:28:12 +00:00

LibWeb: Break friendship between CSS Function and Parser

Again, this means deviating from the spec by creating a complete
Function in one go instead of creating it empty and then poking at its
internals.
This commit is contained in:
Sam Atkins 2022-04-12 16:44:02 +01:00 committed by Andreas Kling
parent 7d67e428a6
commit d67e817d8e
4 changed files with 14 additions and 14 deletions

View file

@ -1878,7 +1878,9 @@ NonnullRefPtr<Function> Parser::consume_a_function(TokenStream<T>& tokens)
// Create a function with its name equal to the value of the current input token
// and with its value initially set to an empty list.
auto function = make_ref_counted<Function>(((Token)name_ident).function());
// NOTE: We create the Function fully initialized when we return it instead.
FlyString function_name = ((Token)name_ident).function();
Vector<ComponentValue> function_values;
// Repeatedly consume the next input token and process it as follows:
for (;;) {
@ -1887,14 +1889,14 @@ NonnullRefPtr<Function> Parser::consume_a_function(TokenStream<T>& tokens)
// <)-token>
if (token.is(Token::Type::CloseParen)) {
// Return the function.
return function;
return Function::create(move(function_name), move(function_values));
}
// <EOF-token>
if (token.is(Token::Type::EndOfFile)) {
// This is a parse error. Return the function.
log_parse_error();
return function;
return Function::create(move(function_name), move(function_values));
}
// anything else
@ -1903,7 +1905,7 @@ NonnullRefPtr<Function> Parser::consume_a_function(TokenStream<T>& tokens)
tokens.reconsume_current_input_token();
// Consume a component value and append the returned value to the functions value.
function->m_values.append(consume_a_component_value(tokens));
function_values.append(consume_a_component_value(tokens));
}
}
}