1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:37:35 +00:00

LibWeb: Parse comma-separated lists for most background properties

We now can parse lists of values for these properties:
- `background-attachment`
- `background-clip`
- `background-image`
- `background-origin`
- `background-position`
- `background-repeat`
- `background-size`

This uses two new Parser methods:
`parse_simple_comma_separated_value_list()` for the simple case when
each value is parsed from a single token; and
`parse_comma_separated_value_list()` which takes a lambda for when
parsing each value is more involved.

This also means that any unconsumed tokens at the end will make the
parsing fail as it should, where previously we just ignored them.
This commit is contained in:
Sam Atkins 2021-11-08 17:19:55 +00:00 committed by Andreas Kling
parent 50b15bdc1d
commit 8fd4678e79
2 changed files with 47 additions and 46 deletions

View file

@ -198,14 +198,14 @@ private:
RefPtr<StyleValue> parse_color_value(StyleComponentValueRule const&);
RefPtr<StyleValue> parse_string_value(StyleComponentValueRule const&);
RefPtr<StyleValue> parse_image_value(StyleComponentValueRule const&);
template<typename ParseFunction>
RefPtr<StyleValue> parse_comma_separated_value_list(Vector<StyleComponentValueRule> const&, ParseFunction);
RefPtr<StyleValue> parse_simple_comma_separated_value_list(Vector<StyleComponentValueRule> const&);
RefPtr<StyleValue> parse_background_value(Vector<StyleComponentValueRule> const&);
RefPtr<StyleValue> parse_background_image_value(Vector<StyleComponentValueRule> const&);
RefPtr<StyleValue> parse_single_background_position_value(TokenStream<StyleComponentValueRule>&);
RefPtr<StyleValue> parse_background_position_value(Vector<StyleComponentValueRule> const&);
RefPtr<StyleValue> parse_single_background_repeat_value(TokenStream<StyleComponentValueRule>&);
RefPtr<StyleValue> parse_background_repeat_value(Vector<StyleComponentValueRule> const&);
RefPtr<StyleValue> parse_single_background_size_value(TokenStream<StyleComponentValueRule>&);
RefPtr<StyleValue> parse_background_size_value(Vector<StyleComponentValueRule> const&);
RefPtr<StyleValue> parse_border_value(Vector<StyleComponentValueRule> const&);
RefPtr<StyleValue> parse_border_radius_value(Vector<StyleComponentValueRule> const&);
RefPtr<StyleValue> parse_border_radius_shorthand_value(Vector<StyleComponentValueRule> const&);