Base+LibWeb: Make sure grid positions don't cause out of bounds

Add some tests to the test page to make sure that different combinations
of GridTrackPlacement don't cause out of bounds issues.
This commit is contained in:
martinfalisse 2022-09-26 14:04:05 +02:00 committed by Andreas Kling
parent 97230c4ddb
commit 84290ed7c8
2 changed files with 14 additions and 5 deletions

View file

@ -46,15 +46,18 @@
<div class="grid-item" style="grid-row: span 2 / 1; grid-column: span 2 / 1;">1</div>
<div class="grid-item" style="grid-row: span 2 / 1;">2</div>
<div class="grid-item" style="grid-column: span 2 / 1;">3</div>
<div class="grid-item" style="grid-column-end: 1; grid-row-end: 1;">6</div>
</div>
<!-- 0 positioned grid items -->
<!-- 0 positioned grid items and similar inputs -->
<p>If you can see this message then the test passed.</p>
<div class="grid-container">
<div class="grid-item" style="grid-row-end: 0;">1</div>
<div class="grid-item" style="grid-row: 0 / 0;">2</div>
<div class="grid-item" style="grid-column: 0 / 1;">3</div>
<div class="grid-item" style="grid-row: 1 / 0;">4</div>
<div class="grid-item" style="grid-row-end: 0;">2</div>
<div class="grid-item" style="grid-row: 0 / 0;">3</div>
<div class="grid-item" style="grid-column: 0 / 1;">4</div>
<div class="grid-item" style="grid-row: 1 / 0;">5</div>
<div class="grid-item" style="grid-row-end: 1;">1</div>
<div class="grid-item" style="grid-column-end: 1;">6</div>
</div>
<!-- Different column sizes -->

View file

@ -251,6 +251,9 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const
if (row_start != row_end)
row_span = row_end - row_start;
}
// FIXME: Have yet to find the spec for this.
if (!child_box.computed_values().grid_row_start().is_position() && child_box.computed_values().grid_row_end().is_position() && row_end == 1)
row_start = 1;
// If the placement contains two spans, remove the one contributed by the end grid-placement
// property.
@ -361,6 +364,9 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const
if (column_start < 0)
column_start = 1;
}
// FIXME: Have yet to find the spec for this.
if (!child_box.computed_values().grid_column_start().is_position() && child_box.computed_values().grid_column_end().is_position() && column_end == 1)
column_start = 1;
// If a name is given as a <custom-ident>, only lines with that name are counted. If not enough
// lines with that name exist, all implicit grid lines on the side of the explicit grid