mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 21:25:07 +00:00
LibWeb: Parse place-self property using TokenStream
This commit is contained in:
parent
5a8f57f7b3
commit
513dee04d4
2 changed files with 7 additions and 5 deletions
|
@ -4560,16 +4560,17 @@ RefPtr<StyleValue> Parser::parse_place_items_value(TokenStream<ComponentValue>&
|
||||||
{ *maybe_align_items_value, *maybe_justify_items_value });
|
{ *maybe_align_items_value, *maybe_justify_items_value });
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_place_self_value(Vector<ComponentValue> const& component_values)
|
RefPtr<StyleValue> Parser::parse_place_self_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto tokens = TokenStream { component_values };
|
auto transaction = tokens.begin_transaction();
|
||||||
auto maybe_align_self_value = parse_css_value_for_property(PropertyID::AlignSelf, tokens);
|
auto maybe_align_self_value = parse_css_value_for_property(PropertyID::AlignSelf, tokens);
|
||||||
if (!maybe_align_self_value)
|
if (!maybe_align_self_value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (component_values.size() == 1) {
|
if (!tokens.has_next_token()) {
|
||||||
if (!property_accepts_identifier(PropertyID::JustifySelf, maybe_align_self_value->to_identifier()))
|
if (!property_accepts_identifier(PropertyID::JustifySelf, maybe_align_self_value->to_identifier()))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
transaction.commit();
|
||||||
return ShorthandStyleValue::create(PropertyID::PlaceSelf,
|
return ShorthandStyleValue::create(PropertyID::PlaceSelf,
|
||||||
{ PropertyID::AlignSelf, PropertyID::JustifySelf },
|
{ PropertyID::AlignSelf, PropertyID::JustifySelf },
|
||||||
{ *maybe_align_self_value, *maybe_align_self_value });
|
{ *maybe_align_self_value, *maybe_align_self_value });
|
||||||
|
@ -4578,6 +4579,7 @@ RefPtr<StyleValue> Parser::parse_place_self_value(Vector<ComponentValue> const&
|
||||||
auto maybe_justify_self_value = parse_css_value_for_property(PropertyID::JustifySelf, tokens);
|
auto maybe_justify_self_value = parse_css_value_for_property(PropertyID::JustifySelf, tokens);
|
||||||
if (!maybe_justify_self_value)
|
if (!maybe_justify_self_value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
transaction.commit();
|
||||||
return ShorthandStyleValue::create(PropertyID::PlaceSelf,
|
return ShorthandStyleValue::create(PropertyID::PlaceSelf,
|
||||||
{ PropertyID::AlignSelf, PropertyID::JustifySelf },
|
{ PropertyID::AlignSelf, PropertyID::JustifySelf },
|
||||||
{ *maybe_align_self_value, *maybe_justify_self_value });
|
{ *maybe_align_self_value, *maybe_justify_self_value });
|
||||||
|
@ -5921,7 +5923,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::PlaceSelf:
|
case PropertyID::PlaceSelf:
|
||||||
if (auto parsed_value = parse_place_self_value(component_values))
|
if (auto parsed_value = parse_place_self_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::Quotes:
|
case PropertyID::Quotes:
|
||||||
|
|
|
@ -245,7 +245,7 @@ private:
|
||||||
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(TokenStream<ComponentValue>&);
|
RefPtr<StyleValue> parse_place_items_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_place_self_value(Vector<ComponentValue> const&);
|
RefPtr<StyleValue> parse_place_self_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_quotes_value(TokenStream<ComponentValue>&);
|
RefPtr<StyleValue> parse_quotes_value(TokenStream<ComponentValue>&);
|
||||||
enum class AllowInsetKeyword {
|
enum class AllowInsetKeyword {
|
||||||
No,
|
No,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue