소스 검색

LibWeb: Remove hardcoded span = 2 while sizing spanning items in GFC

Aliaksandr Kalenik 2 년 전
부모
커밋
0019b901a0

+ 21 - 0
Tests/LibWeb/Layout/expected/grid/grid-span-4.txt

@@ -0,0 +1,21 @@
+Viewport <#document> at (0,0) content-size 800x600 children: not-inline
+  BlockContainer <html> at (1,1) content-size 798x65.640625 [BFC] children: not-inline
+    Box <body> at (10,10) content-size 780x47.640625 [GFC] children: not-inline
+      BlockContainer <div.foo> at (11,11) content-size 778x21.8125 [BFC] children: inline
+        line 0 width: 33.9375, height: 21.828125, bottom: 21.828125, baseline: 16.890625
+          frag 0 from TextNode start: 0, length: 3, rect: [11,11 33.9375x21.828125]
+            "foo"
+        TextNode <#text>
+      BlockContainer <div.bar> at (11,34.8125) content-size 778x21.828125 [BFC] children: inline
+        line 0 width: 34.546875, height: 21.828125, bottom: 21.828125, baseline: 16.890625
+          frag 0 from TextNode start: 0, length: 3, rect: [11,34.8125 34.546875x21.828125]
+            "bar"
+        TextNode <#text>
+
+PaintableWithLines (Viewport<#document>) [0,0 800x600]
+  PaintableWithLines (BlockContainer<HTML>) [0,0 800x67.640625]
+    PaintableBox (Box<BODY>) [9,9 782x49.640625]
+      PaintableWithLines (BlockContainer<DIV>.foo) [10,10 780x23.8125] overflow: [11,11 778x21.828125]
+        TextPaintable (TextNode<#text>)
+      PaintableWithLines (BlockContainer<DIV>.bar) [10,33.8125 780x23.828125]
+        TextPaintable (TextNode<#text>)

+ 16 - 0
Tests/LibWeb/Layout/input/grid/grid-span-4.html

@@ -0,0 +1,16 @@
+<!doctype html><style>
+* {
+    border: 1px solid black;
+    font-size: 20px;
+}
+body {
+    display: grid;
+    grid-template-rows: repeat(10, min-content) 1fr;
+}
+.foo {
+    grid-area: 4 / 1 / 8 / 2;
+}
+.bar {
+    grid-area: 9 / 1 / 10 / 2;
+}
+</style><body><div class="foo">foo</div><div class="bar">bar</div>

+ 2 - 3
Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp

@@ -754,9 +754,8 @@ void GridFormattingContext::resolve_intrinsic_track_sizes(AvailableSpace const&
     size_t max_item_span = 1;
     for (auto& item : m_grid_items)
         max_item_span = max(item.span(dimension), max_item_span);
-    for (size_t span = 2; span <= max_item_span; span++) {
-        increase_sizes_to_accommodate_spanning_items_crossing_content_sized_tracks(available_space, dimension, 2);
-    }
+    for (size_t span = 2; span <= max_item_span; span++)
+        increase_sizes_to_accommodate_spanning_items_crossing_content_sized_tracks(available_space, dimension, span);
 
     // 4. Increase sizes to accommodate spanning items crossing flexible tracks: Next, repeat the previous
     // step instead considering (together, rather than grouped by span size) all items that do span a