Title: [210211] trunk
Revision
210211
Author
[email protected]
Date
2016-12-30 02:53:58 -0800 (Fri, 30 Dec 2016)

Log Message

[css-grid] Isolate instrinsic size computation from layout
https://bugs.webkit.org/show_bug.cgi?id=166530

Reviewed by Darin Adler.

Source/WebCore:

This is the last patch of the items placement data refactoring. By using a different Grid
instance in computeIntrinsicLogicalWidths we effectively isolate the intrinsic size
computation from the layout. They are now using different data structures so they don't
interfere each other.

This also means that we no longer reuse the placement of items done in the intrinsic size
computation. That shouldn't be a big issue once we make m_grid persistent on RenderGrid.

Last but not least, this patch finally removes the ugly const_cast's we had in
computeIntrinsicLogicalWidths() as we no longer modify the internal state of RenderGrid.

Tests: fast/css-grid-layout/grid-auto-repeat-intrinsic.html
       fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks.html

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::computeIntrinsicLogicalWidths): Use a new instance of Grid.
(WebCore::RenderGrid::computeEmptyTracksForAutoRepeat): Fixed a missing m_grid -> grid
rename.
(WebCore::RenderGrid::placeItemsOnGrid): Constify it. It nows repositions the items if the
number of auto repeat tracks has changed.
* rendering/RenderGrid.h:

LayoutTests:

* fast/css-grid-layout/grid-auto-repeat-intrinsic-expected.txt: Added.
* fast/css-grid-layout/grid-auto-repeat-intrinsic.html: Added.
* fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks-expected.txt: Added.
* fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (210210 => 210211)


--- trunk/LayoutTests/ChangeLog	2016-12-30 10:09:05 UTC (rev 210210)
+++ trunk/LayoutTests/ChangeLog	2016-12-30 10:53:58 UTC (rev 210211)
@@ -1,3 +1,15 @@
+2016-12-28  Sergio Villar Senin  <[email protected]>
+
+        [css-grid] Isolate instrinsic size computation from layout
+        https://bugs.webkit.org/show_bug.cgi?id=166530
+
+        Reviewed by Darin Adler.
+
+        * fast/css-grid-layout/grid-auto-repeat-intrinsic-expected.txt: Added.
+        * fast/css-grid-layout/grid-auto-repeat-intrinsic.html: Added.
+        * fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks-expected.txt: Added.
+        * fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks.html: Added.
+
 2016-12-28  Carlos Alberto Lopez Perez  <[email protected]>
 
         [Gardening] Remove INDIE_UI related entries from TestExpectation files.

Added: trunk/LayoutTests/fast/css-grid-layout/grid-auto-repeat-intrinsic-expected.txt (0 => 210211)


--- trunk/LayoutTests/fast/css-grid-layout/grid-auto-repeat-intrinsic-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-auto-repeat-intrinsic-expected.txt	2016-12-30 10:53:58 UTC (rev 210211)
@@ -0,0 +1,10 @@
+This test checks that auto repeat tracks are properly recomputed and items are properly repositioned when grids have intrinsic inline sizes.
+
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
Property changes on: trunk/LayoutTests/fast/css-grid-layout/grid-auto-repeat-intrinsic-expected.txt
___________________________________________________________________

Added: svn:eol-style

+LF \ No newline at end of property

Added: trunk/LayoutTests/fast/css-grid-layout/grid-auto-repeat-intrinsic.html (0 => 210211)


--- trunk/LayoutTests/fast/css-grid-layout/grid-auto-repeat-intrinsic.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-auto-repeat-intrinsic.html	2016-12-30 10:53:58 UTC (rev 210211)
@@ -0,0 +1,105 @@
+<!DOCTYPE html>
+
+<link href="" rel="stylesheet">
+<link href="" rel="stylesheet">
+
+<style>
+.grid {
+    border: 2px solid black;
+    position: relative;
+    padding-top: 10px;
+    justify-items: start;
+}
+
+.item {
+    background: cyan;
+    height: 20px;
+}
+
+.gridAutoFillFixed { grid-template-columns: repeat(auto-fill, 20px) minmax(-webkit-min-content, 40px); }
+.gridAutoFillAuto { grid-template-columns: repeat(auto-fill, 10px) minmax(60px, auto); }
+.gridAutoFitFixed { grid-template-columns: repeat(auto-fit, 20px) minmax(-webkit-min-content, 40px); }
+.gridAutoFitAuto { grid-template-columns: repeat(auto-fit, 10px) minmax(60px, auto); }
+
+.paddingTop { padding-top: 10px; }
+
+.abs {
+    height: 5px;
+    position: absolute;
+    width: 100%;
+}
+</style>
+
+<script src=""
+
+<body _onload_="checkLayout('.grid')">
+
+<p>This test checks that auto repeat tracks are properly recomputed and items are properly repositioned when grids have intrinsic inline sizes.</p>
+
+<div class="grid gridAutoFillFixed paddingTop max-content" data-expected-width="104" data-expected-height="34">
+    <div class="item" style="grid-column: 1 / -1; width: 100px;" data-expected-width="100" data-expected-height="20" data-expected-x="0" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 1 / 2; background: purple;" data-expected-width="20" data-expected-height="5" data-expected-x="0" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 2 / 3; background: orange;" data-expected-width="20" data-expected-height="5" data-expected-x="20" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 3 / 4; background: yellow;" data-expected-width="20" data-expected-height="5" data-expected-x="40" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 4 / 5; background: green;" data-expected-width="40" data-expected-height="5" data-expected-x="60" data-expected-y="0"></div>
+</div>
+
+<div class="grid gridAutoFillFixed paddingTop min-content" data-expected-width="104" data-expected-height="34">
+    <div class="item" style="grid-column: 1 / -1; width: 100px;" data-expected-width="100" data-expected-height="20" data-expected-x="0" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 1 / 2; background: purple;" data-expected-width="20" data-expected-height="5" data-expected-x="0" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 2 / 3; background: orange;" data-expected-width="20" data-expected-height="5" data-expected-x="20" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 3 / 4; background: yellow;" data-expected-width="20" data-expected-height="5" data-expected-x="40" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 4 / 5; background: green;" data-expected-width="40" data-expected-height="5" data-expected-x="60" data-expected-y="0"></div>
+</div>
+
+<div class="grid gridAutoFillAuto paddingTop max-content" data-expected-width="104" data-expected-height="34">
+    <div class="item" style="grid-column: 1 / -1; width: 100px;" data-expected-width="100" data-expected-height="20" data-expected-x="0" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 1 / 2; background: purple;" data-expected-width="10" data-expected-height="5" data-expected-x="0" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 2 / 3; background: orange;" data-expected-width="10" data-expected-height="5" data-expected-x="20" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 3 / 4; background: yellow;" data-expected-width="10" data-expected-height="5" data-expected-x="40" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 4 / 5; background: green;" data-expected-width="10" data-expected-height="5" data-expected-x="60" data-expected-y="0"></div>
+</div>
+
+<div class="grid gridAutoFillAuto paddingTop min-content" data-expected-width="74" data-expected-height="34">
+    <div class="item" style="grid-column: 1 / -1; width: 100px;" data-expected-width="100" data-expected-height="20" data-expected-x="0" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 1 / 2; background: purple;" data-expected-width="10" data-expected-height="5" data-expected-x="0" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 2 / 3; background: orange;" data-expected-width="60" data-expected-height="5" data-expected-x="20" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 3 / 4; background: yellow;" data-expected-width="0" data-expected-height="5" data-expected-x="40" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 4 / 5; background: green;" data-expected-width="70" data-expected-height="5" data-expected-x="60" data-expected-y="0"></div>
+</div>
+
+<!-- auto-fill -->
+
+<div class="grid gridAutoFitFixed paddingTop max-content" data-expected-width="104" data-expected-height="34">
+    <div class="item" style="grid-column: 1 / -1; width: 100px;" data-expected-width="100" data-expected-height="20" data-expected-x="0" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 1 / 2; background: purple;" data-expected-width="20" data-expected-height="5" data-expected-x="0" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 2 / 3; background: orange;" data-expected-width="20" data-expected-height="5" data-expected-x="20" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 3 / 4; background: yellow;" data-expected-width="20" data-expected-height="5" data-expected-x="40" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 4 / 5; background: green;" data-expected-width="40" data-expected-height="5" data-expected-x="60" data-expected-y="0"></div>
+</div>
+
+<div class="grid gridAutoFitFixed paddingTop min-content" data-expected-width="104" data-expected-height="34">
+    <div class="item" style="grid-column: 1 / -1; width: 100px;" data-expected-width="100" data-expected-height="20" data-expected-x="0" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 1 / 2; background: purple;" data-expected-width="20" data-expected-height="5" data-expected-x="0" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 2 / 3; background: orange;" data-expected-width="20" data-expected-height="5" data-expected-x="20" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 3 / 4; background: yellow;" data-expected-width="20" data-expected-height="5" data-expected-x="40" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 4 / 5; background: green;" data-expected-width="40" data-expected-height="5" data-expected-x="60" data-expected-y="0"></div>
+</div>
+
+<div class="grid gridAutoFitAuto paddingTop max-content" data-expected-width="104" data-expected-height="34">
+    <div class="item" style="grid-column: 1 / -1; width: 100px;" data-expected-width="100" data-expected-height="20" data-expected-x="0" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 1 / 2; background: purple;" data-expected-width="10" data-expected-height="5" data-expected-x="0" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 2 / 3; background: orange;" data-expected-width="10" data-expected-height="5" data-expected-x="20" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 3 / 4; background: yellow;" data-expected-width="10" data-expected-height="5" data-expected-x="40" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 4 / 5; background: green;" data-expected-width="10" data-expected-height="5" data-expected-x="60" data-expected-y="0"></div>
+</div>
+
+<div class="grid gridAutoFitAuto paddingTop min-content" data-expected-width="74" data-expected-height="34">
+    <div class="item" style="grid-column: 1 / -1; width: 100px;" data-expected-width="100" data-expected-height="20" data-expected-x="0" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 1 / 2; background: purple;" data-expected-width="10" data-expected-height="5" data-expected-x="0" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 2 / 3; background: orange;" data-expected-width="60" data-expected-height="5" data-expected-x="20" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 3 / 4; background: yellow;" data-expected-width="0" data-expected-height="5" data-expected-x="40" data-expected-y="0"></div>
+    <div class="abs" style="grid-column: 4 / 5; background: green;" data-expected-width="70" data-expected-height="5" data-expected-x="60" data-expected-y="0"></div>
+</div>
+
+</body>
Property changes on: trunk/LayoutTests/fast/css-grid-layout/grid-auto-repeat-intrinsic.html
___________________________________________________________________

Added: svn:eol-style

+LF \ No newline at end of property

Added: svn:mime-type

+text/html \ No newline at end of property

Added: trunk/LayoutTests/fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks-expected.txt (0 => 210211)


--- trunk/LayoutTests/fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks-expected.txt	2016-12-30 10:53:58 UTC (rev 210211)
@@ -0,0 +1,9 @@
+This test checks that changing the min|max-content contributions of grid items properly recomputes both track sizes and grid positions in grids with auto repeat tracks.
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
Property changes on: trunk/LayoutTests/fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks-expected.txt
___________________________________________________________________

Added: svn:eol-style

+LF \ No newline at end of property

Added: trunk/LayoutTests/fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks.html (0 => 210211)


--- trunk/LayoutTests/fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks.html	2016-12-30 10:53:58 UTC (rev 210211)
@@ -0,0 +1,141 @@
+<!DOCTYPE html>
+<link href="" rel="stylesheet">
+<link href="" rel="stylesheet">
+<style>
+.grid {
+    border: 2px solid black;
+    position: relative;
+    min-width: 30px;
+
+    grid-auto-columns: 20px;
+
+    padding-top: 10px;
+    margin-bottom: 10px;
+}
+
+.abs { height: 5px; position: absolute; width: 100%; }
+
+</style>
+<script src=""
+<script>
+function setGridTemplate(id, gridTemplateRows, gridTemplateColumns)
+{
+     var gridElement = document.getElementById(id);
+     gridElement.style.gridTemplateRows = gridTemplateRows;
+     gridElement.style.gridTemplateColumns = gridTemplateColumns;
+}
+
+function setItemSize(id, width, height)
+{
+     var gridElement = document.getElementById(id);
+     gridElement.style.width = width;
+     gridElement.style.height = height;
+}
+
+function testGridDefinitions(gridItemsData)
+{
+    var length = gridItemsData.length;
+    for (i = 0; i < length; ++i) {
+        var item = document.getElementById(gridItemsData[i].id);
+        item.setAttribute("data-expected-width", gridItemsData[i].width);
+        item.setAttribute("data-expected-height", gridItemsData[i].height);
+        item.setAttribute("data-offset-x", gridItemsData[i].x);
+        item.setAttribute("data-offset-y", gridItemsData[i].y);
+    }
+
+    checkLayout(".grid");
+}
+
+function testChangingGridDefinitions()
+{
+     setGridTemplate('grid1', 'none', 'repeat(auto-fill, 20px) minmax(-webkit-min-content, 40px)');
+
+     setItemSize('item', '100px', '30px');
+     testGridDefinitions([
+         { 'id': 'item', 'width': '100', 'height': '30', 'x': '0', 'y': '10' },
+         { 'id': 'a1', 'width': '20', 'height': '5', 'x': '0', 'y': '0' },
+         { 'id': 'a2', 'width': '20', 'height': '5', 'x': '20', 'y': '0' },
+         { 'id': 'a3', 'width': '20', 'height': '5', 'x': '40', 'y': '0' },
+         { 'id': 'a4', 'width': '40', 'height': '5', 'x': '60', 'y': '0' }
+     ]);
+
+     setItemSize('item', '80px', '30px');
+     testGridDefinitions([
+         { 'id': 'item', 'width': '80', 'height': '30', 'x': '0', 'y': '10' },
+         { 'id': 'a1', 'width': '20', 'height': '5', 'x': '0', 'y': '0' },
+         { 'id': 'a2', 'width': '20', 'height': '5', 'x': '20', 'y': '0' },
+         { 'id': 'a3', 'width': '40', 'height': '5', 'x': '40', 'y': '0' },
+         { 'id': 'a4', 'width': '0', 'height': '5', 'x': '80', 'y': '0' }
+     ]);
+
+     setItemSize('item', '15px', '30px');
+     testGridDefinitions([
+         { 'id': 'item', 'width': '15', 'height': '30', 'x': '0', 'y': '10' },
+         { 'id': 'a1', 'width': '20', 'height': '5', 'x': '0', 'y': '0' },
+         { 'id': 'a2', 'width': '40', 'height': '5', 'x': '20', 'y': '0' },
+         { 'id': 'a3', 'width': '0', 'height': '5', 'x': '60', 'y': '0' },
+         { 'id': 'a4', 'width': '60', 'height': '5', 'x': '0', 'y': '0' }
+     ]);
+
+     setItemSize('item', '120px', '30px');
+     testGridDefinitions([
+         { 'id': 'item', 'width': '120', 'height': '30', 'x': '0', 'y': '10' },
+         { 'id': 'a1', 'width': '20', 'height': '5', 'x': '0', 'y': '0' },
+         { 'id': 'a2', 'width': '20', 'height': '5', 'x': '20', 'y': '0' },
+         { 'id': 'a3', 'width': '20', 'height': '5', 'x': '40', 'y': '0' },
+         { 'id': 'a4', 'width': '20', 'height': '5', 'x': '60', 'y': '0' }
+     ]);
+
+     var grid = document.getElementById('grid1');
+     grid.className = grid.className.replace('max-content', 'min-content');
+
+     setItemSize('item', '100px', '30px');
+     testGridDefinitions([
+         { 'id': 'item', 'width': '100', 'height': '30', 'x': '0', 'y': '10' },
+         { 'id': 'a1', 'width': '20', 'height': '5', 'x': '0', 'y': '0' },
+         { 'id': 'a2', 'width': '20', 'height': '5', 'x': '20', 'y': '0' },
+         { 'id': 'a3', 'width': '20', 'height': '5', 'x': '40', 'y': '0' },
+         { 'id': 'a4', 'width': '40', 'height': '5', 'x': '60', 'y': '0' }
+     ]);
+
+     setItemSize('item', '80px', '30px');
+     testGridDefinitions([
+         { 'id': 'item', 'width': '80', 'height': '30', 'x': '0', 'y': '10' },
+         { 'id': 'a1', 'width': '20', 'height': '5', 'x': '0', 'y': '0' },
+         { 'id': 'a2', 'width': '20', 'height': '5', 'x': '20', 'y': '0' },
+         { 'id': 'a3', 'width': '40', 'height': '5', 'x': '40', 'y': '0' },
+         { 'id': 'a4', 'width': '0', 'height': '5', 'x': '80', 'y': '0' }
+     ]);
+
+     setItemSize('item', '15px', '30px');
+     testGridDefinitions([
+         { 'id': 'item', 'width': '15', 'height': '30', 'x': '0', 'y': '10' },
+         { 'id': 'a1', 'width': '20', 'height': '5', 'x': '0', 'y': '0' },
+         { 'id': 'a2', 'width': '10', 'height': '5', 'x': '20', 'y': '0' },
+         { 'id': 'a3', 'width': '0', 'height': '5', 'x': '30', 'y': '0' },
+         { 'id': 'a4', 'width': '30', 'height': '5', 'x': '0', 'y': '0' }
+     ]);
+
+     setItemSize('item', '120px', '30px');
+     testGridDefinitions([
+         { 'id': 'item', 'width': '120', 'height': '30', 'x': '0', 'y': '10' },
+         { 'id': 'a1', 'width': '20', 'height': '5', 'x': '0', 'y': '0' },
+         { 'id': 'a2', 'width': '20', 'height': '5', 'x': '20', 'y': '0' },
+         { 'id': 'a3', 'width': '20', 'height': '5', 'x': '40', 'y': '0' },
+         { 'id': 'a4', 'width': '20', 'height': '5', 'x': '60', 'y': '0' }
+     ]);
+}
+
+window.addEventListener("load", testChangingGridDefinitions, false);
+</script>
+
+<div>This test checks that changing the min|max-content contributions of grid items properly recomputes both track sizes and grid positions in grids with auto repeat tracks.</div>
+<div id="log"></div>
+
+<div id="grid1" class="grid max-content">
+    <div id="item" style="grid-column: 1 / -1; background: cyan;"></div>
+    <div id="a1" class="abs" style="grid-column: 1 / 2; background: purple;"></div>
+    <div id="a2" class="abs" style="grid-column: 2 / 3; background: orange;"></div>
+    <div id="a3" class="abs" style="grid-column: 3 / 4; background: yellow;"></div>
+    <div id="a4" class="abs" style="grid-column: 4 / 5; background: magenta;"></div>
+</div>
Property changes on: trunk/LayoutTests/fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks.html
___________________________________________________________________

Added: svn:eol-style

+LF \ No newline at end of property

Added: svn:mime-type

+text/html \ No newline at end of property

Modified: trunk/Source/WebCore/ChangeLog (210210 => 210211)


--- trunk/Source/WebCore/ChangeLog	2016-12-30 10:09:05 UTC (rev 210210)
+++ trunk/Source/WebCore/ChangeLog	2016-12-30 10:53:58 UTC (rev 210211)
@@ -1,3 +1,32 @@
+2016-12-28  Sergio Villar Senin  <[email protected]>
+
+        [css-grid] Isolate instrinsic size computation from layout
+        https://bugs.webkit.org/show_bug.cgi?id=166530
+
+        Reviewed by Darin Adler.
+
+        This is the last patch of the items placement data refactoring. By using a different Grid
+        instance in computeIntrinsicLogicalWidths we effectively isolate the intrinsic size
+        computation from the layout. They are now using different data structures so they don't
+        interfere each other.
+
+        This also means that we no longer reuse the placement of items done in the intrinsic size
+        computation. That shouldn't be a big issue once we make m_grid persistent on RenderGrid.
+
+        Last but not least, this patch finally removes the ugly const_cast's we had in
+        computeIntrinsicLogicalWidths() as we no longer modify the internal state of RenderGrid.
+
+        Tests: fast/css-grid-layout/grid-auto-repeat-intrinsic.html
+               fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks.html
+
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::computeIntrinsicLogicalWidths): Use a new instance of Grid.
+        (WebCore::RenderGrid::computeEmptyTracksForAutoRepeat): Fixed a missing m_grid -> grid
+        rename.
+        (WebCore::RenderGrid::placeItemsOnGrid): Constify it. It nows repositions the items if the
+        number of auto repeat tracks has changed.
+        * rendering/RenderGrid.h:
+
 2016-12-30  Michael Catanzaro  <[email protected]>
 
         [GTK] Improve user agent construction

Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (210210 => 210211)


--- trunk/Source/WebCore/rendering/RenderGrid.cpp	2016-12-30 10:09:05 UTC (rev 210210)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp	2016-12-30 10:53:58 UTC (rev 210211)
@@ -735,11 +735,10 @@
 
 void RenderGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
 {
-    bool wasPopulated = !m_grid.needsItemsPlacement();
-    if (!wasPopulated)
-        const_cast<RenderGrid*>(this)->placeItemsOnGrid(const_cast<Grid&>(m_grid), IntrinsicSizeComputation);
+    Grid grid(const_cast<RenderGrid&>(*this));
+    placeItemsOnGrid(grid, IntrinsicSizeComputation);
 
-    GridSizingData sizingData(numTracks(ForColumns, m_grid), numTracks(ForRows, m_grid), const_cast<Grid&>(m_grid));
+    GridSizingData sizingData(numTracks(ForColumns, grid), numTracks(ForRows, grid), grid);
     sizingData.setAvailableSpace(std::nullopt);
     sizingData.setFreeSpace(ForColumns, std::nullopt);
     sizingData.sizingOperation = IntrinsicSizeComputation;
@@ -752,9 +751,6 @@
     LayoutUnit scrollbarWidth = intrinsicScrollbarLogicalWidth();
     minLogicalWidth += scrollbarWidth;
     maxLogicalWidth += scrollbarWidth;
-
-    if (!wasPopulated)
-        const_cast<RenderGrid*>(this)->clearGrid();
 }
 
 void RenderGrid::computeIntrinsicLogicalHeight(GridSizingData& sizingData)
@@ -1708,7 +1704,7 @@
     unsigned firstAutoRepeatTrack = insertionPoint + std::abs(grid.smallestTrackStart(direction));
     unsigned lastAutoRepeatTrack = firstAutoRepeatTrack + grid.autoRepeatTracks(direction);
 
-    if (!m_grid.hasGridItems()) {
+    if (!grid.hasGridItems()) {
         emptyTrackIndexes = std::make_unique<OrderedTrackIndexSet>();
         for (unsigned trackIndex = firstAutoRepeatTrack; trackIndex < lastAutoRepeatTrack; ++trackIndex)
             emptyTrackIndexes->add(trackIndex);
@@ -1725,15 +1721,19 @@
     return emptyTrackIndexes;
 }
 
-void RenderGrid::placeItemsOnGrid(Grid& grid, SizingOperation sizingOperation)
+void RenderGrid::placeItemsOnGrid(Grid& grid, SizingOperation sizingOperation) const
 {
-    ASSERT(grid.needsItemsPlacement());
-    ASSERT(!grid.hasGridItems());
-
     unsigned autoRepeatColumns = computeAutoRepeatTracksCount(ForColumns, sizingOperation);
     unsigned autoRepeatRows = computeAutoRepeatTracksCount(ForRows, sizingOperation);
-    grid.setAutoRepeatTracks(autoRepeatRows, autoRepeatColumns);
+    if (autoRepeatColumns != grid.autoRepeatTracks(ForColumns) || autoRepeatRows != grid.autoRepeatTracks(ForRows)) {
+        grid.setNeedsItemsPlacement(true);
+        grid.setAutoRepeatTracks(autoRepeatRows, autoRepeatColumns);
+    }
 
+    if (!grid.needsItemsPlacement())
+        return;
+
+    ASSERT(!grid.hasGridItems());
     populateExplicitGridAndOrderIterator(grid);
 
     Vector<RenderBox*> autoMajorAxisAutoGridItems;
@@ -2793,7 +2793,7 @@
     // to get it from the style. Note that we know for sure that there are't any implicit tracks,
     // because not having rows implies that there are no "normal" children (out-of-flow children are
     // not stored in m_grid).
-    ASSERT(!m_grid.needsItemsPlacement());
+    ASSERT(!grid.needsItemsPlacement());
     if (direction == ForRows)
         return grid.numTracks(ForRows);
 

Modified: trunk/Source/WebCore/rendering/RenderGrid.h (210210 => 210211)


--- trunk/Source/WebCore/rendering/RenderGrid.h	2016-12-30 10:09:05 UTC (rev 210210)
+++ trunk/Source/WebCore/rendering/RenderGrid.h	2016-12-30 10:53:58 UTC (rev 210211)
@@ -94,7 +94,7 @@
     typedef ListHashSet<size_t> OrderedTrackIndexSet;
     std::unique_ptr<OrderedTrackIndexSet> computeEmptyTracksForAutoRepeat(Grid&, GridTrackSizingDirection) const;
 
-    void placeItemsOnGrid(Grid&, SizingOperation);
+    void placeItemsOnGrid(Grid&, SizingOperation) const;
     void populateExplicitGridAndOrderIterator(Grid&) const;
     std::unique_ptr<GridArea> createEmptyGridAreaAtSpecifiedPositionsOutsideGrid(Grid&, const RenderBox&, GridTrackSizingDirection, const GridSpan&) const;
     void placeSpecifiedMajorAxisItemsOnGrid(Grid&, const Vector<RenderBox*>&) const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to