mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 14:47:34 +00:00
LibWeb: Parse place-content property using TokenStream
This commit is contained in:
parent
4f773a7dae
commit
61d6f611cb
2 changed files with 7 additions and 8 deletions
|
@ -4510,19 +4510,17 @@ RefPtr<StyleValue> Parser::parse_overflow_value(TokenStream<ComponentValue>& tok
|
||||||
{ *maybe_x_value, *maybe_x_value });
|
{ *maybe_x_value, *maybe_x_value });
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_place_content_value(Vector<ComponentValue> const& component_values)
|
RefPtr<StyleValue> Parser::parse_place_content_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
if (component_values.size() > 2)
|
auto transaction = tokens.begin_transaction();
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
auto tokens = TokenStream { component_values };
|
|
||||||
auto maybe_align_content_value = parse_css_value_for_property(PropertyID::AlignContent, tokens);
|
auto maybe_align_content_value = parse_css_value_for_property(PropertyID::AlignContent, tokens);
|
||||||
if (!maybe_align_content_value)
|
if (!maybe_align_content_value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (component_values.size() == 1) {
|
if (!tokens.has_next_token()) {
|
||||||
if (!property_accepts_identifier(PropertyID::JustifyContent, maybe_align_content_value->to_identifier()))
|
if (!property_accepts_identifier(PropertyID::JustifyContent, maybe_align_content_value->to_identifier()))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
transaction.commit();
|
||||||
return ShorthandStyleValue::create(PropertyID::PlaceContent,
|
return ShorthandStyleValue::create(PropertyID::PlaceContent,
|
||||||
{ PropertyID::AlignContent, PropertyID::JustifyContent },
|
{ PropertyID::AlignContent, PropertyID::JustifyContent },
|
||||||
{ *maybe_align_content_value, *maybe_align_content_value });
|
{ *maybe_align_content_value, *maybe_align_content_value });
|
||||||
|
@ -4531,6 +4529,7 @@ RefPtr<StyleValue> Parser::parse_place_content_value(Vector<ComponentValue> cons
|
||||||
auto maybe_justify_content_value = parse_css_value_for_property(PropertyID::JustifyContent, tokens);
|
auto maybe_justify_content_value = parse_css_value_for_property(PropertyID::JustifyContent, tokens);
|
||||||
if (!maybe_justify_content_value)
|
if (!maybe_justify_content_value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
transaction.commit();
|
||||||
return ShorthandStyleValue::create(PropertyID::PlaceContent,
|
return ShorthandStyleValue::create(PropertyID::PlaceContent,
|
||||||
{ PropertyID::AlignContent, PropertyID::JustifyContent },
|
{ PropertyID::AlignContent, PropertyID::JustifyContent },
|
||||||
{ maybe_align_content_value.release_nonnull(), maybe_justify_content_value.release_nonnull() });
|
{ maybe_align_content_value.release_nonnull(), maybe_justify_content_value.release_nonnull() });
|
||||||
|
@ -5912,7 +5911,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::PlaceContent:
|
case PropertyID::PlaceContent:
|
||||||
if (auto parsed_value = parse_place_content_value(component_values))
|
if (auto parsed_value = parse_place_content_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::PlaceItems:
|
case PropertyID::PlaceItems:
|
||||||
|
|
|
@ -243,7 +243,7 @@ private:
|
||||||
RefPtr<StyleValue> parse_list_style_value(TokenStream<ComponentValue>&);
|
RefPtr<StyleValue> parse_list_style_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_math_depth_value(TokenStream<ComponentValue>&);
|
RefPtr<StyleValue> parse_math_depth_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_overflow_value(TokenStream<ComponentValue>&);
|
RefPtr<StyleValue> parse_overflow_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_place_content_value(Vector<ComponentValue> const&);
|
RefPtr<StyleValue> parse_place_content_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_place_items_value(Vector<ComponentValue> const&);
|
RefPtr<StyleValue> parse_place_items_value(Vector<ComponentValue> const&);
|
||||||
RefPtr<StyleValue> parse_place_self_value(Vector<ComponentValue> const&);
|
RefPtr<StyleValue> parse_place_self_value(Vector<ComponentValue> const&);
|
||||||
RefPtr<StyleValue> parse_quotes_value(TokenStream<ComponentValue>&);
|
RefPtr<StyleValue> parse_quotes_value(TokenStream<ComponentValue>&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue