LibWeb: Expand minmax in grid tracks defined by grid-auto-rows/columns

Use GridTrack::create_from_definition() that takes care of minmax().
This commit is contained in:
Aliaksandr Kalenik 2023-06-11 22:18:01 +03:00 committed by Andreas Kling
parent 57581735b7
commit 3fba0a944a
Notes: sideshowbarker 2024-07-17 06:00:02 +09:00
3 changed files with 29 additions and 8 deletions

View file

@ -0,0 +1,5 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x600 [BFC] children: not-inline
BlockContainer <body> at (8,8) content-size 784x200 children: not-inline
Box <div.grid> at (8,8) content-size 200x200 [GFC] children: not-inline
BlockContainer <div.item> at (8,8) content-size 100x100 [BFC] children: not-inline

View file

@ -0,0 +1,16 @@
<style>
.grid {
display: grid;
grid-auto-columns: minmax(50px, 100px);
grid-auto-rows: minmax(50px, 100px);
width: 200px;
height: 200px;
}
.item {
background-color: pink;
width: 100%;
height: 100%;
}
</style>
<div class="grid"><div class="item"></div>

View file

@ -580,8 +580,8 @@ void GridFormattingContext::initialize_grid_tracks_for_columns_and_rows(Availabl
auto negative_index_implied_column_tracks_count = abs(m_occupation_grid.min_column_index());
for (int column_index = 0; column_index < negative_index_implied_column_tracks_count; column_index++) {
if (grid_auto_columns.size() > 0) {
auto size = grid_auto_columns[implicit_column_index % grid_auto_columns.size()];
m_grid_columns.append(GridTrack(size.grid_size()));
auto definition = grid_auto_columns[implicit_column_index % grid_auto_columns.size()];
m_grid_columns.append(GridTrack::create_from_definition(definition));
} else {
m_grid_columns.append(GridTrack());
}
@ -590,8 +590,8 @@ void GridFormattingContext::initialize_grid_tracks_for_columns_and_rows(Availabl
initialize_grid_tracks_from_definition(available_space, grid_computed_values.grid_template_columns().track_list(), m_grid_columns);
for (size_t column_index = m_grid_columns.size(); column_index < m_occupation_grid.column_count(); column_index++) {
if (grid_auto_columns.size() > 0) {
auto size = grid_auto_columns[implicit_column_index % grid_auto_columns.size()];
m_grid_columns.append(GridTrack(size.grid_size()));
auto definition = grid_auto_columns[implicit_column_index % grid_auto_columns.size()];
m_grid_columns.append(GridTrack::create_from_definition(definition));
} else {
m_grid_columns.append(GridTrack());
}
@ -604,8 +604,8 @@ void GridFormattingContext::initialize_grid_tracks_for_columns_and_rows(Availabl
auto negative_index_implied_row_tracks_count = abs(m_occupation_grid.min_row_index());
for (int row_index = 0; row_index < negative_index_implied_row_tracks_count; row_index++) {
if (grid_auto_rows.size() > 0) {
auto size = grid_auto_rows[implicit_row_index % grid_auto_rows.size()];
m_grid_rows.append(GridTrack(size.grid_size()));
auto definition = grid_auto_rows[implicit_row_index % grid_auto_rows.size()];
m_grid_rows.append(GridTrack::create_from_definition(definition));
} else {
m_grid_rows.append(GridTrack());
}
@ -614,8 +614,8 @@ void GridFormattingContext::initialize_grid_tracks_for_columns_and_rows(Availabl
initialize_grid_tracks_from_definition(available_space, grid_computed_values.grid_template_rows().track_list(), m_grid_rows);
for (size_t row_index = m_grid_rows.size(); row_index < m_occupation_grid.row_count(); row_index++) {
if (grid_auto_rows.size() > 0) {
auto size = grid_auto_rows[implicit_row_index % grid_auto_rows.size()];
m_grid_rows.append(GridTrack(size.grid_size()));
auto definition = grid_auto_rows[implicit_row_index % grid_auto_rows.size()];
m_grid_rows.append(GridTrack::create_from_definition(definition));
} else {
m_grid_rows.append(GridTrack());
}