LibWeb/CSS: Refactor contains_single_none_ident() to actually parse it

The new method is Parser::parse_all_as_single_none_value(), which has a
few advantages:

1. There's no need for user code to manually create a StyleValue.
2. It consumes tokens so that doesn't have to be done manually.
3. Whitespace before or after the `none` is consumed correctly.

It does mean we create and then discard a `none` StyleValue in a couple
of places, namely parsing for `grid-*` properties. We may or may not
want to migrate those to returning the IdentifierStyleValue instead.
This commit is contained in:
Sam Atkins 2024-07-19 12:07:51 +01:00
commit ca10fb4129
Notes: github-actions[bot] 2024-07-26 10:05:50 +00:00
2 changed files with 30 additions and 35 deletions

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020-2021, the SerenityOS developers.
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
* Copyright (c) 2021-2024, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -303,6 +303,7 @@ private:
template<typename ParseFunction>
RefPtr<StyleValue> parse_comma_separated_value_list(TokenStream<ComponentValue>&, ParseFunction);
RefPtr<StyleValue> parse_simple_comma_separated_value_list(PropertyID, TokenStream<ComponentValue>&);
RefPtr<StyleValue> parse_all_as_single_none_value(TokenStream<ComponentValue>&);
RefPtr<StyleValue> parse_aspect_ratio_value(TokenStream<ComponentValue>&);
RefPtr<StyleValue> parse_background_value(TokenStream<ComponentValue>&);