diff options
author | martinfalisse <martinmotteditfalisse@gmail.com> | 2022-10-01 13:13:18 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-10-06 21:16:01 +0200 |
commit | a528ea71d119ca15c770b76101e239dccd9bce75 (patch) | |
tree | 94af433549d4fba98be86a0a57150b1e6f8b3cba /Userland/Libraries | |
parent | 4dc2bd3df04369fd4f6284afdaea33cacbb3af43 (diff) | |
download | serenity-a528ea71d119ca15c770b76101e239dccd9bce75.zip |
LibWeb: Use span values for auto-positioned grid items
Auto-positioned items should also take into account the span attributes
passed to them.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp index e21652680b..86f34a65b0 100644 --- a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp @@ -461,14 +461,21 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const auto column_span = child_box.computed_values().grid_column_start().is_span() ? child_box.computed_values().grid_column_start().raw_value() : 1; 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_cell = false; + auto found_unoccupied_area = false; for (int row_index = auto_placement_cursor_y; row_index < (int)occupation_grid.size(); row_index++) { for (int column_index = auto_placement_cursor_x; column_index < (int)occupation_grid[0].size(); column_index++) { - if (!occupation_grid[row_index][column_index]) { - found_unoccupied_cell = true; - column_start = column_index; - row_start = row_index; - goto finish; + if (column_span + column_index <= static_cast<int>(occupation_grid[0].size())) { + auto found_all_available = true; + for (int span_index = 0; span_index < column_span; span_index++) { + if (occupation_grid[row_index][column_index + span_index]) + found_all_available = false; + } + if (found_all_available) { + found_unoccupied_area = true; + column_start = column_index; + row_start = row_index; + goto finish; + } } auto_placement_cursor_x = 0; } @@ -481,7 +488,7 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const // and column-start lines to the cursor's position. Otherwise, increment the auto-placement cursor's // row position (creating new rows in the implicit grid as necessary), set its column position to the // start-most column line in the implicit grid, and return to the previous step. - if (!found_unoccupied_cell) { + if (!found_unoccupied_area) { row_start = (int)occupation_grid.size(); maybe_add_row_to_occupation_grid((int)occupation_grid.size() + 1, occupation_grid); } |