mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:58:12 +00:00
LibWeb: Add support for "place-items" CSS property
Adds support for place-items property which allows to specify both align-items and justify-items in a single declaration.
This commit is contained in:
parent
a74c56bc1b
commit
a8587fe54e
12 changed files with 135 additions and 0 deletions
|
@ -70,6 +70,7 @@
|
|||
#include <LibWeb/CSS/StyleValues/OverflowStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/PlaceContentStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/PlaceItemsStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/PositionStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/RadialGradientStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/RatioStyleValue.h>
|
||||
|
@ -6222,6 +6223,25 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_place_content_value(Vector<ComponentVa
|
|||
return PlaceContentStyleValue::create(maybe_align_content_value.release_nonnull(), maybe_justify_content_value.release_nonnull());
|
||||
}
|
||||
|
||||
ErrorOr<RefPtr<StyleValue>> Parser::parse_place_items_value(Vector<ComponentValue> const& component_values)
|
||||
{
|
||||
auto tokens = TokenStream { component_values };
|
||||
auto maybe_align_items_value = TRY(parse_css_value_for_property(PropertyID::AlignItems, tokens));
|
||||
if (!maybe_align_items_value)
|
||||
return nullptr;
|
||||
|
||||
if (component_values.size() == 1) {
|
||||
if (!property_accepts_identifier(PropertyID::JustifyItems, maybe_align_items_value->to_identifier()))
|
||||
return nullptr;
|
||||
return PlaceItemsStyleValue::create(*maybe_align_items_value, *maybe_align_items_value);
|
||||
}
|
||||
|
||||
auto maybe_justify_items_value = TRY(parse_css_value_for_property(PropertyID::JustifyItems, tokens));
|
||||
if (!maybe_justify_items_value)
|
||||
return nullptr;
|
||||
return PlaceItemsStyleValue::create(*maybe_align_items_value, *maybe_justify_items_value);
|
||||
}
|
||||
|
||||
ErrorOr<RefPtr<StyleValue>> Parser::parse_text_decoration_value(Vector<ComponentValue> const& component_values)
|
||||
{
|
||||
RefPtr<StyleValue> decoration_line;
|
||||
|
@ -7456,6 +7476,10 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(Property
|
|||
if (auto parsed_value = FIXME_TRY(parse_place_content_value(component_values)))
|
||||
return parsed_value.release_nonnull();
|
||||
return ParseError::SyntaxError;
|
||||
case PropertyID::PlaceItems:
|
||||
if (auto parsed_value = FIXME_TRY(parse_place_items_value(component_values)))
|
||||
return parsed_value.release_nonnull();
|
||||
return ParseError::SyntaxError;
|
||||
case PropertyID::TextDecoration:
|
||||
if (auto parsed_value = FIXME_TRY(parse_text_decoration_value(component_values)))
|
||||
return parsed_value.release_nonnull();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue