mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 20:17:42 +00:00
LibWeb: Parse grid-column and grid-row properties using TokenStream
This commit is contained in:
parent
b18c334a4f
commit
a16b35a755
2 changed files with 10 additions and 8 deletions
|
@ -5469,12 +5469,12 @@ RefPtr<StyleValue> Parser::parse_grid_track_placement(Vector<ComponentValue> con
|
||||||
return GridTrackPlacementStyleValue::create(GridTrackPlacement::make_span(span_or_position_value));
|
return GridTrackPlacementStyleValue::create(GridTrackPlacement::make_span(span_or_position_value));
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_grid_track_placement_shorthand_value(PropertyID property_id, Vector<ComponentValue> const& component_values)
|
RefPtr<StyleValue> Parser::parse_grid_track_placement_shorthand_value(PropertyID property_id, TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto start_property = (property_id == PropertyID::GridColumn) ? PropertyID::GridColumnStart : PropertyID::GridRowStart;
|
auto start_property = (property_id == PropertyID::GridColumn) ? PropertyID::GridColumnStart : PropertyID::GridRowStart;
|
||||||
auto end_property = (property_id == PropertyID::GridColumn) ? PropertyID::GridColumnEnd : PropertyID::GridRowEnd;
|
auto end_property = (property_id == PropertyID::GridColumn) ? PropertyID::GridColumnEnd : PropertyID::GridRowEnd;
|
||||||
|
|
||||||
auto tokens = TokenStream { component_values };
|
auto transaction = tokens.begin_transaction();
|
||||||
auto current_token = tokens.next_token();
|
auto current_token = tokens.next_token();
|
||||||
|
|
||||||
Vector<ComponentValue> track_start_placement_tokens;
|
Vector<ComponentValue> track_start_placement_tokens;
|
||||||
|
@ -5500,6 +5500,7 @@ RefPtr<StyleValue> Parser::parse_grid_track_placement_shorthand_value(PropertyID
|
||||||
|
|
||||||
auto parsed_start_value = parse_grid_track_placement(track_start_placement_tokens);
|
auto parsed_start_value = parse_grid_track_placement(track_start_placement_tokens);
|
||||||
if (parsed_start_value && track_end_placement_tokens.is_empty()) {
|
if (parsed_start_value && track_end_placement_tokens.is_empty()) {
|
||||||
|
transaction.commit();
|
||||||
return ShorthandStyleValue::create(property_id,
|
return ShorthandStyleValue::create(property_id,
|
||||||
{ start_property, end_property },
|
{ start_property, end_property },
|
||||||
{ parsed_start_value.release_nonnull(), GridTrackPlacementStyleValue::create(GridTrackPlacement::make_auto()) });
|
{ parsed_start_value.release_nonnull(), GridTrackPlacementStyleValue::create(GridTrackPlacement::make_auto()) });
|
||||||
|
@ -5507,6 +5508,7 @@ RefPtr<StyleValue> Parser::parse_grid_track_placement_shorthand_value(PropertyID
|
||||||
|
|
||||||
auto parsed_end_value = parse_grid_track_placement(track_end_placement_tokens);
|
auto parsed_end_value = parse_grid_track_placement(track_end_placement_tokens);
|
||||||
if (parsed_start_value && parsed_end_value) {
|
if (parsed_start_value && parsed_end_value) {
|
||||||
|
transaction.commit();
|
||||||
return ShorthandStyleValue::create(property_id,
|
return ShorthandStyleValue::create(property_id,
|
||||||
{ start_property, end_property },
|
{ start_property, end_property },
|
||||||
{ parsed_start_value.release_nonnull(), parsed_end_value.release_nonnull() });
|
{ parsed_start_value.release_nonnull(), parsed_end_value.release_nonnull() });
|
||||||
|
@ -5818,10 +5820,6 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(Property
|
||||||
if (auto parsed_value = parse_font_family_value(tokens); parsed_value && !tokens.has_next_token())
|
if (auto parsed_value = parse_font_family_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::GridColumn:
|
|
||||||
if (auto parsed_value = parse_grid_track_placement_shorthand_value(property_id, component_values))
|
|
||||||
return parsed_value.release_nonnull();
|
|
||||||
return ParseError::SyntaxError;
|
|
||||||
case PropertyID::GridArea:
|
case PropertyID::GridArea:
|
||||||
if (auto parsed_value = parse_grid_area_shorthand_value(component_values))
|
if (auto parsed_value = parse_grid_area_shorthand_value(component_values))
|
||||||
return parsed_value.release_nonnull();
|
return parsed_value.release_nonnull();
|
||||||
|
@ -5834,6 +5832,10 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(Property
|
||||||
if (auto parsed_value = parse_grid_template_areas_value(component_values))
|
if (auto parsed_value = parse_grid_template_areas_value(component_values))
|
||||||
return parsed_value.release_nonnull();
|
return parsed_value.release_nonnull();
|
||||||
return ParseError::SyntaxError;
|
return ParseError::SyntaxError;
|
||||||
|
case PropertyID::GridColumn:
|
||||||
|
if (auto parsed_value = parse_grid_track_placement_shorthand_value(property_id, tokens); parsed_value && !tokens.has_next_token())
|
||||||
|
return parsed_value.release_nonnull();
|
||||||
|
return ParseError::SyntaxError;
|
||||||
case PropertyID::GridColumnEnd:
|
case PropertyID::GridColumnEnd:
|
||||||
if (auto parsed_value = parse_grid_track_placement(component_values))
|
if (auto parsed_value = parse_grid_track_placement(component_values))
|
||||||
return parsed_value.release_nonnull();
|
return parsed_value.release_nonnull();
|
||||||
|
@ -5843,7 +5845,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::GridRow:
|
case PropertyID::GridRow:
|
||||||
if (auto parsed_value = parse_grid_track_placement_shorthand_value(property_id, component_values))
|
if (auto parsed_value = parse_grid_track_placement_shorthand_value(property_id, 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::GridRowEnd:
|
case PropertyID::GridRowEnd:
|
||||||
|
|
|
@ -263,7 +263,7 @@ private:
|
||||||
[[nodiscard]] RefPtr<GridAutoFlowStyleValue> parse_grid_auto_flow_value(Vector<ComponentValue> const&);
|
[[nodiscard]] RefPtr<GridAutoFlowStyleValue> parse_grid_auto_flow_value(Vector<ComponentValue> const&);
|
||||||
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, Vector<ComponentValue> const&);
|
RefPtr<StyleValue> parse_grid_track_placement_shorthand_value(PropertyID, TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_grid_template_areas_value(Vector<ComponentValue> const&);
|
RefPtr<StyleValue> parse_grid_template_areas_value(Vector<ComponentValue> const&);
|
||||||
RefPtr<StyleValue> parse_grid_area_shorthand_value(Vector<ComponentValue> const&);
|
RefPtr<StyleValue> parse_grid_area_shorthand_value(Vector<ComponentValue> const&);
|
||||||
RefPtr<StyleValue> parse_grid_shorthand_value(Vector<ComponentValue> const&);
|
RefPtr<StyleValue> parse_grid_shorthand_value(Vector<ComponentValue> const&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue