<!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>[210197] trunk/Source/WebCore</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/210197">210197</a></dd>
<dt>Author</dt> <dd>svillar@igalia.com</dd>
<dt>Date</dt> <dd>2016-12-28 03:06:44 -0800 (Wed, 28 Dec 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[css-grid] Move Grid into GridSizingData
https://bugs.webkit.org/show_bug.cgi?id=165654

Reviewed by Darin Adler.

The grid track sizing algorithm has been using the m_grid attribute from RenderGrid to
compute the sizes of the tracks unconditionally. However the goal is to make it work against
a generic instance of the Grid class, so that the intrinsic size computation and the layout
processes could be effectively decoupled.

Instead of passing the Grid as a new argument to all the track sizing algorithm methods we
leverage the existence of GridSizingData which is already passed to all of them. This data
structure holds from now on a reference to the Grid instance so that the track sizing
algorithm could use it.

No new tests as this is a refactoring.

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::GridSizingData::GridSizingData):
(WebCore::RenderGrid::GridSizingData::grid):
(WebCore::RenderGrid::computeTrackBasedLogicalHeight):
(WebCore::RenderGrid::computeTrackSizesForDirection):
(WebCore::RenderGrid::repeatTracksSizingIfNeeded):
(WebCore::RenderGrid::layoutBlock):
(WebCore::RenderGrid::guttersSize):
(WebCore::RenderGrid::computeIntrinsicLogicalWidths):
(WebCore::RenderGrid::computeIntrinsicLogicalHeight):
(WebCore::RenderGrid::computeUsedBreadthOfGridTracks):
(WebCore::RenderGrid::computeFlexSizedTracksGrowth):
(WebCore::RenderGrid::computeFlexFactorUnitSize):
(WebCore::RenderGrid::findFlexFactorUnitSize):
(WebCore::RenderGrid::rawGridTrackSize):
(WebCore::RenderGrid::gridTrackSize):
(WebCore::RenderGrid::spanningItemCrossesFlexibleSizedTracks):
(WebCore::RenderGrid::resolveContentBasedTrackSizingFunctions):
(WebCore::RenderGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems):
(WebCore::RenderGrid::resolveContentBasedTrackSizingFunctionsForItems):
(WebCore::RenderGrid::tracksAreWiderThanMinTrackBreadth):
(WebCore::RenderGrid::trackSizesForComputedStyle):
(WebCore::RenderGrid::applyStretchAlignmentToTracksIfNeeded):
(WebCore::RenderGrid::layoutGridItems):
(WebCore::RenderGrid::offsetAndBreadthForPositionedChild):
(WebCore::RenderGrid::assumedRowsSizeForOrthogonalChild):
(WebCore::RenderGrid::gridAreaBreadthForChild):
(WebCore::RenderGrid::gridAreaBreadthForChildIncludingAlignmentOffsets):
(WebCore::RenderGrid::populateGridPositionsForDirection):
(WebCore::RenderGrid::columnAxisOffsetForChild):
(WebCore::RenderGrid::rowAxisOffsetForChild):
(WebCore::RenderGrid::findChildLogicalPosition):
(WebCore::RenderGrid::numTracks):
(WebCore::RenderGrid::paintChildren):
* rendering/RenderGrid.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</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>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210196 => 210197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-12-28 11:04:16 UTC (rev 210196)
+++ trunk/Source/WebCore/ChangeLog        2016-12-28 11:06:44 UTC (rev 210197)
</span><span class="lines">@@ -1,3 +1,58 @@
</span><ins>+2016-12-09  Sergio Villar Senin  &lt;svillar@igalia.com&gt;
+
+        [css-grid] Move Grid into GridSizingData
+        https://bugs.webkit.org/show_bug.cgi?id=165654
+
+        Reviewed by Darin Adler.
+
+        The grid track sizing algorithm has been using the m_grid attribute from RenderGrid to
+        compute the sizes of the tracks unconditionally. However the goal is to make it work against
+        a generic instance of the Grid class, so that the intrinsic size computation and the layout
+        processes could be effectively decoupled.
+
+        Instead of passing the Grid as a new argument to all the track sizing algorithm methods we
+        leverage the existence of GridSizingData which is already passed to all of them. This data
+        structure holds from now on a reference to the Grid instance so that the track sizing
+        algorithm could use it.
+
+        No new tests as this is a refactoring.
+
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::GridSizingData::GridSizingData):
+        (WebCore::RenderGrid::GridSizingData::grid):
+        (WebCore::RenderGrid::computeTrackBasedLogicalHeight):
+        (WebCore::RenderGrid::computeTrackSizesForDirection):
+        (WebCore::RenderGrid::repeatTracksSizingIfNeeded):
+        (WebCore::RenderGrid::layoutBlock):
+        (WebCore::RenderGrid::guttersSize):
+        (WebCore::RenderGrid::computeIntrinsicLogicalWidths):
+        (WebCore::RenderGrid::computeIntrinsicLogicalHeight):
+        (WebCore::RenderGrid::computeUsedBreadthOfGridTracks):
+        (WebCore::RenderGrid::computeFlexSizedTracksGrowth):
+        (WebCore::RenderGrid::computeFlexFactorUnitSize):
+        (WebCore::RenderGrid::findFlexFactorUnitSize):
+        (WebCore::RenderGrid::rawGridTrackSize):
+        (WebCore::RenderGrid::gridTrackSize):
+        (WebCore::RenderGrid::spanningItemCrossesFlexibleSizedTracks):
+        (WebCore::RenderGrid::resolveContentBasedTrackSizingFunctions):
+        (WebCore::RenderGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems):
+        (WebCore::RenderGrid::resolveContentBasedTrackSizingFunctionsForItems):
+        (WebCore::RenderGrid::tracksAreWiderThanMinTrackBreadth):
+        (WebCore::RenderGrid::trackSizesForComputedStyle):
+        (WebCore::RenderGrid::applyStretchAlignmentToTracksIfNeeded):
+        (WebCore::RenderGrid::layoutGridItems):
+        (WebCore::RenderGrid::offsetAndBreadthForPositionedChild):
+        (WebCore::RenderGrid::assumedRowsSizeForOrthogonalChild):
+        (WebCore::RenderGrid::gridAreaBreadthForChild):
+        (WebCore::RenderGrid::gridAreaBreadthForChildIncludingAlignmentOffsets):
+        (WebCore::RenderGrid::populateGridPositionsForDirection):
+        (WebCore::RenderGrid::columnAxisOffsetForChild):
+        (WebCore::RenderGrid::rowAxisOffsetForChild):
+        (WebCore::RenderGrid::findChildLogicalPosition):
+        (WebCore::RenderGrid::numTracks):
+        (WebCore::RenderGrid::paintChildren):
+        * rendering/RenderGrid.h:
+
</ins><span class="cx"> 2016-12-27  Michael Catanzaro  &lt;mcatanzaro@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] Improve user agent construction
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderGridcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (210196 => 210197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderGrid.cpp        2016-12-28 11:04:16 UTC (rev 210196)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp        2016-12-28 11:06:44 UTC (rev 210197)
</span><span class="lines">@@ -362,9 +362,10 @@
</span><span class="cx"> class RenderGrid::GridSizingData {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(GridSizingData);
</span><span class="cx"> public:
</span><del>-    GridSizingData(unsigned gridColumnCount, unsigned gridRowCount)
</del><ins>+    GridSizingData(unsigned gridColumnCount, unsigned gridRowCount, Grid&amp; grid)
</ins><span class="cx">         : columnTracks(gridColumnCount)
</span><span class="cx">         , rowTracks(gridRowCount)
</span><ins>+        , m_grid(grid)
</ins><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -420,6 +421,8 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    Grid&amp; grid() const { return m_grid; }
+
</ins><span class="cx"> private:
</span><span class="cx">     std::optional&lt;LayoutUnit&gt; freeSpaceForColumns;
</span><span class="cx">     std::optional&lt;LayoutUnit&gt; freeSpaceForRows;
</span><span class="lines">@@ -426,6 +429,8 @@
</span><span class="cx">     // No need to store one per direction as it will be only used for computations during each axis
</span><span class="cx">     // track sizing. It's cached here because we need it to compute relative sizes.
</span><span class="cx">     std::optional&lt;LayoutUnit&gt; m_availableSpace;
</span><ins>+
+    Grid&amp; m_grid;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> void RenderGrid::GridSizingData::setFreeSpace(GridTrackSizingDirection direction, std::optional&lt;LayoutUnit&gt; freeSpace)
</span><span class="lines">@@ -516,7 +521,7 @@
</span><span class="cx">     for (const auto&amp; row : sizingData.rowTracks)
</span><span class="cx">         logicalHeight += row.baseSize();
</span><span class="cx"> 
</span><del>-    logicalHeight += guttersSize(ForRows, 0, sizingData.rowTracks.size());
</del><ins>+    logicalHeight += guttersSize(sizingData.grid(), ForRows, 0, sizingData.rowTracks.size());
</ins><span class="cx"> 
</span><span class="cx">     return logicalHeight;
</span><span class="cx"> }
</span><span class="lines">@@ -524,7 +529,7 @@
</span><span class="cx"> void RenderGrid::computeTrackSizesForDirection(GridTrackSizingDirection direction, GridSizingData&amp; sizingData, LayoutUnit availableSpace)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(sizingData.isValidTransition(direction));
</span><del>-    LayoutUnit totalGuttersSize = guttersSize(direction, 0, m_grid.numTracks(direction));
</del><ins>+    LayoutUnit totalGuttersSize = guttersSize(sizingData.grid(), direction, 0, m_grid.numTracks(direction));
</ins><span class="cx">     sizingData.setAvailableSpace(availableSpace);
</span><span class="cx">     sizingData.setFreeSpace(direction, availableSpace - totalGuttersSize);
</span><span class="cx">     sizingData.sizingOperation = TrackSizing;
</span><span class="lines">@@ -537,7 +542,7 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderGrid::repeatTracksSizingIfNeeded(GridSizingData&amp; sizingData, LayoutUnit availableSpaceForColumns, LayoutUnit availableSpaceForRows)
</span><span class="cx"> {
</span><del>-    ASSERT(!m_grid.needsItemsPlacement());
</del><ins>+    ASSERT(!sizingData.grid().needsItemsPlacement());
</ins><span class="cx">     ASSERT(sizingData.sizingState &gt; GridSizingData::RowSizingFirstIteration);
</span><span class="cx"> 
</span><span class="cx">     // In orthogonal flow cases column track's size is determined by using the computed
</span><span class="lines">@@ -548,7 +553,7 @@
</span><span class="cx">     // a new cycle of the sizing algorithm; there may be more. In addition, not all the
</span><span class="cx">     // cases with orthogonal flows require this extra cycle; we need a more specific
</span><span class="cx">     // condition to detect whether child's min-content contribution has changed or not.
</span><del>-    if (m_grid.hasAnyOrthogonalGridItem()) {
</del><ins>+    if (sizingData.grid().hasAnyOrthogonalGridItem()) {
</ins><span class="cx">         computeTrackSizesForDirection(ForColumns, sizingData, availableSpaceForColumns);
</span><span class="cx">         computeTrackSizesForDirection(ForRows, sizingData, availableSpaceForRows);
</span><span class="cx">     }
</span><span class="lines">@@ -596,7 +601,7 @@
</span><span class="cx"> 
</span><span class="cx">     placeItemsOnGrid(m_grid, TrackSizing);
</span><span class="cx"> 
</span><del>-    GridSizingData sizingData(numTracks(ForColumns, m_grid), numTracks(ForRows, m_grid));
</del><ins>+    GridSizingData sizingData(numTracks(ForColumns, m_grid), numTracks(ForRows, m_grid), m_grid);
</ins><span class="cx"> 
</span><span class="cx">     // At this point the logical width is always definite as the above call to updateLogicalWidth()
</span><span class="cx">     // properly resolves intrinsic sizes. We cannot do the same for heights though because many code
</span><span class="lines">@@ -667,7 +672,7 @@
</span><span class="cx">     return valueForLength(direction == ForColumns ? style().gridColumnGap() : style().gridRowGap(), LayoutUnit());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-LayoutUnit RenderGrid::guttersSize(GridTrackSizingDirection direction, unsigned startLine, unsigned span) const
</del><ins>+LayoutUnit RenderGrid::guttersSize(const Grid&amp; grid, GridTrackSizingDirection direction, unsigned startLine, unsigned span) const
</ins><span class="cx"> {
</span><span class="cx">     if (span &lt;= 1)
</span><span class="cx">         return { };
</span><span class="lines">@@ -675,7 +680,7 @@
</span><span class="cx">     LayoutUnit gap = gridGapForDirection(direction);
</span><span class="cx"> 
</span><span class="cx">     // Fast path, no collapsing tracks.
</span><del>-    if (!m_grid.hasAutoRepeatEmptyTracks(direction))
</del><ins>+    if (!grid.hasAutoRepeatEmptyTracks(direction))
</ins><span class="cx">         return gap * (span - 1);
</span><span class="cx"> 
</span><span class="cx">     // If there are collapsing tracks we need to be sure that gutters are properly collapsed. Apart
</span><span class="lines">@@ -687,12 +692,12 @@
</span><span class="cx">     unsigned endLine = startLine + span;
</span><span class="cx"> 
</span><span class="cx">     for (unsigned line = startLine; line &lt; endLine - 1; ++line) {
</span><del>-        if (!m_grid.isEmptyAutoRepeatTrack(direction, line))
</del><ins>+        if (!grid.isEmptyAutoRepeatTrack(direction, line))
</ins><span class="cx">             gapAccumulator += gap;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // The above loop adds one extra gap for trailing collapsed tracks.
</span><del>-    if (gapAccumulator &amp;&amp; m_grid.isEmptyAutoRepeatTrack(direction, endLine - 1)) {
</del><ins>+    if (gapAccumulator &amp;&amp; grid.isEmptyAutoRepeatTrack(direction, endLine - 1)) {
</ins><span class="cx">         ASSERT(gapAccumulator &gt;= gap);
</span><span class="cx">         gapAccumulator -= gap;
</span><span class="cx">     }
</span><span class="lines">@@ -699,9 +704,9 @@
</span><span class="cx"> 
</span><span class="cx">     // If the startLine is the start line of a collapsed track we need to go backwards till we reach
</span><span class="cx">     // a non collapsed track. If we find a non collapsed track we need to add that gap.
</span><del>-    if (startLine &amp;&amp; m_grid.isEmptyAutoRepeatTrack(direction, startLine)) {
</del><ins>+    if (startLine &amp;&amp; grid.isEmptyAutoRepeatTrack(direction, startLine)) {
</ins><span class="cx">         unsigned nonEmptyTracksBeforeStartLine = startLine;
</span><del>-        auto begin = m_grid.autoRepeatEmptyTracks(direction)-&gt;begin();
</del><ins>+        auto begin = grid.autoRepeatEmptyTracks(direction)-&gt;begin();
</ins><span class="cx">         for (auto it = begin; *it != startLine; ++it) {
</span><span class="cx">             ASSERT(nonEmptyTracksBeforeStartLine);
</span><span class="cx">             --nonEmptyTracksBeforeStartLine;
</span><span class="lines">@@ -712,10 +717,10 @@
</span><span class="cx"> 
</span><span class="cx">     // If the endLine is the end line of a collapsed track we need to go forward till we reach a non
</span><span class="cx">     // collapsed track. If we find a non collapsed track we need to add that gap.
</span><del>-    if (m_grid.isEmptyAutoRepeatTrack(direction, endLine - 1)) {
-        unsigned nonEmptyTracksAfterEndLine = m_grid.numTracks(direction) - endLine;
-        auto currentEmptyTrack = m_grid.autoRepeatEmptyTracks(direction)-&gt;find(endLine - 1);
-        auto endEmptyTrack = m_grid.autoRepeatEmptyTracks(direction)-&gt;end();
</del><ins>+    if (grid.isEmptyAutoRepeatTrack(direction, endLine - 1)) {
+        unsigned nonEmptyTracksAfterEndLine = grid.numTracks(direction) - endLine;
+        auto currentEmptyTrack = grid.autoRepeatEmptyTracks(direction)-&gt;find(endLine - 1);
+        auto endEmptyTrack = grid.autoRepeatEmptyTracks(direction)-&gt;end();
</ins><span class="cx">         // HashSet iterators do not implement operator- so we have to manually iterate to know the number of remaining empty tracks.
</span><span class="cx">         for (auto it = ++currentEmptyTrack; it != endEmptyTrack; ++it) {
</span><span class="cx">             ASSERT(nonEmptyTracksAfterEndLine &gt;= 1);
</span><span class="lines">@@ -734,13 +739,13 @@
</span><span class="cx">     if (!wasPopulated)
</span><span class="cx">         const_cast&lt;RenderGrid*&gt;(this)-&gt;placeItemsOnGrid(const_cast&lt;Grid&amp;&gt;(m_grid), IntrinsicSizeComputation);
</span><span class="cx"> 
</span><del>-    GridSizingData sizingData(numTracks(ForColumns, m_grid), numTracks(ForRows, m_grid));
</del><ins>+    GridSizingData sizingData(numTracks(ForColumns, m_grid), numTracks(ForRows, m_grid), const_cast&lt;Grid&amp;&gt;(m_grid));
</ins><span class="cx">     sizingData.setAvailableSpace(std::nullopt);
</span><span class="cx">     sizingData.setFreeSpace(ForColumns, std::nullopt);
</span><span class="cx">     sizingData.sizingOperation = IntrinsicSizeComputation;
</span><span class="cx">     computeUsedBreadthOfGridTracks(ForColumns, sizingData, minLogicalWidth, maxLogicalWidth);
</span><span class="cx"> 
</span><del>-    LayoutUnit totalGuttersSize = guttersSize(ForColumns, 0, sizingData.columnTracks.size());
</del><ins>+    LayoutUnit totalGuttersSize = guttersSize(sizingData.grid(), ForColumns, 0, sizingData.columnTracks.size());
</ins><span class="cx">     minLogicalWidth += totalGuttersSize;
</span><span class="cx">     maxLogicalWidth += totalGuttersSize;
</span><span class="cx"> 
</span><span class="lines">@@ -767,7 +772,7 @@
</span><span class="cx">     minHeight += scrollbarHeight;
</span><span class="cx">     maxHeight += scrollbarHeight;
</span><span class="cx"> 
</span><del>-    LayoutUnit totalGuttersSize = guttersSize(ForRows, 0, m_grid.numTracks(ForRows));
</del><ins>+    LayoutUnit totalGuttersSize = guttersSize(sizingData.grid(), ForRows, 0, m_grid.numTracks(ForRows));
</ins><span class="cx">     minHeight += totalGuttersSize;
</span><span class="cx">     maxHeight += totalGuttersSize;
</span><span class="cx"> 
</span><span class="lines">@@ -821,7 +826,7 @@
</span><span class="cx">     // 1. Initialize per Grid track variables.
</span><span class="cx">     for (unsigned i = 0; i &lt; tracks.size(); ++i) {
</span><span class="cx">         GridTrack&amp; track = tracks[i];
</span><del>-        const GridTrackSize&amp; trackSize = gridTrackSize(direction, i, sizingData.sizingOperation);
</del><ins>+        const GridTrackSize&amp; trackSize = gridTrackSize(direction, i, sizingData);
</ins><span class="cx"> 
</span><span class="cx">         track.setBaseSize(computeUsedBreadthOfMinLength(trackSize, maxSize));
</span><span class="cx">         track.setGrowthLimit(computeUsedBreadthOfMaxLength(trackSize, track.baseSize(), maxSize));
</span><span class="lines">@@ -885,22 +890,23 @@
</span><span class="cx">     // 4. Grow all Grid tracks having a fraction as the MaxTrackSizingFunction.
</span><span class="cx">     double flexFraction = 0;
</span><span class="cx">     if (hasDefiniteFreeSpace)
</span><del>-        flexFraction = findFlexFactorUnitSize(tracks, GridSpan::translatedDefiniteGridSpan(0, tracks.size()), direction, sizingData.sizingOperation, initialFreeSpace.value());
</del><ins>+        flexFraction = findFlexFactorUnitSize(tracks, GridSpan::translatedDefiniteGridSpan(0, tracks.size()), direction, initialFreeSpace.value(), sizingData);
</ins><span class="cx">     else {
</span><span class="cx">         for (const auto&amp; trackIndex : flexibleSizedTracksIndex)
</span><del>-            flexFraction = std::max(flexFraction, normalizedFlexFraction(tracks[trackIndex], gridTrackSize(direction, trackIndex, sizingData.sizingOperation).maxTrackBreadth().flex()));
</del><ins>+            flexFraction = std::max(flexFraction, normalizedFlexFraction(tracks[trackIndex], gridTrackSize(direction, trackIndex, sizingData).maxTrackBreadth().flex()));
</ins><span class="cx"> 
</span><del>-        if (m_grid.hasGridItems()) {
</del><ins>+        Grid&amp; grid = sizingData.grid();
+        if (grid.hasGridItems()) {
</ins><span class="cx">             for (unsigned i = 0; i &lt; flexibleSizedTracksIndex.size(); ++i) {
</span><del>-                GridIterator iterator(m_grid, direction, flexibleSizedTracksIndex[i]);
</del><ins>+                GridIterator iterator(grid, direction, flexibleSizedTracksIndex[i]);
</ins><span class="cx">                 while (auto* gridItem = iterator.nextGridItem()) {
</span><del>-                    const GridSpan&amp; span = m_grid.gridItemSpan(*gridItem, direction);
</del><ins>+                    const GridSpan&amp; span = grid.gridItemSpan(*gridItem, direction);
</ins><span class="cx"> 
</span><span class="cx">                     // Do not include already processed items.
</span><span class="cx">                     if (i &gt; 0 &amp;&amp; span.startLine() &lt;= flexibleSizedTracksIndex[i - 1])
</span><span class="cx">                         continue;
</span><span class="cx"> 
</span><del>-                    flexFraction = std::max(flexFraction, findFlexFactorUnitSize(tracks, span, direction, sizingData.sizingOperation, maxContentForChild(*gridItem, direction, sizingData)));
</del><ins>+                    flexFraction = std::max(flexFraction, findFlexFactorUnitSize(tracks, span, direction, maxContentForChild(*gridItem, direction, sizingData), sizingData));
</ins><span class="cx">                 }
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="lines">@@ -908,7 +914,7 @@
</span><span class="cx">     LayoutUnit totalGrowth;
</span><span class="cx">     Vector&lt;LayoutUnit&gt; increments;
</span><span class="cx">     increments.grow(flexibleSizedTracksIndex.size());
</span><del>-    computeFlexSizedTracksGrowth(direction, sizingData.sizingOperation, tracks, flexibleSizedTracksIndex, flexFraction, increments, totalGrowth);
</del><ins>+    computeFlexSizedTracksGrowth(direction, sizingData, tracks, flexibleSizedTracksIndex, flexFraction, increments, totalGrowth);
</ins><span class="cx"> 
</span><span class="cx">     // We only need to redo the flex fraction computation for indefinite heights (definite sizes are
</span><span class="cx">     // already constrained by min/max sizes). Regarding widths, they are always definite at layout
</span><span class="lines">@@ -924,11 +930,11 @@
</span><span class="cx">         bool checkMaxSize = maxSize &amp;&amp; rowsSize &gt; maxSize.value();
</span><span class="cx">         if (checkMinSize || checkMaxSize) {
</span><span class="cx">             LayoutUnit constrainedFreeSpace = checkMaxSize ? maxSize.value() : LayoutUnit(-1);
</span><del>-            constrainedFreeSpace = std::max(constrainedFreeSpace, minSize.value()) - guttersSize(ForRows, 0, m_grid.numTracks(ForRows));
-            flexFraction = findFlexFactorUnitSize(tracks, GridSpan::translatedDefiniteGridSpan(0, tracks.size()), ForRows, sizingData.sizingOperation, constrainedFreeSpace);
</del><ins>+            constrainedFreeSpace = std::max(constrainedFreeSpace, minSize.value()) - guttersSize(sizingData.grid(), ForRows, 0, sizingData.grid().numTracks(ForRows));
+            flexFraction = findFlexFactorUnitSize(tracks, GridSpan::translatedDefiniteGridSpan(0, tracks.size()), ForRows, constrainedFreeSpace, sizingData);
</ins><span class="cx"> 
</span><span class="cx">             totalGrowth = LayoutUnit(0);
</span><del>-            computeFlexSizedTracksGrowth(ForRows, sizingData.sizingOperation, tracks, flexibleSizedTracksIndex, flexFraction, increments, totalGrowth);
</del><ins>+            computeFlexSizedTracksGrowth(ForRows, sizingData, tracks, flexibleSizedTracksIndex, flexFraction, increments, totalGrowth);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -943,13 +949,13 @@
</span><span class="cx">     sizingData.setFreeSpace(direction, freeSpace);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderGrid::computeFlexSizedTracksGrowth(GridTrackSizingDirection direction, SizingOperation sizingOperation, Vector&lt;GridTrack&gt;&amp; tracks, const Vector&lt;unsigned&gt;&amp; flexibleSizedTracksIndex, double flexFraction, Vector&lt;LayoutUnit&gt;&amp; increments, LayoutUnit&amp; totalGrowth) const
</del><ins>+void RenderGrid::computeFlexSizedTracksGrowth(GridTrackSizingDirection direction, const GridSizingData&amp; sizingData, Vector&lt;GridTrack&gt;&amp; tracks, const Vector&lt;unsigned&gt;&amp; flexibleSizedTracksIndex, double flexFraction, Vector&lt;LayoutUnit&gt;&amp; increments, LayoutUnit&amp; totalGrowth) const
</ins><span class="cx"> {
</span><span class="cx">     size_t numFlexTracks = flexibleSizedTracksIndex.size();
</span><span class="cx">     ASSERT(increments.size() == numFlexTracks);
</span><span class="cx">     for (size_t i = 0; i &lt; numFlexTracks; ++i) {
</span><span class="cx">         unsigned trackIndex = flexibleSizedTracksIndex[i];
</span><del>-        auto trackSize = gridTrackSize(direction, trackIndex, sizingOperation);
</del><ins>+        auto trackSize = gridTrackSize(direction, trackIndex, sizingData);
</ins><span class="cx">         ASSERT(trackSize.maxTrackBreadth().isFlex());
</span><span class="cx">         LayoutUnit oldBaseSize = tracks[trackIndex].baseSize();
</span><span class="cx">         LayoutUnit newBaseSize = std::max(oldBaseSize, LayoutUnit(flexFraction * trackSize.maxTrackBreadth().flex()));
</span><span class="lines">@@ -986,7 +992,7 @@
</span><span class="cx">     return infinity;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-double RenderGrid::computeFlexFactorUnitSize(const Vector&lt;GridTrack&gt;&amp; tracks, GridTrackSizingDirection direction, SizingOperation sizingOperation, double flexFactorSum, LayoutUnit leftOverSpace, const Vector&lt;unsigned, 8&gt;&amp; flexibleTracksIndexes, std::unique_ptr&lt;TrackIndexSet&gt; tracksToTreatAsInflexible) const
</del><ins>+double RenderGrid::computeFlexFactorUnitSize(const Vector&lt;GridTrack&gt;&amp; tracks, GridTrackSizingDirection direction, const GridSizingData&amp; sizingData, double flexFactorSum, LayoutUnit leftOverSpace, const Vector&lt;unsigned, 8&gt;&amp; flexibleTracksIndexes, std::unique_ptr&lt;TrackIndexSet&gt; tracksToTreatAsInflexible) const
</ins><span class="cx"> {
</span><span class="cx">     // We want to avoid the effect of flex factors sum below 1 making the factor unit size to grow exponentially.
</span><span class="cx">     double hypotheticalFactorUnitSize = leftOverSpace / std::max&lt;double&gt;(1, flexFactorSum);
</span><span class="lines">@@ -997,7 +1003,7 @@
</span><span class="cx">         if (tracksToTreatAsInflexible &amp;&amp; tracksToTreatAsInflexible-&gt;contains(index))
</span><span class="cx">             continue;
</span><span class="cx">         LayoutUnit baseSize = tracks[index].baseSize();
</span><del>-        double flexFactor = gridTrackSize(direction, index, sizingOperation).maxTrackBreadth().flex();
</del><ins>+        double flexFactor = gridTrackSize(direction, index, sizingData).maxTrackBreadth().flex();
</ins><span class="cx">         // treating all such tracks as inflexible.
</span><span class="cx">         if (baseSize &gt; hypotheticalFactorUnitSize * flexFactor) {
</span><span class="cx">             leftOverSpace -= baseSize;
</span><span class="lines">@@ -1009,11 +1015,11 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     if (!validFlexFactorUnit)
</span><del>-        return computeFlexFactorUnitSize(tracks, direction, sizingOperation, flexFactorSum, leftOverSpace, flexibleTracksIndexes, WTFMove(tracksToTreatAsInflexible));
</del><ins>+        return computeFlexFactorUnitSize(tracks, direction, sizingData, flexFactorSum, leftOverSpace, flexibleTracksIndexes, WTFMove(tracksToTreatAsInflexible));
</ins><span class="cx">     return hypotheticalFactorUnitSize;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-double RenderGrid::findFlexFactorUnitSize(const Vector&lt;GridTrack&gt;&amp; tracks, const GridSpan&amp; tracksSpan, GridTrackSizingDirection direction, SizingOperation sizingOperation, LayoutUnit leftOverSpace) const
</del><ins>+double RenderGrid::findFlexFactorUnitSize(const Vector&lt;GridTrack&gt;&amp; tracks, const GridSpan&amp; tracksSpan, GridTrackSizingDirection direction, LayoutUnit leftOverSpace, const GridSizingData&amp; sizingData) const
</ins><span class="cx"> {
</span><span class="cx">     if (leftOverSpace &lt;= 0)
</span><span class="cx">         return 0;
</span><span class="lines">@@ -1021,7 +1027,7 @@
</span><span class="cx">     double flexFactorSum = 0;
</span><span class="cx">     Vector&lt;unsigned, 8&gt; flexibleTracksIndexes;
</span><span class="cx">     for (auto trackIndex : tracksSpan) {
</span><del>-        GridTrackSize trackSize = gridTrackSize(direction, trackIndex, sizingOperation);
</del><ins>+        GridTrackSize trackSize = gridTrackSize(direction, trackIndex, sizingData);
</ins><span class="cx">         if (!trackSize.maxTrackBreadth().isFlex())
</span><span class="cx">             leftOverSpace -= tracks[trackIndex].baseSize();
</span><span class="cx">         else {
</span><span class="lines">@@ -1034,7 +1040,7 @@
</span><span class="cx">     // The function is not called if we don't have &lt;flex&gt; grid tracks
</span><span class="cx">     ASSERT(!flexibleTracksIndexes.isEmpty());
</span><span class="cx"> 
</span><del>-    return computeFlexFactorUnitSize(tracks, direction, sizingOperation, flexFactorSum, leftOverSpace, flexibleTracksIndexes);
</del><ins>+    return computeFlexFactorUnitSize(tracks, direction, sizingData, flexFactorSum, leftOverSpace, flexibleTracksIndexes);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static bool hasOverrideContainingBlockContentSizeForChild(const RenderBox&amp; child, GridTrackSizingDirection direction)
</span><span class="lines">@@ -1062,7 +1068,7 @@
</span><span class="cx">     return child.hasRelativeLogicalHeight() || child.style().logicalHeight().isIntrinsicOrAuto();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-const GridTrackSize&amp; RenderGrid::rawGridTrackSize(GridTrackSizingDirection direction, unsigned translatedIndex) const
</del><ins>+const GridTrackSize&amp; RenderGrid::rawGridTrackSize(GridTrackSizingDirection direction, unsigned translatedIndex, const GridSizingData&amp; sizingData) const
</ins><span class="cx"> {
</span><span class="cx">     bool isRowAxis = direction == ForColumns;
</span><span class="cx">     auto&amp; trackStyles = isRowAxis ? style().gridColumns() : style().gridRows();
</span><span class="lines">@@ -1069,7 +1075,7 @@
</span><span class="cx">     auto&amp; autoRepeatTrackStyles = isRowAxis ? style().gridAutoRepeatColumns() : style().gridAutoRepeatRows();
</span><span class="cx">     auto&amp; autoTrackStyles = isRowAxis ? style().gridAutoColumns() : style().gridAutoRows();
</span><span class="cx">     unsigned insertionPoint = isRowAxis ? style().gridAutoRepeatColumnsInsertionPoint() : style().gridAutoRepeatRowsInsertionPoint();
</span><del>-    unsigned autoRepeatTracksCount = m_grid.autoRepeatTracks(direction);
</del><ins>+    unsigned autoRepeatTracksCount = sizingData.grid().autoRepeatTracks(direction);
</ins><span class="cx"> 
</span><span class="cx">     // We should not use GridPositionsResolver::explicitGridXXXCount() for this because the
</span><span class="cx">     // explicit grid might be larger than the number of tracks in grid-template-rows|columns (if
</span><span class="lines">@@ -1076,7 +1082,7 @@
</span><span class="cx">     // grid-template-areas is specified for example).
</span><span class="cx">     unsigned explicitTracksCount = trackStyles.size() + autoRepeatTracksCount;
</span><span class="cx"> 
</span><del>-    int untranslatedIndexAsInt = translatedIndex + m_grid.smallestTrackStart(direction);
</del><ins>+    int untranslatedIndexAsInt = translatedIndex + sizingData.grid().smallestTrackStart(direction);
</ins><span class="cx">     unsigned autoTrackStylesSize = autoTrackStyles.size();
</span><span class="cx">     if (untranslatedIndexAsInt &lt; 0) {
</span><span class="cx">         int index = untranslatedIndexAsInt % static_cast&lt;int&gt;(autoTrackStylesSize);
</span><span class="lines">@@ -1100,13 +1106,13 @@
</span><span class="cx">     return trackStyles[untranslatedIndex - autoRepeatTracksCount];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GridTrackSize RenderGrid::gridTrackSize(GridTrackSizingDirection direction, unsigned translatedIndex, SizingOperation sizingOperation) const
</del><ins>+GridTrackSize RenderGrid::gridTrackSize(GridTrackSizingDirection direction, unsigned translatedIndex, const GridSizingData&amp; sizingData) const
</ins><span class="cx"> {
</span><span class="cx">     // Collapse empty auto repeat tracks if auto-fit.
</span><del>-    if (m_grid.hasAutoRepeatEmptyTracks(direction) &amp;&amp; m_grid.isEmptyAutoRepeatTrack(direction, translatedIndex))
</del><ins>+    if (sizingData.grid().hasAutoRepeatEmptyTracks(direction) &amp;&amp; sizingData.grid().isEmptyAutoRepeatTrack(direction, translatedIndex))
</ins><span class="cx">         return { Length(Fixed), LengthTrackSizing };
</span><span class="cx"> 
</span><del>-    auto&amp; trackSize = rawGridTrackSize(direction, translatedIndex);
</del><ins>+    auto&amp; trackSize = rawGridTrackSize(direction, translatedIndex, sizingData);
</ins><span class="cx">     if (trackSize.isFitContent())
</span><span class="cx">         return trackSize;
</span><span class="cx"> 
</span><span class="lines">@@ -1117,7 +1123,7 @@
</span><span class="cx">     if (minTrackBreadth.isPercentage() || maxTrackBreadth.isPercentage()) {
</span><span class="cx">         // If the logical width/height of the grid container is indefinite, percentage values are treated as &lt;auto&gt;.
</span><span class="cx">         // For the inline axis this only happens when we're computing the intrinsic sizes (IntrinsicSizeComputation).
</span><del>-        if (sizingOperation == IntrinsicSizeComputation || (direction == ForRows &amp;&amp; !hasDefiniteLogicalHeight())) {
</del><ins>+        if (sizingData.sizingOperation == IntrinsicSizeComputation || (direction == ForRows &amp;&amp; !hasDefiniteLogicalHeight())) {
</ins><span class="cx">             if (minTrackBreadth.isPercentage())
</span><span class="cx">                 minTrackBreadth = Length(Auto);
</span><span class="cx">             if (maxTrackBreadth.isPercentage())
</span><span class="lines">@@ -1269,10 +1275,10 @@
</span><span class="cx">     GridSpan m_span;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-bool RenderGrid::spanningItemCrossesFlexibleSizedTracks(const GridSpan&amp; itemSpan, GridTrackSizingDirection direction, SizingOperation sizingOperation) const
</del><ins>+bool RenderGrid::spanningItemCrossesFlexibleSizedTracks(const GridSpan&amp; itemSpan, GridTrackSizingDirection direction, const GridSizingData&amp; sizingData) const
</ins><span class="cx"> {
</span><span class="cx">     for (auto trackPosition : itemSpan) {
</span><del>-        const GridTrackSize&amp; trackSize = gridTrackSize(direction, trackPosition, sizingOperation);
</del><ins>+        const GridTrackSize&amp; trackSize = gridTrackSize(direction, trackPosition, sizingData);
</ins><span class="cx">         if (trackSize.minTrackBreadth().isFlex() || trackSize.maxTrackBreadth().isFlex())
</span><span class="cx">             return true;
</span><span class="cx">     }
</span><span class="lines">@@ -1289,17 +1295,18 @@
</span><span class="cx"> {
</span><span class="cx">     sizingData.itemsSortedByIncreasingSpan.shrink(0);
</span><span class="cx">     HashSet&lt;RenderBox*&gt; itemsSet;
</span><del>-    if (m_grid.hasGridItems()) {
</del><ins>+    Grid&amp; grid = sizingData.grid();
+    if (grid.hasGridItems()) {
</ins><span class="cx">         for (auto trackIndex : sizingData.contentSizedTracksIndex) {
</span><del>-            GridIterator iterator(m_grid, direction, trackIndex);
</del><ins>+            GridIterator iterator(grid, direction, trackIndex);
</ins><span class="cx">             GridTrack&amp; track = (direction == ForColumns) ? sizingData.columnTracks[trackIndex] : sizingData.rowTracks[trackIndex];
</span><span class="cx"> 
</span><span class="cx">             while (auto* gridItem = iterator.nextGridItem()) {
</span><span class="cx">                 if (itemsSet.add(gridItem).isNewEntry) {
</span><del>-                    const GridSpan&amp; span = m_grid.gridItemSpan(*gridItem, direction);
</del><ins>+                    const GridSpan&amp; span = grid.gridItemSpan(*gridItem, direction);
</ins><span class="cx">                     if (span.integerSpan() == 1)
</span><span class="cx">                         resolveContentBasedTrackSizingFunctionsForNonSpanningItems(direction, span, *gridItem, track, sizingData);
</span><del>-                    else if (!spanningItemCrossesFlexibleSizedTracks(span, direction, sizingData.sizingOperation))
</del><ins>+                    else if (!spanningItemCrossesFlexibleSizedTracks(span, direction, sizingData))
</ins><span class="cx">                         sizingData.itemsSortedByIncreasingSpan.append(GridItemWithSpan(*gridItem, span));
</span><span class="cx">                 }
</span><span class="cx">             }
</span><span class="lines">@@ -1329,7 +1336,7 @@
</span><span class="cx"> void RenderGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems(GridTrackSizingDirection direction, const GridSpan&amp; span, RenderBox&amp; gridItem, GridTrack&amp; track, GridSizingData&amp; sizingData) const
</span><span class="cx"> {
</span><span class="cx">     unsigned trackPosition = span.startLine();
</span><del>-    GridTrackSize trackSize = gridTrackSize(direction, trackPosition, sizingData.sizingOperation);
</del><ins>+    GridTrackSize trackSize = gridTrackSize(direction, trackPosition, sizingData);
</ins><span class="cx"> 
</span><span class="cx">     if (trackSize.hasMinContentMinTrackBreadth())
</span><span class="cx">         track.setBaseSize(std::max(track.baseSize(), minContentForChild(gridItem, direction, sizingData)));
</span><span class="lines">@@ -1488,7 +1495,7 @@
</span><span class="cx">         sizingData.growBeyondGrowthLimitsTracks.shrink(0);
</span><span class="cx">         LayoutUnit spanningTracksSize;
</span><span class="cx">         for (auto trackPosition : itemSpan) {
</span><del>-            const GridTrackSize&amp; trackSize = gridTrackSize(direction, trackPosition, sizingData.sizingOperation);
</del><ins>+            const GridTrackSize&amp; trackSize = gridTrackSize(direction, trackPosition, sizingData);
</ins><span class="cx">             GridTrack&amp; track = (direction == ForColumns) ? sizingData.columnTracks[trackPosition] : sizingData.rowTracks[trackPosition];
</span><span class="cx">             spanningTracksSize += trackSizeForTrackSizeComputationPhase(phase, track, ForbidInfinity);
</span><span class="cx">             if (!shouldProcessTrackForTrackSizeComputationPhase(phase, trackSize))
</span><span class="lines">@@ -1503,7 +1510,7 @@
</span><span class="cx">         if (sizingData.filteredTracks.isEmpty())
</span><span class="cx">             continue;
</span><span class="cx"> 
</span><del>-        spanningTracksSize += guttersSize(direction, itemSpan.startLine(), itemSpan.integerSpan());
</del><ins>+        spanningTracksSize += guttersSize(sizingData.grid(), direction, itemSpan.startLine(), itemSpan.integerSpan());
</ins><span class="cx"> 
</span><span class="cx">         LayoutUnit extraSpace = currentItemSizeForTrackSizeComputationPhase(phase, gridItemWithSpan.gridItem(), direction, sizingData) - spanningTracksSize;
</span><span class="cx">         extraSpace = std::max&lt;LayoutUnit&gt;(extraSpace, 0);
</span><span class="lines">@@ -1603,7 +1610,7 @@
</span><span class="cx">     const Vector&lt;GridTrack&gt;&amp; tracks = (direction == ForColumns) ? sizingData.columnTracks : sizingData.rowTracks;
</span><span class="cx">     const LayoutUnit maxSize = sizingData.availableSpace().value_or(0);
</span><span class="cx">     for (unsigned i = 0; i &lt; tracks.size(); ++i) {
</span><del>-        const GridTrackSize&amp; trackSize = gridTrackSize(direction, i, sizingData.sizingOperation);
</del><ins>+        const GridTrackSize&amp; trackSize = gridTrackSize(direction, i, sizingData);
</ins><span class="cx">         if (computeUsedBreadthOfMinLength(trackSize, maxSize) &gt; tracks[i].baseSize())
</span><span class="cx">             return false;
</span><span class="cx">     }
</span><span class="lines">@@ -1962,6 +1969,8 @@
</span><span class="cx">     if (numPositions &lt; 2)
</span><span class="cx">         return tracks;
</span><span class="cx"> 
</span><ins>+    // FIXME: enable the ASSERT once m_grid is persistent.
+    // ASSERT(!m_grid.needsItemsPlacement());
</ins><span class="cx">     bool hasCollapsedTracks = m_grid.hasAutoRepeatEmptyTracks(direction);
</span><span class="cx">     LayoutUnit gap = !hasCollapsedTracks ? gridGapForDirection(direction) : LayoutUnit();
</span><span class="cx">     tracks.reserveCapacity(numPositions - 1);
</span><span class="lines">@@ -2009,7 +2018,7 @@
</span><span class="cx">     Vector&lt;GridTrack&gt;&amp; tracks = (direction == ForColumns) ? sizingData.columnTracks : sizingData.rowTracks;
</span><span class="cx">     Vector&lt;unsigned&gt; autoSizedTracksIndex;
</span><span class="cx">     for (unsigned i = 0; i &lt; tracks.size(); ++i) {
</span><del>-        const GridTrackSize&amp; trackSize = gridTrackSize(direction, i, sizingData.sizingOperation);
</del><ins>+        const GridTrackSize&amp; trackSize = gridTrackSize(direction, i, sizingData);
</ins><span class="cx">         if (trackSize.hasAutoMaxTrackBreadth())
</span><span class="cx">             autoSizedTracksIndex.append(i);
</span><span class="cx">     }
</span><span class="lines">@@ -2066,7 +2075,7 @@
</span><span class="cx">         updateAutoMarginsInColumnAxisIfNeeded(*child);
</span><span class="cx">         updateAutoMarginsInRowAxisIfNeeded(*child);
</span><span class="cx"> 
</span><del>-        child-&gt;setLogicalLocation(findChildLogicalPosition(*child));
</del><ins>+        child-&gt;setLogicalLocation(findChildLogicalPosition(*child, sizingData));
</ins><span class="cx"> 
</span><span class="cx">         // If the child moved, we have to repaint it as well as any floating/positioned
</span><span class="cx">         // descendants. An exception is if we need a layout. In this case, we know we're going to
</span><span class="lines">@@ -2167,7 +2176,8 @@
</span><span class="cx"> 
</span><span class="cx">         // These vectors store line positions including gaps, but we shouldn't consider them for the edges of the grid.
</span><span class="cx">         if (endLine &gt; 0 &amp;&amp; endLine &lt; lastLine) {
</span><del>-            end -= guttersSize(direction, endLine - 1, 2);
</del><ins>+            ASSERT(!m_grid.needsItemsPlacement());
+            end -= guttersSize(m_grid, direction, endLine - 1, 2);
</ins><span class="cx">             end -= isRowAxis ? m_offsetBetweenColumns : m_offsetBetweenRows;
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -2184,7 +2194,8 @@
</span><span class="cx">             offset = translateRTLCoordinate(m_columnPositions[endLine]) - borderLogicalLeft();
</span><span class="cx"> 
</span><span class="cx">             if (endLine &gt; 0 &amp;&amp; endLine &lt; lastLine) {
</span><del>-                offset += guttersSize(direction, endLine - 1, 2);
</del><ins>+                ASSERT(!m_grid.needsItemsPlacement());
+                offset += guttersSize(m_grid, direction, endLine - 1, 2);
</ins><span class="cx">                 offset += isRowAxis ? m_offsetBetweenColumns : m_offsetBetweenRows;
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="lines">@@ -2191,15 +2202,15 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-LayoutUnit RenderGrid::assumedRowsSizeForOrthogonalChild(const RenderBox&amp; child, SizingOperation sizingOperation) const
</del><ins>+LayoutUnit RenderGrid::assumedRowsSizeForOrthogonalChild(const RenderBox&amp; child, const GridSizingData&amp; sizingData) const
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(isOrthogonalChild(child));
</span><del>-    const GridSpan&amp; span = m_grid.gridItemSpan(child, ForRows);
</del><ins>+    const GridSpan&amp; span = sizingData.grid().gridItemSpan(child, ForRows);
</ins><span class="cx">     LayoutUnit gridAreaSize;
</span><span class="cx">     bool gridAreaIsIndefinite = false;
</span><span class="cx">     LayoutUnit containingBlockAvailableSize = containingBlockLogicalHeightForContent(ExcludeMarginBorderPadding);
</span><span class="cx">     for (auto trackPosition : span) {
</span><del>-        GridLength maxTrackSize = gridTrackSize(ForRows, trackPosition, sizingOperation).maxTrackBreadth();
</del><ins>+        GridLength maxTrackSize = gridTrackSize(ForRows, trackPosition, sizingData).maxTrackBreadth();
</ins><span class="cx">         if (maxTrackSize.isContentSized() || maxTrackSize.isFlex())
</span><span class="cx">             gridAreaIsIndefinite = true;
</span><span class="cx">         else
</span><span class="lines">@@ -2206,7 +2217,7 @@
</span><span class="cx">             gridAreaSize += valueForLength(maxTrackSize.length(), containingBlockAvailableSize);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    gridAreaSize += guttersSize(ForRows, span.startLine(), span.integerSpan());
</del><ins>+    gridAreaSize += guttersSize(sizingData.grid(), ForRows, span.startLine(), span.integerSpan());
</ins><span class="cx"> 
</span><span class="cx">     return gridAreaIsIndefinite ? std::max(child.maxPreferredLogicalWidth(), gridAreaSize) : gridAreaSize;
</span><span class="cx"> }
</span><span class="lines">@@ -2217,15 +2228,15 @@
</span><span class="cx">     // may depend on the row track's size. It's possible that the row tracks sizing logic has not been performed yet,
</span><span class="cx">     // so we will need to do an estimation.
</span><span class="cx">     if (direction == ForRows &amp;&amp; sizingData.sizingState == GridSizingData::ColumnSizingFirstIteration)
</span><del>-        return assumedRowsSizeForOrthogonalChild(child, sizingData.sizingOperation);
</del><ins>+        return assumedRowsSizeForOrthogonalChild(child, sizingData);
</ins><span class="cx"> 
</span><span class="cx">     const Vector&lt;GridTrack&gt;&amp; tracks = direction == ForColumns ? sizingData.columnTracks : sizingData.rowTracks;
</span><del>-    const GridSpan&amp; span = m_grid.gridItemSpan(child, direction);
</del><ins>+    const GridSpan&amp; span = sizingData.grid().gridItemSpan(child, direction);
</ins><span class="cx">     LayoutUnit gridAreaBreadth = 0;
</span><span class="cx">     for (auto trackPosition : span)
</span><span class="cx">         gridAreaBreadth += tracks[trackPosition].baseSize();
</span><span class="cx"> 
</span><del>-    gridAreaBreadth += guttersSize(direction, span.startLine(), span.integerSpan());
</del><ins>+    gridAreaBreadth += guttersSize(sizingData.grid(), direction, span.startLine(), span.integerSpan());
</ins><span class="cx"> 
</span><span class="cx">     return gridAreaBreadth;
</span><span class="cx"> }
</span><span class="lines">@@ -2235,7 +2246,7 @@
</span><span class="cx">     // We need the cached value when available because Content Distribution alignment properties
</span><span class="cx">     // may have some influence in the final grid area breadth.
</span><span class="cx">     const auto&amp; tracks = (direction == ForColumns) ? sizingData.columnTracks : sizingData.rowTracks;
</span><del>-    const auto&amp; span = m_grid.gridItemSpan(child, direction);
</del><ins>+    const auto&amp; span = sizingData.grid().gridItemSpan(child, direction);
</ins><span class="cx">     const auto&amp; linePositions = (direction == ForColumns) ? m_columnPositions : m_rowPositions;
</span><span class="cx"> 
</span><span class="cx">     LayoutUnit initialTrackPosition = linePositions[span.startLine()];
</span><span class="lines">@@ -2265,10 +2276,11 @@
</span><span class="cx">     positions.resize(numberOfLines);
</span><span class="cx">     auto borderAndPadding = isRowAxis ? borderAndPaddingLogicalLeft() : borderAndPaddingBefore();
</span><span class="cx">     positions[0] = borderAndPadding + offset.positionOffset;
</span><ins>+    Grid&amp; grid = sizingData.grid();
</ins><span class="cx">     if (numberOfLines &gt; 1) {
</span><span class="cx">         // If we have collapsed tracks we just ignore gaps here and add them later as we might not
</span><span class="cx">         // compute the gap between two consecutive tracks without examining the surrounding ones.
</span><del>-        bool hasCollapsedTracks = m_grid.hasAutoRepeatEmptyTracks(direction);
</del><ins>+        bool hasCollapsedTracks = grid.hasAutoRepeatEmptyTracks(direction);
</ins><span class="cx">         LayoutUnit gap = !hasCollapsedTracks ? gridGapForDirection(direction) : LayoutUnit();
</span><span class="cx">         unsigned nextToLastLine = numberOfLines - 2;
</span><span class="cx">         for (unsigned i = 0; i &lt; nextToLastLine; ++i)
</span><span class="lines">@@ -2279,16 +2291,16 @@
</span><span class="cx">         // coincide exactly) except on the edges of the grid where they become 0.
</span><span class="cx">         if (hasCollapsedTracks) {
</span><span class="cx">             gap = gridGapForDirection(direction);
</span><del>-            unsigned remainingEmptyTracks = m_grid.autoRepeatEmptyTracks(direction)-&gt;size();
</del><ins>+            unsigned remainingEmptyTracks = grid.autoRepeatEmptyTracks(direction)-&gt;size();
</ins><span class="cx">             LayoutUnit gapAccumulator;
</span><span class="cx">             for (unsigned i = 1; i &lt; lastLine; ++i) {
</span><del>-                if (m_grid.isEmptyAutoRepeatTrack(direction, i - 1))
</del><ins>+                if (grid.isEmptyAutoRepeatTrack(direction, i - 1))
</ins><span class="cx">                     --remainingEmptyTracks;
</span><span class="cx">                 else {
</span><span class="cx">                     // Add gap between consecutive non empty tracks. Add it also just once for an
</span><span class="cx">                     // arbitrary number of empty tracks between two non empty ones.
</span><span class="cx">                     bool allRemainingTracksAreEmpty = remainingEmptyTracks == (lastLine - i);
</span><del>-                    if (!allRemainingTracksAreEmpty || !m_grid.isEmptyAutoRepeatTrack(direction, i))
</del><ins>+                    if (!allRemainingTracksAreEmpty || !grid.isEmptyAutoRepeatTrack(direction, i))
</ins><span class="cx">                         gapAccumulator += gap;
</span><span class="cx">                 }
</span><span class="cx">                 positions[i] += gapAccumulator;
</span><span class="lines">@@ -2582,9 +2594,9 @@
</span><span class="cx">     return GridAxisStart;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-LayoutUnit RenderGrid::columnAxisOffsetForChild(const RenderBox&amp; child) const
</del><ins>+LayoutUnit RenderGrid::columnAxisOffsetForChild(const RenderBox&amp; child, const GridSizingData&amp; sizingData) const
</ins><span class="cx"> {
</span><del>-    const GridSpan&amp; rowsSpan = m_grid.gridItemSpan(child, ForRows);
</del><ins>+    const GridSpan&amp; rowsSpan = sizingData.grid().gridItemSpan(child, ForRows);
</ins><span class="cx">     unsigned childStartLine = rowsSpan.startLine();
</span><span class="cx">     LayoutUnit startOfRow = m_rowPositions[childStartLine];
</span><span class="cx">     LayoutUnit startPosition = startOfRow + marginBeforeForChild(child);
</span><span class="lines">@@ -2615,9 +2627,9 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-LayoutUnit RenderGrid::rowAxisOffsetForChild(const RenderBox&amp; child) const
</del><ins>+LayoutUnit RenderGrid::rowAxisOffsetForChild(const RenderBox&amp; child, const GridSizingData&amp; sizingData) const
</ins><span class="cx"> {
</span><del>-    const GridSpan&amp; columnsSpan = m_grid.gridItemSpan(child, ForColumns);
</del><ins>+    const GridSpan&amp; columnsSpan = sizingData.grid().gridItemSpan(child, ForColumns);
</ins><span class="cx">     unsigned childStartLine = columnsSpan.startLine();
</span><span class="cx">     LayoutUnit startOfColumn = m_columnPositions[childStartLine];
</span><span class="cx">     LayoutUnit startPosition = startOfColumn + marginStartForChild(child);
</span><span class="lines">@@ -2757,10 +2769,10 @@
</span><span class="cx">     return rightGridEdgePosition + alignmentOffset - coordinate;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-LayoutPoint RenderGrid::findChildLogicalPosition(const RenderBox&amp; child) const
</del><ins>+LayoutPoint RenderGrid::findChildLogicalPosition(const RenderBox&amp; child, const GridSizingData&amp; sizingData) const
</ins><span class="cx"> {
</span><del>-    LayoutUnit columnAxisOffset = columnAxisOffsetForChild(child);
-    LayoutUnit rowAxisOffset = rowAxisOffsetForChild(child);
</del><ins>+    LayoutUnit columnAxisOffset = columnAxisOffsetForChild(child, sizingData);
+    LayoutUnit rowAxisOffset = rowAxisOffsetForChild(child, sizingData);
</ins><span class="cx">     // We stored m_columnPositions's data ignoring the direction, hence we might need now
</span><span class="cx">     // to translate positions from RTL to LTR, as it's more convenient for painting.
</span><span class="cx">     if (!style().isLeftToRightDirection())
</span><span class="lines">@@ -2781,6 +2793,7 @@
</span><span class="cx">     // to get it from the style. Note that we know for sure that there are't any implicit tracks,
</span><span class="cx">     // because not having rows implies that there are no &quot;normal&quot; children (out-of-flow children are
</span><span class="cx">     // not stored in m_grid).
</span><ins>+    ASSERT(!m_grid.needsItemsPlacement());
</ins><span class="cx">     if (direction == ForRows)
</span><span class="cx">         return grid.numTracks(ForRows);
</span><span class="cx"> 
</span><span class="lines">@@ -2790,6 +2803,8 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderGrid::paintChildren(PaintInfo&amp; paintInfo, const LayoutPoint&amp; paintOffset, PaintInfo&amp; forChild, bool usePrintRect)
</span><span class="cx"> {
</span><ins>+    // FIXME: enable the ASSERT once m_grid is persistent.
+    // ASSERT(!m_grid.needsItemsPlacement());
</ins><span class="cx">     for (RenderBox* child = m_grid.orderIterator().first(); child; child = m_grid.orderIterator().next())
</span><span class="cx">         paintChild(*child, paintInfo, paintOffset, forChild, usePrintRect, PaintAsInlineBlock);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderGridh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderGrid.h (210196 => 210197)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderGrid.h        2016-12-28 11:04:16 UTC (rev 210196)
+++ trunk/Source/WebCore/rendering/RenderGrid.h        2016-12-28 11:06:44 UTC (rev 210197)
</span><span class="lines">@@ -84,7 +84,7 @@
</span><span class="cx">     class GridSizingData;
</span><span class="cx">     enum SizingOperation { TrackSizing, IntrinsicSizeComputation };
</span><span class="cx">     void computeUsedBreadthOfGridTracks(GridTrackSizingDirection, GridSizingData&amp;, LayoutUnit&amp; baseSizesWithoutMaximization, LayoutUnit&amp; growthLimitsWithoutMaximization) const;
</span><del>-    void computeFlexSizedTracksGrowth(GridTrackSizingDirection, SizingOperation, Vector&lt;GridTrack&gt;&amp;, const Vector&lt;unsigned&gt;&amp; flexibleSizedTracksIndex, double flexFraction, Vector&lt;LayoutUnit&gt;&amp; increments, LayoutUnit&amp; totalGrowth) const;
</del><ins>+    void computeFlexSizedTracksGrowth(GridTrackSizingDirection, const GridSizingData&amp;, Vector&lt;GridTrack&gt;&amp;, const Vector&lt;unsigned&gt;&amp; flexibleSizedTracksIndex, double flexFraction, Vector&lt;LayoutUnit&gt;&amp; increments, LayoutUnit&amp; totalGrowth) const;
</ins><span class="cx">     LayoutUnit computeUsedBreadthOfMinLength(const GridTrackSize&amp;, LayoutUnit maxSize) const;
</span><span class="cx">     LayoutUnit computeUsedBreadthOfMaxLength(const GridTrackSize&amp;, LayoutUnit usedBreadth, LayoutUnit maxSize) const;
</span><span class="cx">     void resolveContentBasedTrackSizingFunctions(GridTrackSizingDirection, GridSizingData&amp;) const;
</span><span class="lines">@@ -131,11 +131,11 @@
</span><span class="cx">     template &lt;TrackSizeComputationPhase&gt; void distributeSpaceToTracks(Vector&lt;GridTrack*&gt;&amp;, Vector&lt;GridTrack*&gt;* growBeyondGrowthLimitsTracks, LayoutUnit&amp; availableLogicalSpace) const;
</span><span class="cx"> 
</span><span class="cx">     typedef HashSet&lt;unsigned, DefaultHash&lt;unsigned&gt;::Hash, WTF::UnsignedWithZeroKeyHashTraits&lt;unsigned&gt;&gt; TrackIndexSet;
</span><del>-    double computeFlexFactorUnitSize(const Vector&lt;GridTrack&gt;&amp;, GridTrackSizingDirection, SizingOperation, double flexFactorSum, LayoutUnit leftOverSpace, const Vector&lt;unsigned, 8&gt;&amp; flexibleTracksIndexes, std::unique_ptr&lt;TrackIndexSet&gt; tracksToTreatAsInflexible = nullptr) const;
-    double findFlexFactorUnitSize(const Vector&lt;GridTrack&gt;&amp;, const GridSpan&amp;, GridTrackSizingDirection, SizingOperation, LayoutUnit spaceToFill) const;
</del><ins>+    double computeFlexFactorUnitSize(const Vector&lt;GridTrack&gt;&amp;, GridTrackSizingDirection, const GridSizingData&amp;, double flexFactorSum, LayoutUnit leftOverSpace, const Vector&lt;unsigned, 8&gt;&amp; flexibleTracksIndexes, std::unique_ptr&lt;TrackIndexSet&gt; tracksToTreatAsInflexible = nullptr) const;
+    double findFlexFactorUnitSize(const Vector&lt;GridTrack&gt;&amp;, const GridSpan&amp;, GridTrackSizingDirection, LayoutUnit spaceToFill, const GridSizingData&amp;) const;
</ins><span class="cx"> 
</span><del>-    const GridTrackSize&amp; rawGridTrackSize(GridTrackSizingDirection, unsigned) const;
-    GridTrackSize gridTrackSize(GridTrackSizingDirection, unsigned, SizingOperation) const;
</del><ins>+    const GridTrackSize&amp; rawGridTrackSize(GridTrackSizingDirection, unsigned, const GridSizingData&amp;) const;
+    GridTrackSize gridTrackSize(GridTrackSizingDirection, unsigned, const GridSizingData&amp;) const;
</ins><span class="cx"> 
</span><span class="cx">     bool updateOverrideContainingBlockContentSizeForChild(RenderBox&amp;, GridTrackSizingDirection, GridSizingData&amp;) const;
</span><span class="cx">     LayoutUnit logicalHeightForChild(RenderBox&amp;) const;
</span><span class="lines">@@ -144,10 +144,10 @@
</span><span class="cx">     LayoutUnit maxContentForChild(RenderBox&amp;, GridTrackSizingDirection, GridSizingData&amp;) const;
</span><span class="cx">     GridAxisPosition columnAxisPositionForChild(const RenderBox&amp;) const;
</span><span class="cx">     GridAxisPosition rowAxisPositionForChild(const RenderBox&amp;) const;
</span><del>-    LayoutUnit columnAxisOffsetForChild(const RenderBox&amp;) const;
-    LayoutUnit rowAxisOffsetForChild(const RenderBox&amp;) const;
</del><ins>+    LayoutUnit columnAxisOffsetForChild(const RenderBox&amp;, const GridSizingData&amp;) const;
+    LayoutUnit rowAxisOffsetForChild(const RenderBox&amp;, const GridSizingData&amp;) const;
</ins><span class="cx">     ContentAlignmentData computeContentPositionAndDistributionOffset(GridTrackSizingDirection, const LayoutUnit&amp; availableFreeSpace, unsigned numberOfGridTracks) const;
</span><del>-    LayoutPoint findChildLogicalPosition(const RenderBox&amp;) const;
</del><ins>+    LayoutPoint findChildLogicalPosition(const RenderBox&amp;, const GridSizingData&amp;) const;
</ins><span class="cx">     GridArea cachedGridArea(const RenderBox&amp;) const;
</span><span class="cx">     GridSpan cachedGridSpan(const RenderBox&amp;, GridTrackSizingDirection) const;
</span><span class="cx"> 
</span><span class="lines">@@ -154,7 +154,7 @@
</span><span class="cx"> 
</span><span class="cx">     LayoutUnit gridAreaBreadthForChild(const RenderBox&amp; child, GridTrackSizingDirection, const GridSizingData&amp;) const;
</span><span class="cx">     LayoutUnit gridAreaBreadthForChildIncludingAlignmentOffsets(const RenderBox&amp;, GridTrackSizingDirection, const GridSizingData&amp;) const;
</span><del>-    LayoutUnit assumedRowsSizeForOrthogonalChild(const RenderBox&amp;, SizingOperation) const;
</del><ins>+    LayoutUnit assumedRowsSizeForOrthogonalChild(const RenderBox&amp;, const GridSizingData&amp;) const;
</ins><span class="cx"> 
</span><span class="cx">     void applyStretchAlignmentToTracksIfNeeded(GridTrackSizingDirection, GridSizingData&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -181,9 +181,9 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     LayoutUnit gridGapForDirection(GridTrackSizingDirection) const;
</span><del>-    LayoutUnit guttersSize(GridTrackSizingDirection, unsigned startLine, unsigned span) const;
</del><ins>+    LayoutUnit guttersSize(const Grid&amp;, GridTrackSizingDirection, unsigned startLine, unsigned span) const;
</ins><span class="cx"> 
</span><del>-    bool spanningItemCrossesFlexibleSizedTracks(const GridSpan&amp;, GridTrackSizingDirection, SizingOperation) const;
</del><ins>+    bool spanningItemCrossesFlexibleSizedTracks(const GridSpan&amp;, GridTrackSizingDirection, const GridSizingData&amp;) const;
</ins><span class="cx"> 
</span><span class="cx">     unsigned numTracks(GridTrackSizingDirection, const Grid&amp;) const;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>