소스 검색

LibWeb: Make auto-fit compatible with grid-gap

This fixes an error when using auto-fit with grid-gap, as previously
were not taking into account the fact that more columns had been added
to the grid yet the occupation grid had not grown.
martinfalisse 2 년 전
부모
커밋
35094fc744
1개의 변경된 파일13개의 추가작업 그리고 9개의 파일을 삭제
  1. 13 9
      Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp

+ 13 - 9
Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp

@@ -972,15 +972,19 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const
     if (grid_template_columns.track_list().size() == 1
     if (grid_template_columns.track_list().size() == 1
         && grid_template_columns.track_list().first().is_repeat()
         && grid_template_columns.track_list().first().is_repeat()
         && grid_template_columns.track_list().first().repeat().is_auto_fit()) {
         && grid_template_columns.track_list().first().repeat().is_auto_fit()) {
-        auto idx = 0;
-        for (auto& grid_column : m_grid_columns) {
-            // A collapsed track is treated as having a fixed track sizing function of 0px, and the gutters on
-            // either side of it—including any space allotted through distributed alignment—collapse.
-            if (!occupation_grid.is_occupied(idx, 0)) {
-                grid_column.base_size = 0;
-                grid_column.growth_limit = 0;
-            }
-            idx++;
+        for (size_t idx = 0; idx < m_grid_columns.size(); idx++) {
+            auto column_to_check = box.computed_values().column_gap().is_auto() ? idx : idx / 2;
+            if (occupation_grid.is_occupied(column_to_check, 0))
+                continue;
+            if (!box.computed_values().column_gap().is_auto() && idx % 2 != 0)
+                continue;
+
+            // A collapsed track is treated as having a fixed track sizing function of 0px
+            m_grid_columns[idx].base_size = 0;
+            m_grid_columns[idx].growth_limit = 0;
+
+            // FIXME: And the gutters on either side of it—including any space allotted through distributed
+            // alignment—collapse.
         }
         }
     }
     }