mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:38:11 +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
|
||||
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
|
||||
TokenStream<ComponentValue> tokens { component_values };
|
||||
if (!tokens.has_next_token())
|
||||
return nullptr;
|
||||
|
||||
auto transaction = tokens.begin_transaction();
|
||||
|
||||
auto parse_axis = [&]() -> Optional<GridAutoFlowStyleValue::Axis> {
|
||||
auto transaction = tokens.begin_transaction();
|
||||
auto token = tokens.next_token();
|
||||
|
@ -5359,6 +5360,7 @@ RefPtr<GridAutoFlowStyleValue> Parser::parse_grid_auto_flow_value(Vector<Compone
|
|||
if (tokens.has_next_token())
|
||||
return nullptr;
|
||||
|
||||
transaction.commit();
|
||||
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 ParseError::SyntaxError;
|
||||
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 ParseError::SyntaxError;
|
||||
case PropertyID::GridTemplateAreas:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue