summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAliaksandr Kalenik <kalenik.aliaksandr@gmail.com>2023-05-17 12:33:22 +0300
committerAndreas Kling <kling@serenityos.org>2023-05-17 15:55:14 +0200
commit628efda75407d44160d100ea3ba175130832b8b7 (patch)
tree91870f6ff70358cd55fcdca15fdb2d8522c4c45f /Userland
parent79e76ae64c0aad68829952b1e5ff386d5aeab147 (diff)
downloadserenity-628efda75407d44160d100ea3ba175130832b8b7.zip
LibWeb: Consider span > 1 while getting available space for items in GFC
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp34
1 files changed, 30 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp
index 590d5cc266..120e413fa7 100644
--- a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp
@@ -1649,11 +1649,37 @@ CSSPixels GridFormattingContext::containing_block_size_for_item(GridItem const&
AvailableSpace GridFormattingContext::get_available_space_for_item(GridItem const& item) const
{
- auto const& column_track = m_grid_columns[item.raw_column()];
- AvailableSize available_width = column_track.has_definite_base_size ? AvailableSize::make_definite(column_track.base_size) : AvailableSize::make_indefinite();
+ CSSPixels column_width = 0;
+ bool has_columns_with_definite_base_size = false;
+ for (size_t span = 0; span < item.raw_column_span(); span++) {
+ // FIXME: This check should not be need if grid item positioning works correct
+ if (item.raw_column() + span >= m_grid_columns.size())
+ break;
+
+ auto& track = m_grid_columns[item.raw_column() + span];
+ column_width += track.base_size;
+
+ if (track.has_definite_base_size)
+ has_columns_with_definite_base_size = true;
+ }
+
+ AvailableSize available_width = has_columns_with_definite_base_size ? AvailableSize::make_definite(column_width) : AvailableSize::make_indefinite();
+
+ CSSPixels column_height = 0;
+ bool has_rows_with_definite_base_size = false;
+ for (size_t span = 0; span < item.raw_row_span(); span++) {
+ // FIXME: This check should not be need if grid item positioning works correct
+ if (item.raw_row() + span >= m_grid_rows.size())
+ break;
+
+ auto& track = m_grid_rows[item.raw_row() + span];
+ column_height += track.base_size;
+
+ if (track.has_definite_base_size)
+ has_rows_with_definite_base_size = true;
+ }
- auto const& row_track = m_grid_rows[item.raw_row()];
- AvailableSize available_height = row_track.has_definite_base_size ? AvailableSize::make_definite(row_track.base_size) : AvailableSize::make_indefinite();
+ AvailableSize available_height = has_rows_with_definite_base_size ? AvailableSize::make_definite(column_height) : AvailableSize::make_indefinite();
return AvailableSpace(available_width, available_height);
}