mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:37:35 +00:00
LibWeb: Parse grid-auto-flow property using TokenStream
RefPtr is already `[[nodiscard]]` so we can remove that extra noise from the declaration.
This commit is contained in:
parent
bbbd9c14ac
commit
c3583317ee
2 changed files with 6 additions and 4 deletions
|
@ -5312,13 +5312,14 @@ RefPtr<StyleValue> Parser::parse_grid_track_size_list(Vector<ComponentValue> con
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-grid-1/#grid-auto-flow-property
|
// https://www.w3.org/TR/css-grid-1/#grid-auto-flow-property
|
||||||
RefPtr<GridAutoFlowStyleValue> Parser::parse_grid_auto_flow_value(Vector<ComponentValue> const& component_values)
|
RefPtr<GridAutoFlowStyleValue> Parser::parse_grid_auto_flow_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
// [ row | column ] || dense
|
// [ row | column ] || dense
|
||||||
TokenStream<ComponentValue> tokens { component_values };
|
|
||||||
if (!tokens.has_next_token())
|
if (!tokens.has_next_token())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
auto transaction = tokens.begin_transaction();
|
||||||
|
|
||||||
auto parse_axis = [&]() -> Optional<GridAutoFlowStyleValue::Axis> {
|
auto parse_axis = [&]() -> Optional<GridAutoFlowStyleValue::Axis> {
|
||||||
auto transaction = tokens.begin_transaction();
|
auto transaction = tokens.begin_transaction();
|
||||||
auto token = tokens.next_token();
|
auto token = tokens.next_token();
|
||||||
|
@ -5359,6 +5360,7 @@ RefPtr<GridAutoFlowStyleValue> Parser::parse_grid_auto_flow_value(Vector<Compone
|
||||||
if (tokens.has_next_token())
|
if (tokens.has_next_token())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
transaction.commit();
|
||||||
return GridAutoFlowStyleValue::create(axis.value_or(GridAutoFlowStyleValue::Axis::Row), dense.value_or(GridAutoFlowStyleValue::Dense::No));
|
return GridAutoFlowStyleValue::create(axis.value_or(GridAutoFlowStyleValue::Axis::Row), dense.value_or(GridAutoFlowStyleValue::Dense::No));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5826,7 +5828,7 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(Property
|
||||||
return parsed_value.release_nonnull();
|
return parsed_value.release_nonnull();
|
||||||
return ParseError::SyntaxError;
|
return ParseError::SyntaxError;
|
||||||
case PropertyID::GridAutoFlow:
|
case PropertyID::GridAutoFlow:
|
||||||
if (auto parsed_value = parse_grid_auto_flow_value(component_values))
|
if (auto parsed_value = parse_grid_auto_flow_value(tokens); parsed_value && !tokens.has_next_token())
|
||||||
return parsed_value.release_nonnull();
|
return parsed_value.release_nonnull();
|
||||||
return ParseError::SyntaxError;
|
return ParseError::SyntaxError;
|
||||||
case PropertyID::GridTemplateAreas:
|
case PropertyID::GridTemplateAreas:
|
||||||
|
|
|
@ -260,7 +260,7 @@ private:
|
||||||
RefPtr<StyleValue> parse_transform_origin_value(Vector<ComponentValue> const&);
|
RefPtr<StyleValue> parse_transform_origin_value(Vector<ComponentValue> const&);
|
||||||
RefPtr<StyleValue> parse_grid_track_size_list(Vector<ComponentValue> const&, bool allow_separate_line_name_blocks = false);
|
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(Vector<ComponentValue> const&);
|
||||||
[[nodiscard]] RefPtr<GridAutoFlowStyleValue> parse_grid_auto_flow_value(Vector<ComponentValue> const&);
|
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_size_list_shorthand_value(PropertyID, Vector<ComponentValue> const&);
|
||||||
RefPtr<StyleValue> parse_grid_track_placement(Vector<ComponentValue> const&);
|
RefPtr<StyleValue> parse_grid_track_placement(Vector<ComponentValue> const&);
|
||||||
RefPtr<StyleValue> parse_grid_track_placement_shorthand_value(PropertyID, TokenStream<ComponentValue>&);
|
RefPtr<StyleValue> parse_grid_track_placement_shorthand_value(PropertyID, TokenStream<ComponentValue>&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue