<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[214604] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/214604">214604</a></dd>
<dt>Author</dt> <dd>svillar@igalia.com</dd>
<dt>Date</dt> <dd>2017-03-30 07:40:46 -0700 (Thu, 30 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[css-grid] Clamp the number of autorepeat tracks
https://bugs.webkit.org/show_bug.cgi?id=170120

Reviewed by Manuel Rego Casasnovas.

Source/WebCore:

As suggested by the specs we do clamp the maximum number of tracks per grid in order to
minimize potential OOM situations. However we were not considering the case of the recently
added auto repeat syntax. Abnormally huge values for the width/height on the grid container
could lead to a number of auto repeat tracks higher than the maximum.

A new API was added to Internals in order to test limits without having to create huge
grids. This new API allows clients to set an arbitrary limit to the number of tracks. The
addition of this new API forced us to add GridPosition.cpp to the project to define the
global variable we use for testing. We took the chance to move part of the implementation
from the header file to the source file.

Last but not least, several new ASSERTs were added to Grid.cpp implementation to ensure that
we do not surpass the grid track limits.

Test: fast/css-grid-layout/grid-auto-repeat-huge-grid.html

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeGridTrackRepeatFunction):
* rendering/Grid.cpp:
(WebCore::Grid::ensureGridSize): Added ASSERT.
(WebCore::Grid::setSmallestTracksStart): Ditto.
(WebCore::Grid::setAutoRepeatTracks): Ditto.
(WebCore::Grid::setAutoRepeatEmptyColumns): Ditto.
(WebCore::Grid::setAutoRepeatEmptyRows): Ditto.
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::clampAutoRepeatTracks): New method.
(WebCore::RenderGrid::placeItemsOnGrid): Clamp the number of auto repeat tracks before
passing them to the Grid.
* rendering/RenderGrid.h:
* rendering/style/GridArea.h:
(WebCore::GridSpan::GridSpan):
* rendering/style/GridPosition.cpp: Added.
(WebCore::GridPosition::setExplicitPosition):
(WebCore::GridPosition::setAutoPosition):
(WebCore::GridPosition::setSpanPosition):
(WebCore::GridPosition::setNamedGridArea):
(WebCore::GridPosition::integerPosition):
(WebCore::GridPosition::namedGridLine):
(WebCore::GridPosition::spanPosition):
(WebCore::GridPosition::operator==):
* rendering/style/GridPosition.h:
(WebCore::GridPosition::shouldBeResolvedAgainstOppositePosition):
(WebCore::GridPosition::max):
(WebCore::GridPosition::min):
(WebCore::GridPosition::setMaxPositionForTesting):
(WebCore::GridPosition::setExplicitPosition): Deleted.
(WebCore::GridPosition::setAutoPosition): Deleted.
(WebCore::GridPosition::setSpanPosition): Deleted.
(WebCore::GridPosition::setNamedGridArea): Deleted.
(WebCore::GridPosition::integerPosition): Deleted.
(WebCore::GridPosition::namedGridLine): Deleted.
(WebCore::GridPosition::spanPosition): Deleted.
(WebCore::GridPosition::operator==): Deleted.
* rendering/style/GridPositionsResolver.cpp:
(WebCore::GridPositionsResolver::explicitGridColumnCount):
(WebCore::GridPositionsResolver::explicitGridRowCount):
* testing/Internals.cpp:
(WebCore::Internals::setGridMaxTracksLimit):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

Added a new test to check the clamping of grid tracks. It's mostly all JavaScript in order
to allow us to run several test cases over a small number of grids in a single file quite
fast. The other option was to statically (CSS) create several huge grids, something that
could potentially be very expensive in terms of memory and CPU leading to timeouts.

* fast/css-grid-layout/grid-auto-repeat-huge-grid-expected.txt: Added.
* fast/css-grid-layout/grid-auto-repeat-huge-grid.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorecssparserCSSPropertyParsercpp">trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingGridcpp">trunk/Source/WebCore/rendering/Grid.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderGridcpp">trunk/Source/WebCore/rendering/RenderGrid.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderGridh">trunk/Source/WebCore/rendering/RenderGrid.h</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleGridAreah">trunk/Source/WebCore/rendering/style/GridArea.h</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleGridPositionh">trunk/Source/WebCore/rendering/style/GridPosition.h</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleGridPositionsResolvercpp">trunk/Source/WebCore/rendering/style/GridPositionsResolver.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsh">trunk/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsidl">trunk/Source/WebCore/testing/Internals.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcssgridlayoutgridautorepeathugegridexpectedtxt">trunk/LayoutTests/fast/css-grid-layout/grid-auto-repeat-huge-grid-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcssgridlayoutgridautorepeathugegridhtml">trunk/LayoutTests/fast/css-grid-layout/grid-auto-repeat-huge-grid.html</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleGridPositioncpp">trunk/Source/WebCore/rendering/style/GridPosition.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (214603 => 214604)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-03-30 13:11:25 UTC (rev 214603)
+++ trunk/LayoutTests/ChangeLog        2017-03-30 14:40:46 UTC (rev 214604)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2017-03-27  Sergio Villar Senin  &lt;svillar@igalia.com&gt;
+
+        [css-grid] Clamp the number of autorepeat tracks
+        https://bugs.webkit.org/show_bug.cgi?id=170120
+
+        Reviewed by Manuel Rego Casasnovas.
+
+        Added a new test to check the clamping of grid tracks. It's mostly all JavaScript in order
+        to allow us to run several test cases over a small number of grids in a single file quite
+        fast. The other option was to statically (CSS) create several huge grids, something that
+        could potentially be very expensive in terms of memory and CPU leading to timeouts.
+
+        * fast/css-grid-layout/grid-auto-repeat-huge-grid-expected.txt: Added.
+        * fast/css-grid-layout/grid-auto-repeat-huge-grid.html: Added.
+
</ins><span class="cx"> 2017-03-30  Antoine Quint  &lt;graouts@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [mac-wk1] LayoutTest media/modern-media-controls/airplay-button/airplay-button.html is a flaky timeout
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssgridlayoutgridautorepeathugegridexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css-grid-layout/grid-auto-repeat-huge-grid-expected.txt (0 => 214604)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css-grid-layout/grid-auto-repeat-huge-grid-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-auto-repeat-huge-grid-expected.txt        2017-03-30 14:40:46 UTC (rev 214604)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+This test checks that we properly enforce the maximum number of grid tracks in different situations.
+
+
+PASS Test that we don't get more than kGridMaxTracks repetitions even on very wide grids (normal tracks clamped). 
+PASS Test that we don't get more than kGridMaxTracks repetitions even on very tall grids (normal tracks clamped). 
+PASS Test that we don't get more than kGridMaxTracks repetitions even on very wide grids (auto repeat tracks clamped). 
+PASS Test that we don't get more than kGridMaxTracks repetitions even on very tall grids (auto repeat tracks clamped). 
+PASS Test that we don't get more than kGridMaxTracks repetitions even on very wide grids with gaps. 
+PASS Test that we don't get more than kGridMaxTracks repetitions even on very tall grids with gaps. 
+PASS Test that we don't get more than kGridMaxTracks repetitions even on very wide grids with gaps and min-width. 
+PASS Test that we don't get more than kGridMaxTracks repetitions even on very tall grids with gaps and min-height. 
+PASS Test that we don't crash when there are exactly kGridMaxTracks auto repeat rows on very tall grids. 
+PASS Test that we don't crash when there are exactly kGridMaxTracks auto repeat columns on very wide grids. 
+PASS Test that we don't crash when there are exactly kGridMaxTracks (normal and auto-repeat) rows on very tall grids. 
+PASS Test that we don't crash when there are exactly kGridMaxTracks (normal and auto-repeat) columns on very wide grids. 
+PASS Test that we don't crash when there are exactly kGridMaxTracks non auto-repeat rows on very tall grids. 
+PASS Test that we don't crash when there are exactly kGridMaxTracks non auto-repeat columns on very wide grids. 
+PASS Test that we don't crash when there are exactly kGridMaxTracks non auto-repeat rows on very tall grids with enough room for auto repetitions. 
+PASS Test that we don't crash when there are exactly kGridMaxTracks non auto-repeat columns on very wide grids with enough room for auto repetitions. 
+PASS Test that we don't crash when there are more than kGridMaxTracks non auto-repeat rows on very tall grids. 
+PASS Test that we don't crash when there are more than kGridMaxTracks non auto-repeat columns on very wide grids. 
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/css-grid-layout/grid-auto-repeat-huge-grid-expected.txt
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+LF
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestsfastcssgridlayoutgridautorepeathugegridhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css-grid-layout/grid-auto-repeat-huge-grid.html (0 => 214604)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css-grid-layout/grid-auto-repeat-huge-grid.html                                (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-auto-repeat-huge-grid.html        2017-03-30 14:40:46 UTC (rev 214604)
</span><span class="lines">@@ -0,0 +1,333 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;title&gt;Test for auto-fit and auto-fill with huge grids (lots of tracks)&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Sergio Villar Senin&quot; href=&quot;mailto:svillar@igalia.com&quot;&gt;
+&lt;link href=&quot;resources/grid.css&quot; rel=&quot;stylesheet&quot;&gt;
+&lt;link href=&quot;../css-intrinsic-dimensions/resources/width-keyword-classes.css&quot; rel=&quot;stylesheet&quot;&gt;
+&lt;link href=&quot;../css-intrinsic-dimensions/resources/height-keyword-classes.css&quot; rel=&quot;stylesheet&quot;&gt;
+
+&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/grid-definitions-parsing-utils.js&quot;&gt;&lt;/script&gt;
+&lt;style&gt;
+ .wideGrid { width: 1000000000px; }
+ .tallGrid { height: 1000000000px; }
+
+ .width25k { width: 25000px; }
+ .height25k { height: 25000px; }
+
+ .lastColumn { grid-column: -2 / -1; }
+ .lastRow { grid-row: -2 / -1; }
+
+ .minSizeWideGrid { min-width: 1000000000px; }
+ .minSizeTallGrid { min-height: 1000000000px; }
+
+ .lotsOfFixedRepeatWithAutoFitCols { grid-template-columns: repeat(auto-fit, 10px 2px 8px) repeat(992, 1px); }
+ .lotsOfFixedRepeatWithAutoFillCols { grid-template-columns: repeat(auto-fill, 10px 2px 8px 7px 20px) repeat(995, 1px); }
+
+ .lotsOfAutoRepeatWithAutoFitCols { grid-template-columns: repeat(auto-fit, 10px 2px 8px) repeat(10, 1px); }
+ .lotsOfAutoRepeatWithAutoFillCols { grid-template-columns: repeat(auto-fill, 10px 2px 8px 7px 20px) repeat(10, 1px); }
+
+ .lotsOfFixedRepeatWithAutoFitColsReversed { grid-template-columns:  repeat(992, 1px) repeat(auto-fit, 10px 2px 8px); }
+ .lotsOfFixedRepeatWithAutoFillColsReversed { grid-template-columns:  repeat(995, 1px) repeat(auto-fill, 10px 2px 8px 7px 20px); }
+
+ .lotsOfFixedRepeatWithAutoFitRows { grid-template-rows: repeat(auto-fit, 10px 2px 8px) repeat(992, 1px); }
+ .lotsOfFixedRepeatWithAutoFillRows { grid-template-rows: repeat(auto-fill, 10px 2px 8px 7px 20px) repeat(995, 1px); }
+
+ .lotsOfAutoRepeatWithAutoFitRows { grid-template-rows: repeat(auto-fit, 10px 2px 8px) repeat(10, 1px); }
+ .lotsOfAutoRepeatWithAutoFillRows { grid-template-rows: repeat(auto-fill, 10px 2px 8px 7px 20px) repeat(10, 1px); }
+
+ .lotsOfFixedRepeatWithAutoFitRowsReversed { grid-template-rows:  repeat(992, 1px) repeat(auto-fit, 10px 2px 8px); }
+ .lotsOfFixedRepeatWithAutoFillRowsReversed { grid-template-rows: repeat(995, 1px) repeat(auto-fill, 10px 2px 8px 7px 20px); }
+
+ .autoFitRows25px { grid-template-rows: repeat(auto-fit, 10px 2px 8px 5px); }
+ .autoFitCols25px { grid-template-columns: repeat(auto-fit, 10px 2px 8px 5px); }
+
+ .autoFillRows25px { grid-template-rows: repeat(auto-fill, 17px 8px); }
+ .autoFillCols25px { grid-template-columns: repeat(auto-fill, 2px 23px); }
+
+ .autoFitRows205pxFixed5px { grid-template-rows: repeat(900, 5px) repeat(auto-fit, 20px 50px 13px 50px 72px); }
+ .autoFitCols205pxFixed5px { grid-template-columns: repeat(900, 5px) repeat(auto-fit, 20px 50px 13px 50px 72px); }
+
+ .autoFillRows205pxFixed5px { grid-template-rows:  repeat(900, 5px) repeat(auto-fill, 200px 5px); }
+ .autoFillCols205pxFixed5px { grid-template-columns: repeat(900, 5px) repeat(auto-fill, 200px 5px); }
+
+ .autoFitAndAThousandFixedRows { grid-template-rows: repeat(auto-fit, 20px 50px 72px) repeat(1000, 37px); }
+ .autoFitAndAThousandFixedCols { grid-template-columns: repeat(auto-fit, 20px 50px 72px) repeat(1000, 37px); }
+
+ .autoFillAndAThousandFixedRows { grid-template-rows: repeat(auto-fill, 2px) repeat(1000, 37px); }
+ .autoFillAndAThousandFixedCols { grid-template-columns: repeat(auto-fill, 2px) repeat(1000, 37px); }
+
+ .autoFitAndMoreThanThousandFixedRows { grid-template-rows:  repeat(700, 7px) repeat(auto-fit, 11px 13px 125px) repeat(600, 6px); }
+ .autoFitAndMoreThanThousandFixedCols { grid-template-columns:  repeat(700, 7px) repeat(auto-fit, 11px 13px 125px) repeat(600, 6px); }
+
+ .autoFillAndMoreThanThousandFixedRows { grid-template-rows: repeat(700, 7px) repeat(auto-fill, 20px 50px 72px) repeat(600, 6px); }
+ .autoFillAndMoreThanThousandFixedCols { grid-template-columns: repeat(700, 7px) repeat(auto-fill, 20px 50px 72px) repeat(600, 6px); }
+&lt;/style&gt;
+
+&lt;p&gt;This test checks that we properly enforce the maximum number of grid tracks in different situations.&lt;/p&gt;
+
+&lt;div id=&quot;autoFillGridCols&quot; class=&quot;grid&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;autoFitGridCols&quot; class=&quot;grid&quot;&gt;
+    &lt;div style=&quot;grid-column: 1;&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;grid-column: 2;&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;lastColumn&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div id=&quot;autoFillGridRows&quot; class=&quot;grid&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;autoFitGridRows&quot; class=&quot;grid&quot;&gt;
+    &lt;div style=&quot;grid-row: 1;&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;grid-row: 2;&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;lastRow&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+var maxTracksForTesting = 1000;  // Keep this value in sync with the ones used in CSS definitions.
+var autoFillGridElementCols = document.getElementById(&quot;autoFillGridCols&quot;);
+var autoFitGridElementCols = document.getElementById(&quot;autoFitGridCols&quot;);
+var autoFillGridElementRows = document.getElementById(&quot;autoFillGridRows&quot;);
+var autoFitGridElementRows = document.getElementById(&quot;autoFitGridRows&quot;);
+if (window.internals)
+    window.internals.setGridMaxTracksLimit(maxTracksForTesting);
+
+function getTracksCheckingLength(gridElement, property, length, classNames) {
+    for (let className of classNames)
+        gridElement.classList.add(className);
+
+    var propertyValue = getComputedStyle(gridElement, '').getPropertyValue(property);
+    for (let className of classNames)
+        gridElement.classList.remove(className);
+
+    if (propertyValue == &quot;&quot;) {
+        assert_equals(length, 0);
+        return [];
+    }
+
+    var tracks = propertyValue.split(' ');
+    assert_equals(tracks.length, length);
+    return tracks;
+}
+
+test(function() {
+    var autoFillGrid = getTracksCheckingLength(autoFillGridElementCols, &quot;grid-template-columns&quot;, maxTracksForTesting, [&quot;wideGrid&quot;, &quot;lotsOfFixedRepeatWithAutoFillCols&quot;]);
+    var autoFitGrid = getTracksCheckingLength(autoFitGridElementCols, &quot;grid-template-columns&quot;, maxTracksForTesting, [&quot;wideGrid&quot;, &quot;lotsOfFixedRepeatWithAutoFitCols&quot;]);
+    assert_equals(autoFitGrid[maxTracksForTesting - 1], &quot;10px&quot;);
+    assert_equals(autoFitGrid[maxTracksForTesting - 2], &quot;0px&quot;);
+    assert_equals(autoFitGrid[0], &quot;10px&quot;);
+    assert_equals(autoFitGrid[1], &quot;2px&quot;);
+
+    assert_equals(autoFillGrid[maxTracksForTesting - 1], &quot;20px&quot;);
+    assert_equals(autoFillGrid[maxTracksForTesting - 2], &quot;7px&quot;);
+    assert_equals(autoFillGrid[0], &quot;10px&quot;);
+    assert_equals(autoFillGrid[1], &quot;2px&quot;);
+}, &quot;Test that we don't get more than kGridMaxTracks repetitions even on very wide grids (normal tracks clamped).&quot;);
+
+test(function() {
+    var autoFillGrid = getTracksCheckingLength(autoFillGridElementRows, &quot;grid-template-rows&quot;, maxTracksForTesting, [&quot;tallGrid&quot;, &quot;lotsOfFixedRepeatWithAutoFillRows&quot;]);
+    var autoFitGrid = getTracksCheckingLength(autoFitGridElementRows, &quot;grid-template-rows&quot;, maxTracksForTesting, [&quot;tallGrid&quot;, &quot;lotsOfFixedRepeatWithAutoFitRows&quot;]);
+    assert_equals(autoFitGrid[maxTracksForTesting - 1], &quot;10px&quot;);
+    assert_equals(autoFitGrid[maxTracksForTesting - 2], &quot;0px&quot;);
+    assert_equals(autoFitGrid[0], &quot;10px&quot;);
+    assert_equals(autoFitGrid[1], &quot;2px&quot;);
+
+    assert_equals(autoFillGrid[maxTracksForTesting - 1], &quot;20px&quot;);
+    assert_equals(autoFillGrid[maxTracksForTesting - 2], &quot;7px&quot;);
+    assert_equals(autoFillGrid[0], &quot;10px&quot;);
+    assert_equals(autoFillGrid[1], &quot;2px&quot;);
+}, &quot;Test that we don't get more than kGridMaxTracks repetitions even on very tall grids (normal tracks clamped).&quot;);
+
+test(function() {
+    var autoFillGrid = getTracksCheckingLength(autoFillGridElementCols, &quot;grid-template-columns&quot;, maxTracksForTesting, [&quot;wideGrid&quot;, &quot;lotsOfFixedRepeatWithAutoFillColsReversed&quot;]);
+    var autoFitGrid = getTracksCheckingLength(autoFitGridElementCols, &quot;grid-template-columns&quot;, maxTracksForTesting, [&quot;wideGrid&quot;, &quot;lotsOfFixedRepeatWithAutoFitColsReversed&quot;]);
+
+    assert_equals(autoFitGrid[maxTracksForTesting - 1], &quot;2px&quot;);
+    assert_equals(autoFitGrid[maxTracksForTesting - 2], &quot;0px&quot;);
+    assert_equals(autoFitGrid[0], &quot;1px&quot;);
+    assert_equals(autoFitGrid[1], &quot;1px&quot;);
+
+    assert_equals(autoFillGrid[maxTracksForTesting - 1], &quot;20px&quot;);
+    assert_equals(autoFillGrid[maxTracksForTesting - 2], &quot;7px&quot;);
+    assert_equals(autoFillGrid[0], &quot;1px&quot;);
+    assert_equals(autoFillGrid[1], &quot;1px&quot;);
+}, &quot;Test that we don't get more than kGridMaxTracks repetitions even on very wide grids (auto repeat tracks clamped).&quot;);
+
+test(function() {
+    var autoFillGrid = getTracksCheckingLength(autoFillGridElementRows, &quot;grid-template-rows&quot;, maxTracksForTesting, [&quot;tallGrid&quot;, &quot;lotsOfFixedRepeatWithAutoFillRowsReversed&quot;]);
+    var autoFitGrid = getTracksCheckingLength(autoFitGridElementRows, &quot;grid-template-rows&quot;, maxTracksForTesting, [&quot;tallGrid&quot;, &quot;lotsOfFixedRepeatWithAutoFitRowsReversed&quot;]);
+
+    assert_equals(autoFitGrid[maxTracksForTesting - 1], &quot;2px&quot;);
+    assert_equals(autoFitGrid[maxTracksForTesting - 2], &quot;0px&quot;);
+    assert_equals(autoFitGrid[0], &quot;1px&quot;);
+    assert_equals(autoFitGrid[1], &quot;1px&quot;);
+
+    assert_equals(autoFillGrid[maxTracksForTesting - 1], &quot;20px&quot;);
+    assert_equals(autoFillGrid[maxTracksForTesting - 2], &quot;7px&quot;);
+    assert_equals(autoFillGrid[0], &quot;1px&quot;);
+    assert_equals(autoFillGrid[1], &quot;1px&quot;);
+}, &quot;Test that we don't get more than kGridMaxTracks repetitions even on very tall grids (auto repeat tracks clamped).&quot;);
+
+test(function() {
+    autoFillGridElementCols.style.gridGap = &quot;100px&quot;;
+    autoFitGridElementCols.style.gridGap = &quot;100px&quot;;
+
+    var autoFillGrid = getTracksCheckingLength(autoFillGridElementCols, &quot;grid-template-columns&quot;, maxTracksForTesting, [&quot;wideGrid&quot;, &quot;lotsOfAutoRepeatWithAutoFillCols&quot;]);
+    var autoFitGrid = getTracksCheckingLength(autoFitGridElementCols, &quot;grid-template-columns&quot;, maxTracksForTesting, [&quot;wideGrid&quot;, &quot;lotsOfAutoRepeatWithAutoFitCols&quot;]);
+
+    assert_equals(autoFitGrid[maxTracksForTesting - 1], &quot;10px&quot;);
+    assert_equals(autoFitGrid[maxTracksForTesting - 2], &quot;0px&quot;);
+    assert_equals(autoFillGrid[maxTracksForTesting - 1], &quot;20px&quot;);
+    assert_equals(autoFillGrid[maxTracksForTesting - 2], &quot;7px&quot;);
+
+    autoFillGridElementCols.style.gridGap = &quot;1000000px&quot;;
+    autoFitGridElementCols.style.gridGap = &quot;1000000px&quot;;
+
+    getTracksCheckingLength(autoFillGridElementCols, &quot;grid-template-columns&quot;, 130, [&quot;wideGrid&quot;, &quot;lotsOfAutoRepeatWithAutoFillCols&quot;]);
+    getTracksCheckingLength(autoFitGridElementCols, &quot;grid-template-columns&quot;, 82, [&quot;wideGrid&quot;, &quot;lotsOfAutoRepeatWithAutoFitCols&quot;]);
+
+    autoFillGridElementCols.style.gridGap = &quot;0px&quot;;
+    autoFitGridElementCols.style.gridGap = &quot;0px&quot;;
+}, &quot;Test that we don't get more than kGridMaxTracks repetitions even on very wide grids with gaps.&quot;);
+
+test(function() {
+    autoFillGridElementRows.style.gridGap = &quot;100px&quot;;
+    autoFitGridElementRows.style.gridGap = &quot;100px&quot;;
+
+    var autoFillGrid = getTracksCheckingLength(autoFillGridElementRows, &quot;grid-template-rows&quot;, maxTracksForTesting, [&quot;tallGrid&quot;, &quot;lotsOfAutoRepeatWithAutoFillRows&quot;]);
+    var autoFitGrid = getTracksCheckingLength(autoFitGridElementRows, &quot;grid-template-rows&quot;, maxTracksForTesting, [&quot;tallGrid&quot;, &quot;lotsOfAutoRepeatWithAutoFitRows&quot;]);
+
+    assert_equals(autoFitGrid[maxTracksForTesting - 1], &quot;10px&quot;);
+    assert_equals(autoFitGrid[maxTracksForTesting - 2], &quot;0px&quot;);
+    assert_equals(autoFillGrid[maxTracksForTesting - 1], &quot;20px&quot;);
+    assert_equals(autoFillGrid[maxTracksForTesting - 2], &quot;7px&quot;);
+
+    autoFillGridElementRows.style.gridGap = &quot;1000000px&quot;;
+    autoFitGridElementRows.style.gridGap = &quot;1000000px&quot;;
+
+    getTracksCheckingLength(autoFillGridElementRows, &quot;grid-template-rows&quot;, 130, [&quot;tallGrid&quot;, &quot;lotsOfAutoRepeatWithAutoFillRows&quot;]);
+    getTracksCheckingLength(autoFitGridElementRows, &quot;grid-template-rows&quot;, 82, [&quot;tallGrid&quot;, &quot;lotsOfAutoRepeatWithAutoFitRows&quot;]);
+
+    autoFillGridElementRows.style.gridGap = &quot;0px&quot;;
+    autoFitGridElementRows.style.gridGap = &quot;0px&quot;;
+}, &quot;Test that we don't get more than kGridMaxTracks repetitions even on very tall grids with gaps.&quot;);
+
+test(function() {
+    var autoFillCols = getTracksCheckingLength(autoFillGridElementCols, &quot;grid-template-columns&quot;, maxTracksForTesting, [&quot;lotsOfAutoRepeatWithAutoFillCols&quot;, &quot;minSizeWideGrid&quot;, &quot;min-content&quot;]);
+    var autoFitCols = getTracksCheckingLength(autoFitGridElementCols, &quot;grid-template-columns&quot;, maxTracksForTesting, [&quot;lotsOfAutoRepeatWithAutoFitCols&quot;, &quot;minSizeWideGrid&quot;, &quot;min-content&quot;]);
+
+    // Check that clamping auto repetitions does not reduce the amount of the other tracks.
+    assert_equals(autoFillCols[maxTracksForTesting - 1], &quot;20px&quot;);
+    assert_equals(autoFillCols[maxTracksForTesting - 2], &quot;7px&quot;);
+    assert_equals(autoFitCols[maxTracksForTesting - 1], &quot;10px&quot;);
+    assert_equals(autoFitCols[maxTracksForTesting - 2], &quot;0px&quot;);
+}, &quot;Test that we don't get more than kGridMaxTracks repetitions even on very wide grids with gaps and min-width.&quot;);
+
+test(function() {
+    var autoFillRows = getTracksCheckingLength(autoFillGridElementRows, &quot;grid-template-rows&quot;, maxTracksForTesting, [&quot;lotsOfAutoRepeatWithAutoFillRows&quot;, &quot;minSizeTallGrid&quot;, &quot;min-content&quot;]);
+    var autoFitRows = getTracksCheckingLength(autoFitGridElementRows, &quot;grid-template-rows&quot;, maxTracksForTesting, [&quot;lotsOfAutoRepeatWithAutoFitRows&quot;, &quot;minSizeTallGrid&quot;, &quot;min-content&quot;]);
+
+    assert_equals(autoFillRows[maxTracksForTesting - 1], &quot;20px&quot;);
+    assert_equals(autoFillRows[maxTracksForTesting - 2], &quot;7px&quot;);
+    assert_equals(autoFitRows[maxTracksForTesting - 1], &quot;10px&quot;);
+    assert_equals(autoFitRows[maxTracksForTesting - 2], &quot;0px&quot;);
+}, &quot;Test that we don't get more than kGridMaxTracks repetitions even on very tall grids with gaps and min-height.&quot;);
+
+test(function() {
+    var autoFillRows = getTracksCheckingLength(autoFillGridElementRows, &quot;grid-template-rows&quot;, maxTracksForTesting, [&quot;height25k&quot;, &quot;autoFillRows25px&quot;]);
+    var autoFitRows = getTracksCheckingLength(autoFitGridElementRows, &quot;grid-template-rows&quot;, maxTracksForTesting, [&quot;height25k&quot;, &quot;autoFitRows25px&quot;]);
+
+    assert_equals(autoFillRows[maxTracksForTesting - 1], &quot;8px&quot;);
+    assert_equals(autoFillRows[maxTracksForTesting - 2], &quot;17px&quot;);
+    assert_equals(autoFitRows[maxTracksForTesting - 1], &quot;5px&quot;);
+    assert_equals(autoFitRows[maxTracksForTesting - 2], &quot;0px&quot;);
+}, &quot;Test that we don't crash when there are exactly kGridMaxTracks auto repeat rows on very tall grids.&quot;);
+
+test(function() {
+    var autoFillCols = getTracksCheckingLength(autoFillGridElementCols, &quot;grid-template-columns&quot;, maxTracksForTesting, [&quot;width25k&quot;, &quot;autoFillCols25px&quot;]);
+    var autoFitCols = getTracksCheckingLength(autoFitGridElementCols, &quot;grid-template-columns&quot;, maxTracksForTesting, [&quot;width25k&quot;, &quot;autoFitCols25px&quot;]);
+
+    assert_equals(autoFillCols[maxTracksForTesting - 1], &quot;23px&quot;);
+    assert_equals(autoFillCols[maxTracksForTesting - 2], &quot;2px&quot;);
+    assert_equals(autoFitCols[maxTracksForTesting - 1], &quot;5px&quot;);
+    assert_equals(autoFitCols[maxTracksForTesting - 2], &quot;0px&quot;);
+}, &quot;Test that we don't crash when there are exactly kGridMaxTracks auto repeat columns on very wide grids.&quot;);
+
+test(function() {
+    var autoFillRows = getTracksCheckingLength(autoFillGridElementRows, &quot;grid-template-rows&quot;, maxTracksForTesting, [&quot;height25k&quot;, &quot;autoFillRows205pxFixed5px&quot;]);
+    var autoFitRows = getTracksCheckingLength(autoFitGridElementRows, &quot;grid-template-rows&quot;, maxTracksForTesting, [&quot;height25k&quot;, &quot;autoFitRows205pxFixed5px&quot;]);
+
+    assert_equals(autoFillRows[maxTracksForTesting - 1], &quot;5px&quot;);
+    assert_equals(autoFillRows[maxTracksForTesting - 2], &quot;200px&quot;);
+    assert_equals(autoFitRows[maxTracksForTesting - 1], &quot;72px&quot;);
+    assert_equals(autoFitRows[maxTracksForTesting - 2], &quot;0px&quot;);
+}, &quot;Test that we don't crash when there are exactly kGridMaxTracks (normal and auto-repeat) rows on very tall grids.&quot;);
+
+test(function() {
+    var autoFillCols = getTracksCheckingLength(autoFillGridElementCols, &quot;grid-template-columns&quot;, maxTracksForTesting, [&quot;width25k&quot;, &quot;autoFillCols205pxFixed5px&quot;]);
+    var autoFitCols = getTracksCheckingLength(autoFitGridElementCols, &quot;grid-template-columns&quot;, maxTracksForTesting, [&quot;width25k&quot;, &quot;autoFitCols205pxFixed5px&quot;]);
+
+    assert_equals(autoFillCols[maxTracksForTesting - 1], &quot;5px&quot;);
+    assert_equals(autoFillCols[maxTracksForTesting - 2], &quot;200px&quot;);
+    assert_equals(autoFitCols[maxTracksForTesting - 1], &quot;72px&quot;);
+    assert_equals(autoFitCols[maxTracksForTesting - 2], &quot;0px&quot;);
+}, &quot;Test that we don't crash when there are exactly kGridMaxTracks (normal and auto-repeat) columns on very wide grids.&quot;);
+
+test(function() {
+    var autoFillGrid = getTracksCheckingLength(autoFillGridElementRows, &quot;grid-template-rows&quot;, maxTracksForTesting, [&quot;height25k&quot;, &quot;autoFillAndAThousandFixedRows&quot;]);
+    var autoFitGrid = getTracksCheckingLength(autoFitGridElementRows, &quot;grid-template-rows&quot;, maxTracksForTesting, [&quot;height25k&quot;, &quot;autoFitAndAThousandFixedRows&quot;]);
+
+    assert_equals(autoFillGrid[maxTracksForTesting - 1], &quot;37px&quot;);
+    assert_equals(autoFillGrid[0], &quot;2px&quot;);
+    assert_equals(autoFitGrid[maxTracksForTesting - 1], &quot;37px&quot;);
+    assert_equals(autoFitGrid[0], &quot;20px&quot;);
+}, &quot;Test that we don't crash when there are exactly kGridMaxTracks non auto-repeat rows on very tall grids.&quot;);
+
+test(function() {
+    var autoFillGrid = getTracksCheckingLength(autoFillGridElementCols, &quot;grid-template-columns&quot;, maxTracksForTesting, [&quot;width25k&quot;, &quot;autoFillAndAThousandFixedCols&quot;]);
+    var autoFitGrid = getTracksCheckingLength(autoFitGridElementCols, &quot;grid-template-columns&quot;, maxTracksForTesting, [&quot;width25k&quot;, &quot;autoFitAndAThousandFixedCols&quot;]);
+
+    assert_equals(autoFillGrid[maxTracksForTesting - 1], &quot;37px&quot;);
+    assert_equals(autoFillGrid[0], &quot;2px&quot;);
+    assert_equals(autoFitGrid[maxTracksForTesting - 1], &quot;37px&quot;);
+    assert_equals(autoFitGrid[0], &quot;20px&quot;);
+}, &quot;Test that we don't crash when there are exactly kGridMaxTracks non auto-repeat columns on very wide grids.&quot;);
+
+test(function() {
+    var autoFillGrid = getTracksCheckingLength(autoFillGridElementRows, &quot;grid-template-rows&quot;, maxTracksForTesting, [&quot;tallGrid&quot;, &quot;autoFillAndAThousandFixedRows&quot;]);
+    var autoFitGrid = getTracksCheckingLength(autoFitGridElementRows, &quot;grid-template-rows&quot;, maxTracksForTesting, [&quot;tallGrid&quot;, &quot;autoFitAndAThousandFixedRows&quot;]);
+
+    assert_equals(autoFillGrid[maxTracksForTesting - 1], &quot;2px&quot;);
+    assert_equals(autoFillGrid[0], &quot;2px&quot;);
+    assert_equals(autoFitGrid[maxTracksForTesting - 1], &quot;20px&quot;);
+    assert_equals(autoFitGrid[0], &quot;20px&quot;);
+}, &quot;Test that we don't crash when there are exactly kGridMaxTracks non auto-repeat rows on very tall grids with enough room for auto repetitions.&quot;);
+
+test(function() {
+    var autoFillGrid = getTracksCheckingLength(autoFillGridElementCols, &quot;grid-template-columns&quot;, maxTracksForTesting, [&quot;wideGrid&quot;, &quot;autoFillAndAThousandFixedCols&quot;]);
+    var autoFitGrid = getTracksCheckingLength(autoFitGridElementCols, &quot;grid-template-columns&quot;, maxTracksForTesting, [&quot;wideGrid&quot;, &quot;autoFitAndAThousandFixedCols&quot;]);
+
+    assert_equals(autoFillGrid[maxTracksForTesting - 1], &quot;2px&quot;);
+    assert_equals(autoFillGrid[0], &quot;2px&quot;);
+    assert_equals(autoFitGrid[maxTracksForTesting - 1], &quot;20px&quot;);
+    assert_equals(autoFitGrid[0], &quot;20px&quot;);
+}, &quot;Test that we don't crash when there are exactly kGridMaxTracks non auto-repeat columns on very wide grids with enough room for auto repetitions.&quot;);
+
+test(function() {
+    var autoFillGrid = getTracksCheckingLength(autoFillGridElementRows, &quot;grid-template-rows&quot;, maxTracksForTesting, [&quot;height25k&quot;, &quot;autoFillAndMoreThanThousandFixedRows&quot;]);
+    var autoFitGrid = getTracksCheckingLength(autoFitGridElementRows, &quot;grid-template-rows&quot;, maxTracksForTesting, [&quot;height25k&quot;, &quot;autoFitAndMoreThanThousandFixedRows&quot;]);
+
+    assert_equals(autoFillGrid[maxTracksForTesting - 1], &quot;72px&quot;);
+    assert_equals(autoFillGrid[0], &quot;7px&quot;);
+    assert_equals(autoFitGrid[maxTracksForTesting - 1], &quot;125px&quot;);
+    assert_equals(autoFitGrid[0], &quot;7px&quot;);
+}, &quot;Test that we don't crash when there are more than kGridMaxTracks non auto-repeat rows on very tall grids.&quot;);
+
+test(function() {
+    var autoFillGrid = getTracksCheckingLength(autoFillGridElementCols, &quot;grid-template-columns&quot;, maxTracksForTesting, [&quot;width25k&quot;, &quot;autoFillAndMoreThanThousandFixedCols&quot;]);
+    var autoFitGrid = getTracksCheckingLength(autoFitGridElementCols, &quot;grid-template-columns&quot;, maxTracksForTesting, [&quot;width25k&quot;, &quot;autoFitAndMoreThanThousandFixedCols&quot;]);
+
+    assert_equals(autoFillGrid[maxTracksForTesting - 1], &quot;72px&quot;);
+    assert_equals(autoFillGrid[0], &quot;7px&quot;);
+    assert_equals(autoFitGrid[maxTracksForTesting - 1], &quot;125px&quot;);
+    assert_equals(autoFitGrid[0], &quot;7px&quot;);
+}, &quot;Test that we don't crash when there are more than kGridMaxTracks non auto-repeat columns on very wide grids.&quot;);
+
+&lt;/script&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/css-grid-layout/grid-auto-repeat-huge-grid.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+LF
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/html
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (214603 => 214604)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2017-03-30 13:11:25 UTC (rev 214603)
+++ trunk/Source/WebCore/CMakeLists.txt        2017-03-30 14:40:46 UTC (rev 214604)
</span><span class="lines">@@ -2624,6 +2624,7 @@
</span><span class="cx">     rendering/style/ContentData.cpp
</span><span class="cx">     rendering/style/CounterDirectives.cpp
</span><span class="cx">     rendering/style/FillLayer.cpp
</span><ins>+    rendering/style/GridPosition.cpp
</ins><span class="cx">     rendering/style/GridPositionsResolver.cpp
</span><span class="cx">     rendering/style/KeyframeList.cpp
</span><span class="cx">     rendering/style/NinePieceImage.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (214603 => 214604)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-30 13:11:25 UTC (rev 214603)
+++ trunk/Source/WebCore/ChangeLog        2017-03-30 14:40:46 UTC (rev 214604)
</span><span class="lines">@@ -1,3 +1,73 @@
</span><ins>+2017-03-27  Sergio Villar Senin  &lt;svillar@igalia.com&gt;
+
+        [css-grid] Clamp the number of autorepeat tracks
+        https://bugs.webkit.org/show_bug.cgi?id=170120
+
+        Reviewed by Manuel Rego Casasnovas.
+
+        As suggested by the specs we do clamp the maximum number of tracks per grid in order to
+        minimize potential OOM situations. However we were not considering the case of the recently
+        added auto repeat syntax. Abnormally huge values for the width/height on the grid container
+        could lead to a number of auto repeat tracks higher than the maximum.
+
+        A new API was added to Internals in order to test limits without having to create huge
+        grids. This new API allows clients to set an arbitrary limit to the number of tracks. The
+        addition of this new API forced us to add GridPosition.cpp to the project to define the
+        global variable we use for testing. We took the chance to move part of the implementation
+        from the header file to the source file.
+
+        Last but not least, several new ASSERTs were added to Grid.cpp implementation to ensure that
+        we do not surpass the grid track limits.
+
+        Test: fast/css-grid-layout/grid-auto-repeat-huge-grid.html
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::consumeGridTrackRepeatFunction):
+        * rendering/Grid.cpp:
+        (WebCore::Grid::ensureGridSize): Added ASSERT.
+        (WebCore::Grid::setSmallestTracksStart): Ditto.
+        (WebCore::Grid::setAutoRepeatTracks): Ditto.
+        (WebCore::Grid::setAutoRepeatEmptyColumns): Ditto.
+        (WebCore::Grid::setAutoRepeatEmptyRows): Ditto.
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::clampAutoRepeatTracks): New method.
+        (WebCore::RenderGrid::placeItemsOnGrid): Clamp the number of auto repeat tracks before
+        passing them to the Grid.
+        * rendering/RenderGrid.h:
+        * rendering/style/GridArea.h:
+        (WebCore::GridSpan::GridSpan):
+        * rendering/style/GridPosition.cpp: Added.
+        (WebCore::GridPosition::setExplicitPosition):
+        (WebCore::GridPosition::setAutoPosition):
+        (WebCore::GridPosition::setSpanPosition):
+        (WebCore::GridPosition::setNamedGridArea):
+        (WebCore::GridPosition::integerPosition):
+        (WebCore::GridPosition::namedGridLine):
+        (WebCore::GridPosition::spanPosition):
+        (WebCore::GridPosition::operator==):
+        * rendering/style/GridPosition.h:
+        (WebCore::GridPosition::shouldBeResolvedAgainstOppositePosition):
+        (WebCore::GridPosition::max):
+        (WebCore::GridPosition::min):
+        (WebCore::GridPosition::setMaxPositionForTesting):
+        (WebCore::GridPosition::setExplicitPosition): Deleted.
+        (WebCore::GridPosition::setAutoPosition): Deleted.
+        (WebCore::GridPosition::setSpanPosition): Deleted.
+        (WebCore::GridPosition::setNamedGridArea): Deleted.
+        (WebCore::GridPosition::integerPosition): Deleted.
+        (WebCore::GridPosition::namedGridLine): Deleted.
+        (WebCore::GridPosition::spanPosition): Deleted.
+        (WebCore::GridPosition::operator==): Deleted.
+        * rendering/style/GridPositionsResolver.cpp:
+        (WebCore::GridPositionsResolver::explicitGridColumnCount):
+        (WebCore::GridPositionsResolver::explicitGridRowCount):
+        * testing/Internals.cpp:
+        (WebCore::Internals::setGridMaxTracksLimit):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
</ins><span class="cx"> 2017-03-29  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Disconnecting a HTMLObjectElement does not always unload its content document
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (214603 => 214604)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-03-30 13:11:25 UTC (rev 214603)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-03-30 14:40:46 UTC (rev 214604)
</span><span class="lines">@@ -6491,6 +6491,7 @@
</span><span class="cx">                 E172AF70180F289500FBADB9 /* CryptoKeyUsage.h in Headers */ = {isa = PBXBuildFile; fileRef = E172AF6F180F289500FBADB9 /* CryptoKeyUsage.h */; };
</span><span class="cx">                 E172AF8F1811BC3700FBADB9 /* JSDOMPromise.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E172AF8D1811BC3700FBADB9 /* JSDOMPromise.cpp */; };
</span><span class="cx">                 E172AF901811BC3700FBADB9 /* JSDOMPromise.h in Headers */ = {isa = PBXBuildFile; fileRef = E172AF8E1811BC3700FBADB9 /* JSDOMPromise.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                E175BA991E8AE3380071454F /* GridPosition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1F817451E897A5200F22CD0 /* GridPosition.cpp */; };
</ins><span class="cx">                 E179F0DA1B9774FE00ED0A27 /* Internals.mm in Sources */ = {isa = PBXBuildFile; fileRef = E179F0D91B9774FE00ED0A27 /* Internals.mm */; };
</span><span class="cx">                 E17B491516A9B094001C8839 /* TransitionEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E17B491316A9B093001C8839 /* TransitionEvent.cpp */; };
</span><span class="cx">                 E17B491616A9B094001C8839 /* TransitionEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = E17B491416A9B093001C8839 /* TransitionEvent.h */; };
</span><span class="lines">@@ -15072,6 +15073,7 @@
</span><span class="cx">                 E1F80B8618317252007885C3 /* CryptoKeyPair.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoKeyPair.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E1F80B8B183172B5007885C3 /* JSCryptoKeyPair.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCryptoKeyPair.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E1F80B8C183172B5007885C3 /* JSCryptoKeyPair.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCryptoKeyPair.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                E1F817451E897A5200F22CD0 /* GridPosition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GridPosition.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 E1FE1368183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmRSA_OAEP.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E1FE1369183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRSA_OAEP.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E1FE136E183FECF000892F13 /* CryptoAlgorithmRSA_OAEPMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmRSA_OAEPMac.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -23420,6 +23422,7 @@
</span><span class="cx">                                 BC5EB69D0E81DAEB00B25965 /* FillLayer.h */,
</span><span class="cx">                                 CD3E251B18046B0600E27F56 /* GridArea.h */,
</span><span class="cx">                                 CDEF4FD617E85C8F00AEE24B /* GridLength.h */,
</span><ins>+                                E1F817451E897A5200F22CD0 /* GridPosition.cpp */,
</ins><span class="cx">                                 A12705C21656BD6500C2E27C /* GridPosition.h */,
</span><span class="cx">                                 CDF7483C18FEBCEC0006ECC0 /* GridPositionsResolver.cpp */,
</span><span class="cx">                                 CDF7483D18FEBCEC0006ECC0 /* GridPositionsResolver.h */,
</span><span class="lines">@@ -31070,6 +31073,7 @@
</span><span class="cx">                                 0FA24D79162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp in Sources */,
</span><span class="cx">                                 B2A015AA0AF6CD53006BCE0E /* GraphicsTypes.cpp in Sources */,
</span><span class="cx">                                 E112F4711E3A861200D6CDFD /* Grid.cpp in Sources */,
</span><ins>+                                E175BA991E8AE3380071454F /* GridPosition.cpp in Sources */,
</ins><span class="cx">                                 CDF7483E18FEBCEC0006ECC0 /* GridPositionsResolver.cpp in Sources */,
</span><span class="cx">                                 316DCB4B1E7910A6001B5F87 /* JSRTCIceConnectionState.cpp in Sources */,
</span><span class="cx">                                 E12DE7171E4B749C00F9ACCF /* GridTrackSizingAlgorithm.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorecssparserCSSPropertyParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (214603 => 214604)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp        2017-03-30 13:11:25 UTC (rev 214603)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp        2017-03-30 14:40:46 UTC (rev 214604)
</span><span class="lines">@@ -3332,7 +3332,7 @@
</span><span class="cx">         RefPtr&lt;CSSPrimitiveValue&gt; repetition = consumePositiveInteger(args);
</span><span class="cx">         if (!repetition)
</span><span class="cx">             return false;
</span><del>-        repetitions = clampTo&lt;size_t&gt;(repetition-&gt;doubleValue(), 0, kGridMaxTracks);
</del><ins>+        repetitions = clampTo&lt;size_t&gt;(repetition-&gt;doubleValue(), 0, GridPosition::max());
</ins><span class="cx">         repeatedValues = CSSValueList::createSpaceSeparated();
</span><span class="cx">     }
</span><span class="cx">     if (!consumeCommaIncludingWhitespace(args))
</span><span class="lines">@@ -3362,7 +3362,7 @@
</span><span class="cx">         list.append(repeatedValues.releaseNonNull());
</span><span class="cx">     else {
</span><span class="cx">         // We clamp the repetitions to a multiple of the repeat() track list's size, while staying below the max grid size.
</span><del>-        repetitions = std::min(repetitions, kGridMaxTracks / numberOfTracks);
</del><ins>+        repetitions = std::min(repetitions, GridPosition::max() / numberOfTracks);
</ins><span class="cx">         for (size_t i = 0; i &lt; repetitions; ++i) {
</span><span class="cx">             for (size_t j = 0; j &lt; repeatedValues-&gt;length(); ++j)
</span><span class="cx">                 list.append(*repeatedValues-&gt;itemWithoutBoundsCheck(j));
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingGridcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/Grid.cpp (214603 => 214604)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/Grid.cpp        2017-03-30 13:11:25 UTC (rev 214603)
+++ trunk/Source/WebCore/rendering/Grid.cpp        2017-03-30 14:40:46 UTC (rev 214604)
</span><span class="lines">@@ -45,6 +45,8 @@
</span><span class="cx"> 
</span><span class="cx"> void Grid::ensureGridSize(unsigned maximumRowSize, unsigned maximumColumnSize)
</span><span class="cx"> {
</span><ins>+    ASSERT(static_cast&lt;int&gt;(maximumRowSize) &lt; GridPosition::max() * 2);
+    ASSERT(static_cast&lt;int&gt;(maximumColumnSize) &lt; GridPosition::max() * 2);
</ins><span class="cx">     const size_t oldColumnSize = numTracks(ForColumns);
</span><span class="cx">     const size_t oldRowSize = numTracks(ForRows);
</span><span class="cx">     if (maximumRowSize &gt; oldRowSize) {
</span><span class="lines">@@ -74,6 +76,8 @@
</span><span class="cx"> 
</span><span class="cx"> void Grid::setSmallestTracksStart(int rowStart, int columnStart)
</span><span class="cx"> {
</span><ins>+    ASSERT(rowStart &gt; GridPosition::min() &amp;&amp; rowStart &lt; GridPosition::max() - 1);
+    ASSERT(columnStart &gt; GridPosition::min() &amp;&amp; columnStart &lt; GridPosition::max() - 1);
</ins><span class="cx">     m_smallestRowStart = rowStart;
</span><span class="cx">     m_smallestColumnStart = columnStart;
</span><span class="cx"> }
</span><span class="lines">@@ -96,6 +100,8 @@
</span><span class="cx"> 
</span><span class="cx"> void Grid::setAutoRepeatTracks(unsigned autoRepeatRows, unsigned autoRepeatColumns)
</span><span class="cx"> {
</span><ins>+    ASSERT(static_cast&lt;unsigned&gt;(GridPosition::max()) &gt;= numTracks(ForRows) + autoRepeatRows);
+    ASSERT(static_cast&lt;unsigned&gt;(GridPosition::max()) &gt;= numTracks(ForColumns) + autoRepeatColumns);
</ins><span class="cx">     m_autoRepeatRows = autoRepeatRows;
</span><span class="cx">     m_autoRepeatColumns =  autoRepeatColumns;
</span><span class="cx"> }
</span><span class="lines">@@ -107,11 +113,13 @@
</span><span class="cx"> 
</span><span class="cx"> void Grid::setAutoRepeatEmptyColumns(std::unique_ptr&lt;OrderedTrackIndexSet&gt; autoRepeatEmptyColumns)
</span><span class="cx"> {
</span><ins>+    ASSERT(!autoRepeatEmptyColumns || (autoRepeatEmptyColumns-&gt;size() &lt;= m_autoRepeatColumns));
</ins><span class="cx">     m_autoRepeatEmptyColumns = WTFMove(autoRepeatEmptyColumns);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Grid::setAutoRepeatEmptyRows(std::unique_ptr&lt;OrderedTrackIndexSet&gt; autoRepeatEmptyRows)
</span><span class="cx"> {
</span><ins>+    ASSERT(!autoRepeatEmptyRows || (autoRepeatEmptyRows-&gt;size() &lt;= m_autoRepeatRows));
</ins><span class="cx">     m_autoRepeatEmptyRows = WTFMove(autoRepeatEmptyRows);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderGridcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (214603 => 214604)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderGrid.cpp        2017-03-30 13:11:25 UTC (rev 214603)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp        2017-03-30 14:40:46 UTC (rev 214604)
</span><span class="lines">@@ -535,10 +535,31 @@
</span><span class="cx">     return emptyTrackIndexes;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+unsigned RenderGrid::clampAutoRepeatTracks(GridTrackSizingDirection direction, unsigned autoRepeatTracks) const
+{
+    if (!autoRepeatTracks)
+        return 0;
+
+    unsigned insertionPoint = direction == ForColumns ? style().gridAutoRepeatColumnsInsertionPoint() : style().gridAutoRepeatRowsInsertionPoint();
+    unsigned maxTracks = static_cast&lt;unsigned&gt;(GridPosition::max());
+
+    if (!insertionPoint)
+        return std::min(autoRepeatTracks, maxTracks);
+
+    if (insertionPoint &gt;= maxTracks)
+        return 0;
+
+    return std::min(autoRepeatTracks, maxTracks - insertionPoint);
+}
+
</ins><span class="cx"> void RenderGrid::placeItemsOnGrid(Grid&amp; grid, SizingOperation sizingOperation) const
</span><span class="cx"> {
</span><span class="cx">     unsigned autoRepeatColumns = computeAutoRepeatTracksCount(ForColumns, sizingOperation);
</span><span class="cx">     unsigned autoRepeatRows = computeAutoRepeatTracksCount(ForRows, sizingOperation);
</span><ins>+
+    autoRepeatRows = clampAutoRepeatTracks(ForRows, autoRepeatRows);
+    autoRepeatColumns = clampAutoRepeatTracks(ForColumns, autoRepeatColumns);
+
</ins><span class="cx">     if (autoRepeatColumns != grid.autoRepeatTracks(ForColumns) || autoRepeatRows != grid.autoRepeatTracks(ForRows)) {
</span><span class="cx">         grid.setNeedsItemsPlacement(true);
</span><span class="cx">         grid.setAutoRepeatTracks(autoRepeatRows, autoRepeatColumns);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderGridh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderGrid.h (214603 => 214604)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderGrid.h        2017-03-30 13:11:25 UTC (rev 214603)
+++ trunk/Source/WebCore/rendering/RenderGrid.h        2017-03-30 14:40:46 UTC (rev 214604)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2011 Apple Inc. All rights reserved.
</span><del>- * Copyright (C) 2013, 2014 Igalia S.L.
</del><ins>+ * Copyright (C) 2013-2017 Igalia S.L.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx">     // Required by GridTrackSizingAlgorithm. Keep them under control.
</span><span class="cx">     bool isOrthogonalChild(const RenderBox&amp;) const;
</span><span class="cx">     LayoutUnit guttersSize(const Grid&amp;, GridTrackSizingDirection, unsigned startLine, unsigned span, SizingOperation) const;
</span><del>-    
</del><ins>+
</ins><span class="cx"> protected:
</span><span class="cx">     ItemPosition selfAlignmentNormalBehavior(const RenderBox* child = nullptr) const override
</span><span class="cx">     {
</span><span class="lines">@@ -86,6 +86,8 @@
</span><span class="cx"> 
</span><span class="cx">     unsigned computeAutoRepeatTracksCount(GridTrackSizingDirection, SizingOperation) const;
</span><span class="cx"> 
</span><ins>+    unsigned clampAutoRepeatTracks(GridTrackSizingDirection, unsigned autoRepeatTracks) const;
+
</ins><span class="cx">     std::unique_ptr&lt;OrderedTrackIndexSet&gt; computeEmptyTracksForAutoRepeat(Grid&amp;, GridTrackSizingDirection) const;
</span><span class="cx"> 
</span><span class="cx">     void placeItemsOnGrid(Grid&amp;, SizingOperation) const;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleGridAreah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/GridArea.h (214603 => 214604)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/GridArea.h        2017-03-30 13:11:25 UTC (rev 214603)
+++ trunk/Source/WebCore/rendering/style/GridArea.h        2017-03-30 14:40:46 UTC (rev 214604)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2013 Google Inc. All rights reserved.
</span><del>- * Copyright (C) 2013, 2014, 2016 Igalia S.L.
</del><ins>+ * Copyright (C) 2013-2017 Igalia S.L.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions are
</span><span class="lines">@@ -156,8 +156,8 @@
</span><span class="cx">         }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-        m_startLine = std::max(-kGridMaxTracks, std::min(startLine, kGridMaxTracks - 1));
-        m_endLine = std::max(-kGridMaxTracks + 1, std::min(endLine, kGridMaxTracks));
</del><ins>+        m_startLine = std::max(GridPosition::min(), std::min(startLine, GridPosition::max() - 1));
+        m_endLine = std::max(GridPosition::min() + 1, std::min(endLine, GridPosition::max()));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     int m_startLine;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleGridPositioncpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/rendering/style/GridPosition.cpp (0 => 214604)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/GridPosition.cpp                                (rev 0)
+++ trunk/Source/WebCore/rendering/style/GridPosition.cpp        2017-03-30 14:40:46 UTC (rev 214604)
</span><span class="lines">@@ -0,0 +1,106 @@
</span><ins>+/*
+ * Copyright (C) 2017 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;GridPosition.h&quot;
+
+namespace WebCore {
+
+std::optional&lt;int&gt; GridPosition::gMaxPositionForTesting;
+static const int kGridMaxPosition = 1000000;
+
+void GridPosition::setExplicitPosition(int position, const String&amp; namedGridLine)
+{
+    m_type = ExplicitPosition;
+    setIntegerPosition(position);
+    m_namedGridLine = namedGridLine;
+}
+
+void GridPosition::setAutoPosition()
+{
+    m_type = AutoPosition;
+    m_integerPosition = 0;
+}
+
+// 'span' values cannot be negative, yet we reuse the &lt;integer&gt; position which can
+// be. This means that we have to convert the span position to an integer, losing
+// some precision here. It shouldn't be an issue in practice though.
+void GridPosition::setSpanPosition(int position, const String&amp; namedGridLine)
+{
+    m_type = SpanPosition;
+    setIntegerPosition(position);
+    m_namedGridLine = namedGridLine;
+}
+
+void GridPosition::setNamedGridArea(const String&amp; namedGridArea)
+{
+    m_type = NamedGridAreaPosition;
+    m_namedGridLine = namedGridArea;
+}
+
+int GridPosition::integerPosition() const
+{
+    ASSERT(type() == ExplicitPosition);
+    return m_integerPosition;
+}
+
+String GridPosition::namedGridLine() const
+{
+    ASSERT(type() == ExplicitPosition || type() == SpanPosition || type() == NamedGridAreaPosition);
+    return m_namedGridLine;
+}
+
+int GridPosition::spanPosition() const
+{
+    ASSERT(type() == SpanPosition);
+    return m_integerPosition;
+}
+
+int GridPosition::max()
+{
+    return gMaxPositionForTesting.value_or(kGridMaxPosition);
+}
+
+int GridPosition::min()
+{
+    return -max();
+}
+
+bool GridPosition::operator==(const GridPosition&amp; other) const
+{
+    return m_type == other.m_type &amp;&amp; m_integerPosition == other.m_integerPosition &amp;&amp; m_namedGridLine == other.m_namedGridLine;
+}
+
+void GridPosition::setMaxPositionForTesting(unsigned maxPosition)
+{
+    gMaxPositionForTesting = static_cast&lt;int&gt;(maxPosition);
+}
+
+} // namespace WebCore
</ins><span class="cx">Property changes on: trunk/Source/WebCore/rendering/style/GridPosition.cpp
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+LF
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkSourceWebCorerenderingstyleGridPositionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/GridPosition.h (214603 => 214604)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/GridPosition.h        2017-03-30 13:11:25 UTC (rev 214603)
+++ trunk/Source/WebCore/rendering/style/GridPosition.h        2017-03-30 14:40:46 UTC (rev 214604)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2012 Google Inc. All rights reserved.
</span><del>- * Copyright (C) 2013, 2014 Igalia S.L.
</del><ins>+ * Copyright (C) 2013-2017 Igalia S.L.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions are
</span><span class="lines">@@ -35,9 +35,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-// Recommended maximum size for both explicit and implicit grids.
-const int kGridMaxTracks = 1000000;
-
</del><span class="cx"> enum GridPositionType {
</span><span class="cx">     AutoPosition,
</span><span class="cx">     ExplicitPosition, // [ &lt;integer&gt; || &lt;string&gt; ]
</span><span class="lines">@@ -67,69 +64,31 @@
</span><span class="cx">     bool isSpan() const { return m_type == SpanPosition; }
</span><span class="cx">     bool isNamedGridArea() const { return m_type == NamedGridAreaPosition; }
</span><span class="cx"> 
</span><del>-    void setExplicitPosition(int position, const String&amp; namedGridLine)
-    {
-        m_type = ExplicitPosition;
-        setIntegerPosition(position);
-        m_namedGridLine = namedGridLine;
-    }
</del><ins>+    WEBCORE_EXPORT void setExplicitPosition(int position, const String&amp; namedGridLine);
+    void setAutoPosition();
+    WEBCORE_EXPORT void setSpanPosition(int position, const String&amp; namedGridLine);
+    void setNamedGridArea(const String&amp;);
</ins><span class="cx"> 
</span><del>-    void setAutoPosition()
-    {
-        m_type = AutoPosition;
-        m_integerPosition = 0;
-    }
</del><ins>+    WEBCORE_EXPORT int integerPosition() const;
+    String namedGridLine() const;
+    WEBCORE_EXPORT int spanPosition() const;
</ins><span class="cx"> 
</span><del>-    // 'span' values cannot be negative, yet we reuse the &lt;integer&gt; position which can
-    // be. This means that we have to convert the span position to an integer, losing
-    // some precision here. It shouldn't be an issue in practice though.
-    void setSpanPosition(int position, const String&amp; namedGridLine)
-    {
-        m_type = SpanPosition;
-        setIntegerPosition(position);
-        m_namedGridLine = namedGridLine;
-    }
</del><ins>+    bool operator==(const GridPosition&amp; other) const;
</ins><span class="cx"> 
</span><del>-    void setNamedGridArea(const String&amp; namedGridArea)
-    {
-        m_type = NamedGridAreaPosition;
-        m_namedGridLine = namedGridArea;
-    }
</del><ins>+    bool shouldBeResolvedAgainstOppositePosition() const { return isAuto() || isSpan(); }
</ins><span class="cx"> 
</span><del>-    int integerPosition() const
-    {
-        ASSERT(type() == ExplicitPosition);
-        return m_integerPosition;
-    }
</del><ins>+    // Note that grid line 1 is internally represented by the index 0, that's why the max value for
+    // a position is kGridMaxTracks instead of kGridMaxTracks + 1.
+    static int max();
+    static int min();
</ins><span class="cx"> 
</span><del>-    String namedGridLine() const
-    {
-        ASSERT(type() == ExplicitPosition || type() == SpanPosition || type() == NamedGridAreaPosition);
-        return m_namedGridLine;
-    }
</del><ins>+    WEBCORE_EXPORT static void setMaxPositionForTesting(unsigned);
</ins><span class="cx"> 
</span><del>-    int spanPosition() const
-    {
-        ASSERT(type() == SpanPosition);
-        return m_integerPosition;
-    }
</del><ins>+private:
+    static std::optional&lt;int&gt; gMaxPositionForTesting;
</ins><span class="cx"> 
</span><del>-    bool operator==(const GridPosition&amp; other) const
-    {
-        return m_type == other.m_type &amp;&amp; m_integerPosition == other.m_integerPosition &amp;&amp; m_namedGridLine == other.m_namedGridLine;
-    }
</del><ins>+    void setIntegerPosition(int integerPosition) { m_integerPosition = clampTo(integerPosition, min(), max()); }
</ins><span class="cx"> 
</span><del>-    bool shouldBeResolvedAgainstOppositePosition() const
-    {
-        return isAuto() || isSpan();
-    }
-
-private:
-    void setIntegerPosition(int integerPosition)
-    {
-        m_integerPosition = clampTo(integerPosition, -kGridMaxTracks, kGridMaxTracks);
-    }
-
</del><span class="cx">     GridPositionType m_type;
</span><span class="cx">     int m_integerPosition;
</span><span class="cx">     String m_namedGridLine;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleGridPositionsResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/GridPositionsResolver.cpp (214603 => 214604)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/GridPositionsResolver.cpp        2017-03-30 13:11:25 UTC (rev 214603)
+++ trunk/Source/WebCore/rendering/style/GridPositionsResolver.cpp        2017-03-30 14:40:46 UTC (rev 214604)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2014-2016 Igalia S.L.
</del><ins>+ * Copyright (C) 2014-2017 Igalia S.L.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions are
</span><span class="lines">@@ -187,12 +187,12 @@
</span><span class="cx"> 
</span><span class="cx"> unsigned GridPositionsResolver::explicitGridColumnCount(const RenderStyle&amp; gridContainerStyle, unsigned autoRepeatTracksCount)
</span><span class="cx"> {
</span><del>-    return std::min&lt;unsigned&gt;(std::max(gridContainerStyle.gridColumns().size() + autoRepeatTracksCount, gridContainerStyle.namedGridAreaColumnCount()), kGridMaxTracks);
</del><ins>+    return std::min&lt;unsigned&gt;(std::max(gridContainerStyle.gridColumns().size() + autoRepeatTracksCount, gridContainerStyle.namedGridAreaColumnCount()), GridPosition::max());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> unsigned GridPositionsResolver::explicitGridRowCount(const RenderStyle&amp; gridContainerStyle, unsigned autoRepeatTracksCount)
</span><span class="cx"> {
</span><del>-    return std::min&lt;unsigned&gt;(std::max(gridContainerStyle.gridRows().size() + autoRepeatTracksCount, gridContainerStyle.namedGridAreaRowCount()), kGridMaxTracks);
</del><ins>+    return std::min&lt;unsigned&gt;(std::max(gridContainerStyle.gridRows().size() + autoRepeatTracksCount, gridContainerStyle.namedGridAreaRowCount()), GridPosition::max());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static unsigned explicitGridSizeForSide(const RenderStyle&amp; gridContainerStyle, GridPositionSide side, unsigned autoRepeatTracksCount)
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (214603 => 214604)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2017-03-30 13:11:25 UTC (rev 214603)
+++ trunk/Source/WebCore/testing/Internals.cpp        2017-03-30 14:40:46 UTC (rev 214604)
</span><span class="lines">@@ -62,6 +62,7 @@
</span><span class="cx"> #include &quot;FrameLoader.h&quot;
</span><span class="cx"> #include &quot;FrameView.h&quot;
</span><span class="cx"> #include &quot;GCObservation.h&quot;
</span><ins>+#include &quot;GridPosition.h&quot;
</ins><span class="cx"> #include &quot;HTMLCanvasElement.h&quot;
</span><span class="cx"> #include &quot;HTMLIFrameElement.h&quot;
</span><span class="cx"> #include &quot;HTMLImageElement.h&quot;
</span><span class="lines">@@ -770,6 +771,11 @@
</span><span class="cx">     downcast&lt;BitmapImage&gt;(*image).setClearDecoderAfterAsyncFrameRequestForTesting(value);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Internals::setGridMaxTracksLimit(unsigned maxTrackLimit)
+{
+    GridPosition::setMaxPositionForTesting(maxTrackLimit);
+}
+
</ins><span class="cx"> void Internals::clearPageCache()
</span><span class="cx"> {
</span><span class="cx">     PageCache::singleton().pruneToSizeNow(0, PruningReason::None);
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (214603 => 214604)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.h        2017-03-30 13:11:25 UTC (rev 214603)
+++ trunk/Source/WebCore/testing/Internals.h        2017-03-30 14:40:46 UTC (rev 214604)
</span><span class="lines">@@ -118,6 +118,8 @@
</span><span class="cx">     bool isImageAnimating(HTMLImageElement&amp;);
</span><span class="cx">     void setClearDecoderAfterAsyncFrameRequestForTesting(HTMLImageElement&amp;, bool);
</span><span class="cx"> 
</span><ins>+    void setGridMaxTracksLimit(unsigned);
+
</ins><span class="cx">     void clearPageCache();
</span><span class="cx">     unsigned pageCacheSize() const;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (214603 => 214604)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.idl        2017-03-30 13:11:25 UTC (rev 214603)
+++ trunk/Source/WebCore/testing/Internals.idl        2017-03-30 14:40:46 UTC (rev 214604)
</span><span class="lines">@@ -250,6 +250,8 @@
</span><span class="cx">     boolean isImageAnimating(HTMLImageElement element);
</span><span class="cx">     void setClearDecoderAfterAsyncFrameRequestForTesting(HTMLImageElement element, boolean value);
</span><span class="cx"> 
</span><ins>+    void setGridMaxTracksLimit(unsigned long maxTracksLimit);
+
</ins><span class="cx">     readonly attribute InternalSettings settings;
</span><span class="cx">     readonly attribute unsigned long workerThreadCount;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>