LibWeb: Parse grid-auto-[columns,rows] properties using TokenStream
This commit is contained in:
parent
519214697b
commit
ee5b00d1ee
Notes:
sideshowbarker
2024-07-17 16:42:19 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/ee5b00d1ee Pull-request: https://github.com/SerenityOS/serenity/pull/22440
2 changed files with 10 additions and 7 deletions
|
@ -5350,21 +5350,24 @@ RefPtr<GridAutoFlowStyleValue> Parser::parse_grid_auto_flow_value(TokenStream<Co
|
|||
return GridAutoFlowStyleValue::create(axis.value_or(GridAutoFlowStyleValue::Axis::Row), dense.value_or(GridAutoFlowStyleValue::Dense::No));
|
||||
}
|
||||
|
||||
RefPtr<StyleValue> Parser::parse_grid_auto_track_sizes(Vector<ComponentValue> const& component_values)
|
||||
RefPtr<StyleValue> Parser::parse_grid_auto_track_sizes(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
// https://www.w3.org/TR/css-grid-2/#auto-tracks
|
||||
// <track-size>+
|
||||
Vector<CSS::ExplicitGridTrack> track_list;
|
||||
TokenStream tokens { component_values };
|
||||
auto transaction = tokens.begin_transaction();
|
||||
while (tokens.has_next_token()) {
|
||||
auto token = tokens.next_token();
|
||||
auto track_sizing_function = parse_track_sizing_function(token);
|
||||
if (!track_sizing_function.has_value())
|
||||
if (!track_sizing_function.has_value()) {
|
||||
transaction.commit();
|
||||
return GridTrackSizeListStyleValue::make_auto();
|
||||
}
|
||||
// FIXME: Handle multiple repeat values (should combine them here, or remove
|
||||
// any other ones if the first one is auto-fill, etc.)
|
||||
// any other ones if the first one is auto-fill, etc.)
|
||||
track_list.append(track_sizing_function.value());
|
||||
}
|
||||
transaction.commit();
|
||||
return GridTrackSizeListStyleValue::create(CSS::GridTrackSizeList(track_list, {}));
|
||||
}
|
||||
|
||||
|
@ -5889,11 +5892,11 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(Property
|
|||
return parsed_value.release_nonnull();
|
||||
return ParseError::SyntaxError;
|
||||
case PropertyID::GridAutoColumns:
|
||||
if (auto parsed_value = parse_grid_auto_track_sizes(component_values))
|
||||
if (auto parsed_value = parse_grid_auto_track_sizes(tokens); parsed_value && !tokens.has_next_token())
|
||||
return parsed_value.release_nonnull();
|
||||
return ParseError::SyntaxError;
|
||||
case PropertyID::GridAutoRows:
|
||||
if (auto parsed_value = parse_grid_auto_track_sizes(component_values))
|
||||
if (auto parsed_value = parse_grid_auto_track_sizes(tokens); parsed_value && !tokens.has_next_token())
|
||||
return parsed_value.release_nonnull();
|
||||
return ParseError::SyntaxError;
|
||||
case PropertyID::ListStyle:
|
||||
|
|
|
@ -259,7 +259,7 @@ private:
|
|||
RefPtr<StyleValue> parse_transform_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue> parse_transform_origin_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue> parse_grid_track_size_list(Vector<ComponentValue> const&, bool allow_separate_line_name_blocks = false);
|
||||
RefPtr<StyleValue> parse_grid_auto_track_sizes(Vector<ComponentValue> const&);
|
||||
RefPtr<StyleValue> parse_grid_auto_track_sizes(TokenStream<ComponentValue>&);
|
||||
RefPtr<GridAutoFlowStyleValue> parse_grid_auto_flow_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue> parse_grid_track_size_list_shorthand_value(PropertyID, Vector<ComponentValue> const&);
|
||||
RefPtr<StyleValue> parse_grid_track_placement(TokenStream<ComponentValue>&);
|
||||
|
|
Loading…
Add table
Reference in a new issue