1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:58:11 +00:00

LibWeb: Use Flex type in GridSize

This commit is contained in:
Sam Atkins 2023-09-28 15:23:04 +01:00 committed by Sam Atkins
parent dfd3d9a72d
commit 127bfd64a8
3 changed files with 13 additions and 13 deletions

View file

@ -5118,17 +5118,15 @@ RefPtr<StyleValue> Parser::parse_as_css_value(PropertyID property_id)
Optional<CSS::GridSize> Parser::parse_grid_size(ComponentValue const& component_value)
{
if (component_value.is_function()) {
if (auto maybe_calculated = parse_calculated_value(component_value))
return GridSize(LengthPercentage(maybe_calculated.release_nonnull()));
if (auto maybe_calculated = parse_calculated_value(component_value)) {
if (maybe_calculated->resolves_to_length_percentage())
return GridSize(LengthPercentage(maybe_calculated.release_nonnull()));
// FIXME: Support calculated <flex>
}
return {};
}
auto token = component_value.token();
if (token.is(Token::Type::Dimension) && token.dimension_unit().equals_ignoring_ascii_case("fr"sv)) {
auto numeric_value = token.dimension_value();
if (numeric_value)
return GridSize(numeric_value);
}
if (token.is(Token::Type::Ident) && token.ident().equals_ignoring_ascii_case("auto"sv))
return GridSize::make_auto();
if (token.is(Token::Type::Ident) && token.ident().equals_ignoring_ascii_case("max-content"sv))
@ -5142,6 +5140,8 @@ Optional<CSS::GridSize> Parser::parse_grid_size(ComponentValue const& component_
return GridSize(dimension->length());
else if (dimension->is_percentage())
return GridSize(dimension->percentage());
else if (dimension->is_flex())
return GridSize(dimension->flex());
return {};
}