From 5a23965e937746923e15584898554871335777c4 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 30 Mar 2022 14:21:43 +0100 Subject: [PATCH] LibWeb: Comment discrepancy from spec in `consume_a_declaration()` We're calling this in a way that is incorrect, and so the algorithm's assumption that the next token is an `` is wrong, and we have to handle that failing. Ideally we would just stop calling this incorrectly, but until then, let's actually document what is happening. --- Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 9c345e32a5..982e3f7aac 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -1776,6 +1776,7 @@ NonnullRefPtr Parser::consume_a_function(TokenStream& toke return function; } +// 5.4.6. Consume a declaration // https://www.w3.org/TR/css-syntax-3/#consume-declaration template Optional Parser::consume_a_declaration(TokenStream& tokens) @@ -1790,6 +1791,8 @@ Optional Parser::consume_a_declaration(TokenStream& tok auto start_position = tokens.position(); auto& token = tokens.next_token(); + // Note: Not to spec, handle the case where the input token *isn't* an . + // FIXME: Perform this check before calling consume_a_declaration(). if (!token.is(Token::Type::Ident)) { tokens.rewind_to_position(start_position); return {};