1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:47:35 +00:00

LibWeb: Respect "auto flow" property in grid layout

Before this change, we only considering `grid-auto-flow` to determine
whether a row or column should be added when there was not enough space
in the implicit grid to fit the next unplaced item.

Now, we also choose the direction in which the "auto placement cursor"
is moved, based on the auto flow property.
This commit is contained in:
Aliaksandr Kalenik 2024-03-04 14:04:15 +01:00 committed by Andreas Kling
parent f9f98016e2
commit 4d8bc16812
14 changed files with 363 additions and 42 deletions

View file

@ -53,6 +53,11 @@ struct GridItem {
[[nodiscard]] int gap_adjusted_column(Box const& grid_box) const;
};
enum class FoundUnoccupiedPlace {
No,
Yes
};
class OccupationGrid {
public:
OccupationGrid(size_t columns_count, size_t rows_count)
@ -83,6 +88,8 @@ public:
bool is_occupied(int column_index, int row_index) const;
FoundUnoccupiedPlace find_unoccupied_place(GridDimension dimension, int& column_index, int& row_index, int column_span, int row_span) const;
private:
HashTable<GridPosition> m_occupation_grid;