Title: [266173] trunk
Revision
266173
Author
obru...@igalia.com
Date
2020-08-26 10:40:36 -0700 (Wed, 26 Aug 2020)

Log Message

[css-grid] Set available column space before grid items prelayout
https://bugs.webkit.org/show_bug.cgi?id=199648

Reviewed by Javier Fernandez.

LayoutTests/imported/w3c:

Import WPT test.

* web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-008-expected.html: Added.
* web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-008.html: Added.
* web-platform-tests/css/css-grid/alignment/self-baseline/w3c-import.log:

Source/WebCore:

Before running the grid track sizing algorithm, there is a prelayout
step which takes care of the baseline alignment of the items.
In order to do that, we estimate the size of the grid area, since we
have not calculated the final size yet.

The problem was that, when calculating this estimate, the available
column space had not been set yet. So if a column had a percentage track
sizing function, it would be treated as auto and the estimated size
would be wrong.

This patch sets the available column space so that we can resolve
percentage track sizing functions and get a more correct estimate.

Test: imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-008.html

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::layoutBlock):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (266172 => 266173)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-08-26 17:34:57 UTC (rev 266172)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-08-26 17:40:36 UTC (rev 266173)
@@ -1,3 +1,16 @@
+2020-08-26  Oriol Brufau  <obru...@igalia.com>
+
+        [css-grid] Set available column space before grid items prelayout
+        https://bugs.webkit.org/show_bug.cgi?id=199648
+
+        Reviewed by Javier Fernandez.
+
+        Import WPT test.
+
+        * web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-008-expected.html: Added.
+        * web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-008.html: Added.
+        * web-platform-tests/css/css-grid/alignment/self-baseline/w3c-import.log:
+
 2020-08-26  Youenn Fablet  <you...@apple.com>
 
         enumerateDevices should expose audiooutput devices that are tied to an audio input device

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-008-expected.html (0 => 266173)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-008-expected.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-008-expected.html	2020-08-26 17:40:36 UTC (rev 266173)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<style>
+div {
+  float: left;
+  width: 200px;
+  height: 200px;
+  background: green;
+}
+</style>
+<div></div>
+<div style="margin-top: 100px"></div>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-008.html (0 => 266173)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-008.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-008.html	2020-08-26 17:40:36 UTC (rev 266173)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Grid Layout Test: baseline context and self alignment</title>
+<link rel="author" title="Oriol Brufau" href="" />
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="match" href=""
+<link rel="stylesheet" href=""
+<meta name="assert" content="Test baseline alignment with percentage track sizing functions and grid items being or containing replaced elements with aspect ratio and percentage sizes." />
+<style>
+.grid {
+  display: grid;
+  width: 400px;
+  grid-template-columns: 25% 25% 25% 25%;
+  line-height: 0;
+}
+.percent {
+  width: 100%;
+}
+canvas {
+  background: green;
+}
+</style>
+<div class="grid alignItemsBaseline">
+  <canvas width="100" height="200"></canvas>
+  <canvas width="200" height="400" class="percent"></canvas>
+  <div>
+    <canvas width="100" height="100" class="percent"></canvas>
+    <canvas width="100" height="100" class="percent"></canvas>
+  </div>
+  <div class="percent">
+    <canvas width="100" height="100" class="percent"></canvas>
+    <canvas width="100" height="100" class="percent"></canvas>
+  </div>
+</div>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/w3c-import.log (266172 => 266173)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/w3c-import.log	2020-08-26 17:34:57 UTC (rev 266172)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/w3c-import.log	2020-08-26 17:40:36 UTC (rev 266173)
@@ -30,6 +30,8 @@
 /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-006.html
 /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-007-expected.html
 /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-007.html
+/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-008-expected.html
+/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-008.html
 /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-changes-grid-area-size-001-expected.xht
 /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-changes-grid-area-size-001.html
 /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-changes-grid-area-size-002-expected.xht

Modified: trunk/Source/WebCore/ChangeLog (266172 => 266173)


--- trunk/Source/WebCore/ChangeLog	2020-08-26 17:34:57 UTC (rev 266172)
+++ trunk/Source/WebCore/ChangeLog	2020-08-26 17:40:36 UTC (rev 266173)
@@ -1,3 +1,28 @@
+2020-08-26  Oriol Brufau  <obru...@igalia.com>
+
+        [css-grid] Set available column space before grid items prelayout
+        https://bugs.webkit.org/show_bug.cgi?id=199648
+
+        Reviewed by Javier Fernandez.
+
+        Before running the grid track sizing algorithm, there is a prelayout
+        step which takes care of the baseline alignment of the items.
+        In order to do that, we estimate the size of the grid area, since we
+        have not calculated the final size yet.
+
+        The problem was that, when calculating this estimate, the available
+        column space had not been set yet. So if a column had a percentage track
+        sizing function, it would be treated as auto and the estimated size
+        would be wrong.
+
+        This patch sets the available column space so that we can resolve
+        percentage track sizing functions and get a more correct estimate.
+
+        Test: imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-008.html
+
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::layoutBlock):
+
 2020-08-26  Andres Gonzalez  <andresg...@apple.com>
 
         Code cleanup and consistent naming in AXIsolatedTree classes, no change in behavior.

Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (266172 => 266173)


--- trunk/Source/WebCore/rendering/RenderGrid.cpp	2020-08-26 17:34:57 UTC (rev 266172)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp	2020-08-26 17:40:36 UTC (rev 266173)
@@ -230,6 +230,7 @@
         LayoutUnit availableSpaceForColumns = availableLogicalWidth();
         placeItemsOnGrid(m_trackSizingAlgorithm, availableSpaceForColumns);
 
+        m_trackSizingAlgorithm.setAvailableSpace(ForColumns, availableSpaceForColumns);
         performGridItemsPreLayout(m_trackSizingAlgorithm);
 
         // 1- First, the track sizing algorithm is used to resolve the sizes of the
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to