1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:57:44 +00:00

LibWeb: Handle unknown values in grid-template-*

This commit fixes a bug found when passing exotic values in the
grid-template-columns (or grid-template-rows) which are not yet
supported.

The bug seems to have been something like:
grid-template-columns: 0 minmax(0, calc(10px - var(--some-color)));
This commit is contained in:
martinfalisse 2022-08-26 10:37:59 +02:00 committed by Andreas Kling
parent 3dd522a109
commit f8e82da4b4

View file

@ -5306,22 +5306,22 @@ RefPtr<StyleValue> Parser::parse_grid_track_sizes(Vector<ComponentValue> const&
Vector<CSS::GridTrackSize> params; Vector<CSS::GridTrackSize> params;
for (auto& component_value : component_values) { for (auto& component_value : component_values) {
// FIXME: Incomplete as a GridTrackSize can be a function like minmax(min, max), etc. // FIXME: Incomplete as a GridTrackSize can be a function like minmax(min, max), etc.
if (component_value.is_function()) if (component_value.is_function()) {
return {}; params.append(Length::make_auto());
continue;
}
if (component_value.is(Token::Type::Ident) && component_value.token().ident().equals_ignoring_case("auto"sv)) { if (component_value.is(Token::Type::Ident) && component_value.token().ident().equals_ignoring_case("auto"sv)) {
params.append(Length::make_auto()); params.append(Length::make_auto());
continue; continue;
} }
auto dimension = parse_dimension(component_value); auto dimension = parse_dimension(component_value);
if (!dimension.has_value()) if (!dimension.has_value())
return {}; return GridTrackSizeStyleValue::create({});
if (dimension->is_length()) if (dimension->is_length())
params.append(dimension->length()); params.append(dimension->length());
if (dimension->is_percentage()) if (dimension->is_percentage())
params.append(dimension->percentage()); params.append(dimension->percentage());
} }
if (params.size() == 0)
return {};
return GridTrackSizeStyleValue::create(params); return GridTrackSizeStyleValue::create(params);
} }