mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:47:45 +00:00
LibWeb+Base: Deal with column-spans greater than implicit grid
When the indicated column-span is greater than the implicit grid (like in cases when the grid has the default size of 1x1, and the column is supposed to span any number greater than that), then previously were crashing.
This commit is contained in:
parent
994d996ab2
commit
e537035cc6
2 changed files with 32 additions and 8 deletions
|
@ -267,6 +267,12 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const
|
|||
|
||||
int column_start = 0;
|
||||
auto column_span = child_box.computed_values().grid_column_start().is_span() ? child_box.computed_values().grid_column_start().raw_value() : 1;
|
||||
// https://drafts.csswg.org/css-grid/#auto-placement-algo
|
||||
// 8.5. Grid Item Placement Algorithm
|
||||
// 3.3. If the largest column span among all the items without a definite column position is larger
|
||||
// than the width of the implicit grid, add columns to the end of the implicit grid to accommodate
|
||||
// that column span.
|
||||
occupation_grid.maybe_add_column(column_span);
|
||||
bool found_available_column = false;
|
||||
for (int column_index = column_start; column_index < occupation_grid.column_count(); column_index++) {
|
||||
if (!occupation_grid.is_occupied(column_index, row_start)) {
|
||||
|
@ -299,11 +305,6 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const
|
|||
// and 2, respectively. Adding columns for "items not yet positioned but with a definite column"
|
||||
// will be done in step 4.
|
||||
|
||||
// 3.3. If the largest column span among all the items without a definite column position is larger
|
||||
// than the width of the implicit grid, add columns to the end of the implicit grid to accommodate
|
||||
// that column span.
|
||||
// NOTE: Done in step 1, 2, and will be done in step 4.
|
||||
|
||||
// 4. Position the remaining grid items.
|
||||
// For each grid item that hasn't been positioned by the previous steps, in order-modified document
|
||||
// order:
|
||||
|
@ -431,6 +432,12 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const
|
|||
// algorithm.
|
||||
auto column_start = 0;
|
||||
auto column_span = child_box.computed_values().grid_column_start().is_span() ? child_box.computed_values().grid_column_start().raw_value() : 1;
|
||||
// https://drafts.csswg.org/css-grid/#auto-placement-algo
|
||||
// 8.5. Grid Item Placement Algorithm
|
||||
// 3.3. If the largest column span among all the items without a definite column position is larger
|
||||
// than the width of the implicit grid, add columns to the end of the implicit grid to accommodate
|
||||
// that column span.
|
||||
occupation_grid.maybe_add_column(column_span);
|
||||
auto row_start = 0;
|
||||
auto row_span = child_box.computed_values().grid_row_start().is_span() ? child_box.computed_values().grid_row_start().raw_value() : 1;
|
||||
auto found_unoccupied_area = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue