LibWeb/CSS: Construct all CSS Tokens in a consistent way

Add `create_foo()` static methods for the missing Token::Types, and use
them in the Tokenizer. This means we slightly deviate from the spec now:
it says "create foo token... set its bar to 32", but we now just wait
and construct the Token fully-formed. But those cases are short so it
should still be clear what we're doing.

This makes it possible to construct all kinds of Token elsewhere, such
as for testing purposes.
This commit is contained in:
Sam Atkins 2025-07-09 12:59:31 +01:00 committed by Tim Ledbetter
parent 57dd85e4ac
commit d5bee680b0
Notes: github-actions[bot] 2025-07-09 14:06:20 +00:00
4 changed files with 203 additions and 188 deletions

View file

@ -79,9 +79,6 @@ private:
[[nodiscard]] U32Twin start_of_input_stream_twin();
[[nodiscard]] U32Triplet start_of_input_stream_triplet();
[[nodiscard]] static Token create_new_token(Token::Type);
[[nodiscard]] static Token create_value_token(Token::Type, FlyString&& value, String&& representation);
[[nodiscard]] static Token create_value_token(Token::Type, u32 value, String&& representation);
[[nodiscard]] Token consume_a_token();
[[nodiscard]] Token consume_string_token(u32 ending_code_point);
[[nodiscard]] Token consume_a_numeric_token();