mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:18:11 +00:00
LibWeb: Add parent classes for managing GridTrackSizes
Add classes ExplicitTrackSizing and MetaGridTrackSize which will allow for managing properties like auto-fill and minmax. In the following CSS example there are 3 classes that will be used: grid-template-column: repeat(auto-fill, minmax(50px, 1fr) 75px); ExplicitTrackSizing - will contain the entire value. e.g. repeat(auto-fill, minmax(50px, 1fr) 75px) With a flag if it's a repeat, as well as references to the MetaGridTrackSizes which is the next step down. MetaGridTrackSize: Contain the individual grid track sizes. Here there are two: minmax(50px, 1fr) as well as 75px. This way can keep track if it's a minmax function or not, and the references to both GridTrackSizes in the case it is, or in just the one if it is not. GridTrackSize: Is the most basic element, in this case there are three in total; two of which are held by the first MetaGridTrackSize, and the third is held by the second MetaGridTrackSize. Examples: 50px, 1fr and 75px.
This commit is contained in:
parent
414a22a386
commit
f7af190de0
10 changed files with 144 additions and 54 deletions
|
@ -5409,7 +5409,7 @@ RefPtr<StyleValue> Parser::parse_as_css_value(PropertyID property_id)
|
|||
|
||||
RefPtr<StyleValue> Parser::parse_grid_track_sizes(Vector<ComponentValue> const& component_values)
|
||||
{
|
||||
Vector<CSS::GridTrackSize> params;
|
||||
Vector<CSS::MetaGridTrackSize> params;
|
||||
for (auto const& component_value : component_values) {
|
||||
if (component_value.is_function()) {
|
||||
auto const& function_token = component_value.function();
|
||||
|
@ -5439,7 +5439,7 @@ RefPtr<StyleValue> Parser::parse_grid_track_sizes(Vector<ComponentValue> const&
|
|||
if (!part_two_tokens.has_next_token())
|
||||
continue;
|
||||
|
||||
Vector<CSS::GridTrackSize> repeat_params;
|
||||
Vector<CSS::MetaGridTrackSize> repeat_params;
|
||||
while (true) {
|
||||
part_two_tokens.skip_whitespace();
|
||||
auto current_component_value = part_two_tokens.next_token();
|
||||
|
@ -5469,13 +5469,8 @@ RefPtr<StyleValue> Parser::parse_grid_track_sizes(Vector<ComponentValue> const&
|
|||
}
|
||||
}
|
||||
part_two_tokens.skip_whitespace();
|
||||
if (!part_two_tokens.has_next_token()) {
|
||||
for (int i = 0; i < repeat_count; ++i) {
|
||||
for (auto const& repeat_param : repeat_params)
|
||||
params.append(repeat_param);
|
||||
}
|
||||
if (!part_two_tokens.has_next_token())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Automatic repetitions (auto-fill or auto-fit) cannot be combined with intrinsic or flexible sizes.
|
||||
|
@ -5499,17 +5494,18 @@ RefPtr<StyleValue> Parser::parse_grid_track_sizes(Vector<ComponentValue> const&
|
|||
// If a repeat() function that is not a <name-repeat> ends up placing two <line-names> adjacent to
|
||||
// each other, the name lists are merged. For example, repeat(2, [a] 1fr [b]) is equivalent to [a]
|
||||
// 1fr [b a] 1fr [b].
|
||||
return GridTrackSizeStyleValue::create(CSS::ExplicitTrackSizing(repeat_params, repeat_count));
|
||||
} else {
|
||||
// FIXME: Implement MinMax, etc.
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (component_value.is_block()) {
|
||||
params.append(Length::make_auto());
|
||||
params.append(GridTrackSize(Length::make_auto()));
|
||||
continue;
|
||||
}
|
||||
if (component_value.is(Token::Type::Ident) && component_value.token().ident().equals_ignoring_case("auto"sv)) {
|
||||
params.append(Length::make_auto());
|
||||
params.append(GridTrackSize(Length::make_auto()));
|
||||
continue;
|
||||
}
|
||||
if (component_value.token().type() == Token::Type::Dimension) {
|
||||
|
@ -5525,9 +5521,9 @@ RefPtr<StyleValue> Parser::parse_grid_track_sizes(Vector<ComponentValue> const&
|
|||
if (!dimension.has_value())
|
||||
return GridTrackSizeStyleValue::create({});
|
||||
if (dimension->is_length())
|
||||
params.append(dimension->length());
|
||||
params.append(GridTrackSize(dimension->length()));
|
||||
if (dimension->is_percentage())
|
||||
params.append(dimension->percentage());
|
||||
params.append(GridTrackSize(dimension->percentage()));
|
||||
}
|
||||
return GridTrackSizeStyleValue::create(params);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue