mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:37:46 +00:00
LibWeb: Parse place-items property using TokenStream
This commit is contained in:
parent
61d6f611cb
commit
5a8f57f7b3
2 changed files with 7 additions and 5 deletions
|
@ -4535,16 +4535,17 @@ RefPtr<StyleValue> Parser::parse_place_content_value(TokenStream<ComponentValue>
|
||||||
{ maybe_align_content_value.release_nonnull(), maybe_justify_content_value.release_nonnull() });
|
{ maybe_align_content_value.release_nonnull(), maybe_justify_content_value.release_nonnull() });
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_place_items_value(Vector<ComponentValue> const& component_values)
|
RefPtr<StyleValue> Parser::parse_place_items_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto tokens = TokenStream { component_values };
|
auto transaction = tokens.begin_transaction();
|
||||||
auto maybe_align_items_value = parse_css_value_for_property(PropertyID::AlignItems, tokens);
|
auto maybe_align_items_value = parse_css_value_for_property(PropertyID::AlignItems, tokens);
|
||||||
if (!maybe_align_items_value)
|
if (!maybe_align_items_value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (component_values.size() == 1) {
|
if (!tokens.has_next_token()) {
|
||||||
if (!property_accepts_identifier(PropertyID::JustifyItems, maybe_align_items_value->to_identifier()))
|
if (!property_accepts_identifier(PropertyID::JustifyItems, maybe_align_items_value->to_identifier()))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
transaction.commit();
|
||||||
return ShorthandStyleValue::create(PropertyID::PlaceItems,
|
return ShorthandStyleValue::create(PropertyID::PlaceItems,
|
||||||
{ PropertyID::AlignItems, PropertyID::JustifyItems },
|
{ PropertyID::AlignItems, PropertyID::JustifyItems },
|
||||||
{ *maybe_align_items_value, *maybe_align_items_value });
|
{ *maybe_align_items_value, *maybe_align_items_value });
|
||||||
|
@ -4553,6 +4554,7 @@ RefPtr<StyleValue> Parser::parse_place_items_value(Vector<ComponentValue> const&
|
||||||
auto maybe_justify_items_value = parse_css_value_for_property(PropertyID::JustifyItems, tokens);
|
auto maybe_justify_items_value = parse_css_value_for_property(PropertyID::JustifyItems, tokens);
|
||||||
if (!maybe_justify_items_value)
|
if (!maybe_justify_items_value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
transaction.commit();
|
||||||
return ShorthandStyleValue::create(PropertyID::PlaceItems,
|
return ShorthandStyleValue::create(PropertyID::PlaceItems,
|
||||||
{ PropertyID::AlignItems, PropertyID::JustifyItems },
|
{ PropertyID::AlignItems, PropertyID::JustifyItems },
|
||||||
{ *maybe_align_items_value, *maybe_justify_items_value });
|
{ *maybe_align_items_value, *maybe_justify_items_value });
|
||||||
|
@ -5915,7 +5917,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::PlaceItems:
|
case PropertyID::PlaceItems:
|
||||||
if (auto parsed_value = parse_place_items_value(component_values))
|
if (auto parsed_value = parse_place_items_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::PlaceSelf:
|
case PropertyID::PlaceSelf:
|
||||||
|
|
|
@ -244,7 +244,7 @@ private:
|
||||||
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(TokenStream<ComponentValue>&);
|
RefPtr<StyleValue> parse_place_content_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_place_items_value(Vector<ComponentValue> const&);
|
RefPtr<StyleValue> parse_place_items_value(TokenStream<ComponentValue>&);
|
||||||
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>&);
|
||||||
enum class AllowInsetKeyword {
|
enum class AllowInsetKeyword {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue