Title: [192512] trunk
Revision
192512
Author
svil...@igalia.com
Date
2015-11-17 02:11:43 -0800 (Tue, 17 Nov 2015)

Log Message

[css-grid] Fix alignment with gutters and negative free spaces
https://bugs.webkit.org/show_bug.cgi?id=151307

Reviewed by Zalan Bujtas.

Source/WebCore:

This is a regression caused by r192154. The problem was that
the free space was not properly computed when the grid
container was narrower than the track sizes + gutters size for
a given axis. The culprit was an unneeded clamp to 0 which was
polluting the freeSpace computation as the track sizing
algorithm works perfectly OK with negative freeSpace values.

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

LayoutTests:

* fast/css-grid-layout/grid-gutters-and-alignment-expected.txt:
* fast/css-grid-layout/grid-gutters-and-alignment.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (192511 => 192512)


--- trunk/LayoutTests/ChangeLog	2015-11-17 09:57:42 UTC (rev 192511)
+++ trunk/LayoutTests/ChangeLog	2015-11-17 10:11:43 UTC (rev 192512)
@@ -1,3 +1,13 @@
+2015-11-17  Sergio Villar Senin  <svil...@igalia.com>
+
+        [css-grid] Fix alignment with gutters and negative free spaces
+        https://bugs.webkit.org/show_bug.cgi?id=151307
+
+        Reviewed by Zalan Bujtas.
+
+        * fast/css-grid-layout/grid-gutters-and-alignment-expected.txt:
+        * fast/css-grid-layout/grid-gutters-and-alignment.html:
+
 2015-11-17  Hunseop Jeong  <hs85.je...@samsung.com>
 
         Unreviewed EFL Gardening on 16th Nov.

Modified: trunk/LayoutTests/fast/css-grid-layout/grid-gutters-and-alignment-expected.txt (192511 => 192512)


--- trunk/LayoutTests/fast/css-grid-layout/grid-gutters-and-alignment-expected.txt	2015-11-17 09:57:42 UTC (rev 192511)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-gutters-and-alignment-expected.txt	2015-11-17 10:11:43 UTC (rev 192512)
@@ -56,3 +56,21 @@
 direction: RTL (parall) | align-items: 'self-start' | justify-items: 'self-start'
 
 PASS
+Negative free space. justify-content: start
+
+PASS
+Negative free space. justify-content: center
+
+PASS
+Negative free space. justify-content: end
+
+PASS
+Negative free space. align-content: start
+
+PASS
+Negative free space. align-content: center
+
+PASS
+Negative free space. align-content: end
+
+PASS

Modified: trunk/LayoutTests/fast/css-grid-layout/grid-gutters-and-alignment.html (192511 => 192512)


--- trunk/LayoutTests/fast/css-grid-layout/grid-gutters-and-alignment.html	2015-11-17 09:57:42 UTC (rev 192511)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-gutters-and-alignment.html	2015-11-17 10:11:43 UTC (rev 192512)
@@ -40,6 +40,22 @@
     position: relative; /* For the <p> comments */
 }
 
+.gridWithAutoColumns {
+    grid-auto-columns: 20px;
+    border: 2px solid black;
+    width: 10px;
+    margin-left: 200px;
+    position: relative;
+}
+
+.gridWithAutoRows {
+    -webkit-grid-auto-rows: 40px;
+    border: 2px solid black;
+    height: 50px;
+    width: 20px;
+    position: relative;
+}
+
 .stretch {
     align-self: stretch;
     justify-self: stretch;
@@ -63,6 +79,11 @@
     margin: 4px 8px 12px 16px;
 }
 
+.thirdRowFirstColumn {
+    background-color: lime;
+    grid-row: 3;
+    grid-column: 1;
+}
 
 .container {
     position: relative;
@@ -294,4 +315,60 @@
     </div>
 </div>
 
+<!-- Check behavior with negative free space -->
+<div class="container">
+    <p>Negative free space. justify-content: start</p>
+    <div class="grid gridWithAutoColumns justifyContentStart gridRowColumnGaps" data-expected-width="14" data-expected-height="44">
+        <div class="cell firstRowFirstColumn"  data-offset-x="0" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
+        <div class="cell firstRowSecondColumn"  data-offset-x="41" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
+        <div class="cell firstRowThirdColumn"  data-offset-x="82" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
+    </div>
+</div>
+
+<div class="container">
+    <p>Negative free space. justify-content: center</p>
+    <div class="grid gridWithAutoColumns justifyContentCenter gridRowColumnGaps" data-expected-width="14" data-expected-height="44">
+        <div class="cell firstRowFirstColumn"  data-offset-x="-46" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
+        <div class="cell firstRowSecondColumn"  data-offset-x="-5" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
+        <div class="cell firstRowThirdColumn"  data-offset-x="36" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
+    </div>
+</div>
+
+<div class="container">
+    <p>Negative free space. justify-content: end</p>
+    <div class="grid gridWithAutoColumns justifyContentEnd gridRowColumnGaps" data-expected-width="14" data-expected-height="44">
+        <div class="cell firstRowFirstColumn"  data-offset-x="-92" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
+        <div class="cell firstRowSecondColumn"  data-offset-x="-51" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
+        <div class="cell firstRowThirdColumn"  data-offset-x="-10" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
+    </div>
+</div>
+
+<!-- NOTE: for the following 3 test cases we use margins just for enhancing the visual output (otherwise grids would overlap) -->
+<div class="container" style="margin-bottom: 125px;">
+    <p>Negative free space. align-content: start</p>
+    <div class="grid gridWithAutoRows alignContentStart gridRowColumnGaps" data-expected-width="24" data-expected-height="54">
+        <div class="cell firstRowFirstColumn"  data-offset-x="0" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
+        <div class="cell secondRowFirstColumn"  data-offset-x="0" data-offset-y="57" data-expected-width="20" data-expected-height="40"></div>
+        <div class="cell thirdRowFirstColumn"  data-offset-x="0" data-offset-y="114" data-expected-width="20" data-expected-height="40"></div>
+    </div>
+</div>
+
+<div class="container" style="margin-bottom: 75px;">
+    <p>Negative free space. align-content: center</p>
+    <div class="grid gridWithAutoRows alignContentCenter gridRowColumnGaps" style="margin-top: 75px" data-expected-width="24" data-expected-height="54">
+        <div class="cell firstRowFirstColumn"  data-offset-x="0" data-offset-y="-52" data-expected-width="20" data-expected-height="40"></div>
+        <div class="cell secondRowFirstColumn"  data-offset-x="0" data-offset-y="5" data-expected-width="20" data-expected-height="40"></div>
+        <div class="cell thirdRowFirstColumn"  data-offset-x="0" data-offset-y="62" data-expected-width="20" data-expected-height="40"></div>
+    </div>
+</div>
+
+<div class="container" style="margin-bottom: 25px;">
+    <p>Negative free space. align-content: end</p>
+    <div class="grid gridWithAutoRows alignContentEnd gridRowColumnGaps" style="margin-top: 125px" data-expected-width="24" data-expected-height="54">
+        <div class="cell firstRowFirstColumn"  data-offset-x="0" data-offset-y="-104" data-expected-width="20" data-expected-height="40"></div>
+        <div class="cell secondRowFirstColumn"  data-offset-x="0" data-offset-y="-47" data-expected-width="20" data-expected-height="40"></div>
+        <div class="cell thirdRowFirstColumn"  data-offset-x="0" data-offset-y="10" data-expected-width="20" data-expected-height="40"></div>
+    </div>
+</div>
+
 </body>

Modified: trunk/Source/WebCore/ChangeLog (192511 => 192512)


--- trunk/Source/WebCore/ChangeLog	2015-11-17 09:57:42 UTC (rev 192511)
+++ trunk/Source/WebCore/ChangeLog	2015-11-17 10:11:43 UTC (rev 192512)
@@ -1,3 +1,20 @@
+2015-11-17  Sergio Villar Senin  <svil...@igalia.com>
+
+        [css-grid] Fix alignment with gutters and negative free spaces
+        https://bugs.webkit.org/show_bug.cgi?id=151307
+
+        Reviewed by Zalan Bujtas.
+
+        This is a regression caused by r192154. The problem was that
+        the free space was not properly computed when the grid
+        container was narrower than the track sizes + gutters size for
+        a given axis. The culprit was an unneeded clamp to 0 which was
+        polluting the freeSpace computation as the track sizing
+        algorithm works perfectly OK with negative freeSpace values.
+
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::computeTrackSizesForDirection):
+
 2015-11-17  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GStreamer] Use RunLoop instead of GMainLoop in AudioFileReaderGStreamer

Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (192511 => 192512)


--- trunk/Source/WebCore/rendering/RenderGrid.cpp	2015-11-17 09:57:42 UTC (rev 192511)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp	2015-11-17 10:11:43 UTC (rev 192512)
@@ -316,8 +316,7 @@
 {
     ASSERT(freeSpace >= 0);
     LayoutUnit totalGuttersSize = guttersSize(direction, direction == ForRows ? gridRowCount() : gridColumnCount());
-    freeSpace = std::max<LayoutUnit>(0, freeSpace - totalGuttersSize);
-    sizingData.setFreeSpaceForDirection(direction, freeSpace);
+    sizingData.setFreeSpaceForDirection(direction, freeSpace - totalGuttersSize);
 
     LayoutUnit baseSizes, growthLimits;
     computeUsedBreadthOfGridTracks(direction, sizingData, baseSizes, growthLimits);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to