<!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>[200368] 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/200368">200368</a></dd>
<dt>Author</dt> <dd>svillar@igalia.com</dd>
<dt>Date</dt> <dd>2016-05-03 04:30:29 -0700 (Tue, 03 May 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[css-grid] Add support for position resolution with auto-repeat tracks
https://bugs.webkit.org/show_bug.cgi?id=157260

Reviewed by Darin Adler.

This is a generalization of our position resolution code so it now supports every possible
type of resolution (definite position, position spans, automatic resolution, named lines
resolution, grid areas...) under the presence of auto-repeat tracks, i.e., tracks that are
dynamically created by the LayoutGrid depending on the available space and that cannot be
directly inferred from the CSS declarations.

This means that we need two extra things to resolve positions:
- the LayoutGrid needs to provide the number of auto-repeat tracks per axis
- a wrapper is needed to hide the eventual presence of auto-repeat tracks (with their line
names) from the rest of the resolution code which should remain mostly unchanged.

The former is trivial (requires passing a new argument to some functions at the most) but
the latter requires a new class called NamedLineCollection. This class allow us to locate
and resolve named lines without having to insert the auto-repeat named lines in the already
existing data structures. It does it in a very compact representation as it does not
duplicate the names for every single repetition.

No new tests required as there is no change in behavior because the auto-repeat tracks
computation is not implemented yet. Current tests already test this code extensively, and
the auto-repeat code paths will be tested later once
RenderGrid::computeAutoRepeatTracksCount() is implemented.

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::computeAutoRepeatTracksCount): New method with empty implementation.
(WebCore::RenderGrid::placeItemsOnGrid): Initialize the auto repeat tracks count.
(WebCore::RenderGrid::populateExplicitGridAndOrderIterator):
(WebCore::RenderGrid::offsetAndBreadthForPositionedChild):
* rendering/RenderGrid.h:
* rendering/style/GridPositionsResolver.cpp:
(WebCore::directionFromSide):
(WebCore::NamedLineCollection::NamedLineCollection): New class which is able to resolve the
positions of a given named line in the presence of auto-repeat and &quot;normal&quot; tracks.
(WebCore::NamedLineCollection::isValidNamedLineOrArea): Checks whether the given named line
is a valid line name or area.
(WebCore::NamedLineCollection::hasNamedLines): Checks whether the named line exists in the
given axis (either specified by auto-repeat or &quot;normal&quot; tracks).
(WebCore::NamedLineCollection::find): Looks for a line number whithin the line numbers where
the given named line was found.
(WebCore::NamedLineCollection::contains):
(WebCore::NamedLineCollection::firstPosition): Returns the first line where the given named
line is located.
(WebCore::adjustGridPositionsFromStyle): Use NamedLineCollection.
(WebCore::GridPositionsResolver::explicitGridColumnCount): Include auto repeat tracks.
(WebCore::GridPositionsResolver::explicitGridRowCount): Ditto.
(WebCore::explicitGridSizeForSide): Ditto.
(WebCore::lookAheadForNamedGridLine): Use NamedLineCollection.
(WebCore::lookBackForNamedGridLine): Ditto.
(WebCore::resolveNamedGridLinePositionFromStyle):
(WebCore::definiteGridSpanWithNamedLineSpanAgainstOpposite):
(WebCore::resolveNamedGridLinePositionAgainstOppositePosition):
(WebCore::resolveGridPositionAgainstOppositePosition):
(WebCore::resolveGridPositionFromStyle):
(WebCore::GridPositionsResolver::resolveGridPositionsFromStyle):
(WebCore::gridLinesForSide): Deleted.
(WebCore::GridPositionsResolver::isNonExistentNamedLineOrArea): Deleted.
* rendering/style/GridPositionsResolver.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>
<li><a href="#trunkSourceWebCorerenderingstyleGridPositionsResolvercpp">trunk/Source/WebCore/rendering/style/GridPositionsResolver.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleGridPositionsResolverh">trunk/Source/WebCore/rendering/style/GridPositionsResolver.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (200367 => 200368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-05-03 09:18:40 UTC (rev 200367)
+++ trunk/Source/WebCore/ChangeLog        2016-05-03 11:30:29 UTC (rev 200368)
</span><span class="lines">@@ -1,3 +1,67 @@
</span><ins>+2016-05-02  Sergio Villar Senin  &lt;svillar@igalia.com&gt;
+
+        [css-grid] Add support for position resolution with auto-repeat tracks
+        https://bugs.webkit.org/show_bug.cgi?id=157260
+
+        Reviewed by Darin Adler.
+
+        This is a generalization of our position resolution code so it now supports every possible
+        type of resolution (definite position, position spans, automatic resolution, named lines
+        resolution, grid areas...) under the presence of auto-repeat tracks, i.e., tracks that are
+        dynamically created by the LayoutGrid depending on the available space and that cannot be
+        directly inferred from the CSS declarations.
+
+        This means that we need two extra things to resolve positions:
+        - the LayoutGrid needs to provide the number of auto-repeat tracks per axis
+        - a wrapper is needed to hide the eventual presence of auto-repeat tracks (with their line
+        names) from the rest of the resolution code which should remain mostly unchanged.
+
+        The former is trivial (requires passing a new argument to some functions at the most) but
+        the latter requires a new class called NamedLineCollection. This class allow us to locate
+        and resolve named lines without having to insert the auto-repeat named lines in the already
+        existing data structures. It does it in a very compact representation as it does not
+        duplicate the names for every single repetition.
+
+        No new tests required as there is no change in behavior because the auto-repeat tracks
+        computation is not implemented yet. Current tests already test this code extensively, and
+        the auto-repeat code paths will be tested later once
+        RenderGrid::computeAutoRepeatTracksCount() is implemented.
+
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::computeAutoRepeatTracksCount): New method with empty implementation.
+        (WebCore::RenderGrid::placeItemsOnGrid): Initialize the auto repeat tracks count.
+        (WebCore::RenderGrid::populateExplicitGridAndOrderIterator):
+        (WebCore::RenderGrid::offsetAndBreadthForPositionedChild):
+        * rendering/RenderGrid.h:
+        * rendering/style/GridPositionsResolver.cpp:
+        (WebCore::directionFromSide):
+        (WebCore::NamedLineCollection::NamedLineCollection): New class which is able to resolve the
+        positions of a given named line in the presence of auto-repeat and &quot;normal&quot; tracks.
+        (WebCore::NamedLineCollection::isValidNamedLineOrArea): Checks whether the given named line
+        is a valid line name or area.
+        (WebCore::NamedLineCollection::hasNamedLines): Checks whether the named line exists in the
+        given axis (either specified by auto-repeat or &quot;normal&quot; tracks).
+        (WebCore::NamedLineCollection::find): Looks for a line number whithin the line numbers where
+        the given named line was found.
+        (WebCore::NamedLineCollection::contains):
+        (WebCore::NamedLineCollection::firstPosition): Returns the first line where the given named
+        line is located.
+        (WebCore::adjustGridPositionsFromStyle): Use NamedLineCollection.
+        (WebCore::GridPositionsResolver::explicitGridColumnCount): Include auto repeat tracks.
+        (WebCore::GridPositionsResolver::explicitGridRowCount): Ditto.
+        (WebCore::explicitGridSizeForSide): Ditto.
+        (WebCore::lookAheadForNamedGridLine): Use NamedLineCollection.
+        (WebCore::lookBackForNamedGridLine): Ditto.
+        (WebCore::resolveNamedGridLinePositionFromStyle):
+        (WebCore::definiteGridSpanWithNamedLineSpanAgainstOpposite):
+        (WebCore::resolveNamedGridLinePositionAgainstOppositePosition):
+        (WebCore::resolveGridPositionAgainstOppositePosition):
+        (WebCore::resolveGridPositionFromStyle):
+        (WebCore::GridPositionsResolver::resolveGridPositionsFromStyle):
+        (WebCore::gridLinesForSide): Deleted.
+        (WebCore::GridPositionsResolver::isNonExistentNamedLineOrArea): Deleted.
+        * rendering/style/GridPositionsResolver.h:
+
</ins><span class="cx"> 2016-05-03  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed. Fix GObject DOM bindings API break after r200316.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderGridcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (200367 => 200368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderGrid.cpp        2016-05-03 09:18:40 UTC (rev 200367)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp        2016-05-03 11:30:29 UTC (rev 200368)
</span><span class="lines">@@ -1185,11 +1185,20 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+unsigned RenderGrid::computeAutoRepeatTracksCount(GridTrackSizingDirection) const
+{
+    // FIXME: implement the algorithm to compute the number of auto repeat tracks.
+    return 0;
+}
+
</ins><span class="cx"> void RenderGrid::placeItemsOnGrid()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!gridWasPopulated());
</span><span class="cx">     ASSERT(m_gridItemArea.isEmpty());
</span><span class="cx"> 
</span><ins>+    m_autoRepeatColumns = computeAutoRepeatTracksCount(ForColumns);
+    m_autoRepeatRows = computeAutoRepeatTracksCount(ForRows);
+
</ins><span class="cx">     populateExplicitGridAndOrderIterator();
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;RenderBox*&gt; autoMajorAxisAutoGridItems;
</span><span class="lines">@@ -1217,8 +1226,8 @@
</span><span class="cx">         insertItemIntoGrid(*child, GridArea(area.rows, area.columns));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ASSERT(gridRowCount() &gt;= GridPositionsResolver::explicitGridRowCount(style()));
-    ASSERT(gridColumnCount() &gt;= GridPositionsResolver::explicitGridColumnCount(style()));
</del><ins>+    ASSERT(gridRowCount() &gt;= GridPositionsResolver::explicitGridRowCount(style(), m_autoRepeatRows));
+    ASSERT(gridColumnCount() &gt;= GridPositionsResolver::explicitGridColumnCount(style(), m_autoRepeatColumns));
</ins><span class="cx"> 
</span><span class="cx">     placeSpecifiedMajorAxisItemsOnGrid(specifiedMajorAxisAutoGridItems);
</span><span class="cx">     placeAutoMajorAxisItemsOnGrid(autoMajorAxisAutoGridItems);
</span><span class="lines">@@ -1238,8 +1247,8 @@
</span><span class="cx"> {
</span><span class="cx">     OrderIteratorPopulator populator(m_orderIterator);
</span><span class="cx">     m_smallestRowStart = m_smallestColumnStart = 0;
</span><del>-    unsigned maximumRowIndex = std::max&lt;unsigned&gt;(1, GridPositionsResolver::explicitGridRowCount(style()));
-    unsigned maximumColumnIndex = std::max&lt;unsigned&gt;(1, GridPositionsResolver::explicitGridColumnCount(style()));
</del><ins>+    unsigned maximumRowIndex = std::max&lt;unsigned&gt;(1, GridPositionsResolver::explicitGridRowCount(style(), m_autoRepeatRows));
+    unsigned maximumColumnIndex = std::max&lt;unsigned&gt;(1, GridPositionsResolver::explicitGridColumnCount(style(), m_autoRepeatColumns));
</ins><span class="cx"> 
</span><span class="cx">     for (RenderBox* child = firstChildBox(); child; child = child-&gt;nextSiblingBox()) {
</span><span class="cx">         if (child-&gt;isOutOfFlowPositioned())
</span><span class="lines">@@ -1247,7 +1256,7 @@
</span><span class="cx"> 
</span><span class="cx">         populator.collectChild(*child);
</span><span class="cx"> 
</span><del>-        GridSpan rowPositions = GridPositionsResolver::resolveGridPositionsFromStyle(style(), *child, ForRows);
</del><ins>+        GridSpan rowPositions = GridPositionsResolver::resolveGridPositionsFromStyle(style(), *child, ForRows, m_autoRepeatRows);
</ins><span class="cx">         if (!rowPositions.isIndefinite()) {
</span><span class="cx">             m_smallestRowStart = std::min(m_smallestRowStart, rowPositions.untranslatedStartLine());
</span><span class="cx">             maximumRowIndex = std::max&lt;int&gt;(maximumRowIndex, rowPositions.untranslatedEndLine());
</span><span class="lines">@@ -1257,7 +1266,7 @@
</span><span class="cx">             maximumRowIndex = std::max(maximumRowIndex, spanSize);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        GridSpan columnPositions = GridPositionsResolver::resolveGridPositionsFromStyle(style(), *child, ForColumns);
</del><ins>+        GridSpan columnPositions = GridPositionsResolver::resolveGridPositionsFromStyle(style(), *child, ForColumns, m_autoRepeatColumns);
</ins><span class="cx">         if (!columnPositions.isIndefinite()) {
</span><span class="cx">             m_smallestColumnStart = std::min(m_smallestColumnStart, columnPositions.untranslatedStartLine());
</span><span class="cx">             maximumColumnIndex = std::max&lt;int&gt;(maximumColumnIndex, columnPositions.untranslatedEndLine());
</span><span class="lines">@@ -1521,7 +1530,8 @@
</span><span class="cx">     ASSERT(child.isHorizontalWritingMode() == isHorizontalWritingMode());
</span><span class="cx">     bool isRowAxis = direction == ForColumns;
</span><span class="cx"> 
</span><del>-    GridSpan positions = GridPositionsResolver::resolveGridPositionsFromStyle(style(), child, direction);
</del><ins>+    unsigned autoRepeatCount = autoRepeatCountForDirection(direction);
+    GridSpan positions = GridPositionsResolver::resolveGridPositionsFromStyle(style(), child, direction, autoRepeatCount);
</ins><span class="cx">     if (positions.isIndefinite()) {
</span><span class="cx">         offset = LayoutUnit();
</span><span class="cx">         breadth = isRowAxis ? clientLogicalWidth() : clientLogicalHeight();
</span><span class="lines">@@ -1536,14 +1546,14 @@
</span><span class="cx">     GridPosition startPosition = isRowAxis ? child.style().gridItemColumnStart() : child.style().gridItemRowStart();
</span><span class="cx">     GridPosition endPosition = isRowAxis ? child.style().gridItemColumnEnd() : child.style().gridItemRowEnd();
</span><span class="cx">     int firstExplicitLine = smallestStart;
</span><del>-    int lastExplicitLine = (isRowAxis ? GridPositionsResolver::explicitGridColumnCount(style()) : GridPositionsResolver::explicitGridRowCount(style())) + smallestStart;
</del><ins>+    int lastExplicitLine = (isRowAxis ? GridPositionsResolver::explicitGridColumnCount(style(), autoRepeatCount) : GridPositionsResolver::explicitGridRowCount(style(), autoRepeatCount)) + smallestStart;
</ins><span class="cx"> 
</span><span class="cx">     bool startIsAuto = startPosition.isAuto()
</span><del>-        || (startPosition.isNamedGridArea() &amp;&amp; GridPositionsResolver::isNonExistentNamedLineOrArea(startPosition.namedGridLine(), style(), (direction == ForColumns) ? ColumnStartSide : RowStartSide))
</del><ins>+        || (startPosition.isNamedGridArea() &amp;&amp; !NamedLineCollection::isValidNamedLineOrArea(startPosition.namedGridLine(), style(), (direction == ForColumns) ? ColumnStartSide : RowStartSide))
</ins><span class="cx">         || (startLine &lt; firstExplicitLine)
</span><span class="cx">         || (startLine &gt; lastExplicitLine);
</span><span class="cx">     bool endIsAuto = endPosition.isAuto()
</span><del>-        || (endPosition.isNamedGridArea() &amp;&amp; GridPositionsResolver::isNonExistentNamedLineOrArea(endPosition.namedGridLine(), style(), (direction == ForColumns) ? ColumnEndSide : RowEndSide))
</del><ins>+        || (endPosition.isNamedGridArea() &amp;&amp; !NamedLineCollection::isValidNamedLineOrArea(endPosition.namedGridLine(), style(), (direction == ForColumns) ? ColumnEndSide : RowEndSide))
</ins><span class="cx">         || (endLine &lt; firstExplicitLine)
</span><span class="cx">         || (endLine &gt; lastExplicitLine);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderGridh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderGrid.h (200367 => 200368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderGrid.h        2016-05-03 09:18:40 UTC (rev 200367)
+++ trunk/Source/WebCore/rendering/RenderGrid.h        2016-05-03 11:30:29 UTC (rev 200368)
</span><span class="lines">@@ -63,6 +63,8 @@
</span><span class="cx">     LayoutUnit guttersSize(GridTrackSizingDirection, size_t span) const;
</span><span class="cx">     LayoutUnit offsetBetweenTracks(GridTrackSizingDirection) const;
</span><span class="cx"> 
</span><ins>+    size_t autoRepeatCountForDirection(GridTrackSizingDirection) const;
+
</ins><span class="cx"> private:
</span><span class="cx">     const char* renderName() const override;
</span><span class="cx">     bool isRenderGrid() const override { return true; }
</span><span class="lines">@@ -79,6 +81,9 @@
</span><span class="cx"> 
</span><span class="cx">     void ensureGridSize(unsigned maximumRowSize, unsigned maximumColumnSize);
</span><span class="cx">     void insertItemIntoGrid(RenderBox&amp;, const GridArea&amp;);
</span><ins>+
+    unsigned computeAutoRepeatTracksCount(GridTrackSizingDirection) const;
+
</ins><span class="cx">     void placeItemsOnGrid();
</span><span class="cx">     void populateExplicitGridAndOrderIterator();
</span><span class="cx">     std::unique_ptr&lt;GridArea&gt; createEmptyGridAreaAtSpecifiedPositionsOutsideGrid(const RenderBox&amp;, GridTrackSizingDirection, const GridSpan&amp;) const;
</span><span class="lines">@@ -198,8 +203,16 @@
</span><span class="cx"> 
</span><span class="cx">     int m_smallestColumnStart;
</span><span class="cx">     int m_smallestRowStart;
</span><ins>+
+    unsigned m_autoRepeatColumns { 0 };
+    unsigned m_autoRepeatRows { 0 };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><ins>+size_t inline RenderGrid::autoRepeatCountForDirection(GridTrackSizingDirection direction) const
+{
+    return direction == ForColumns ? m_autoRepeatColumns : m_autoRepeatRows;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderGrid, isRenderGrid())
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleGridPositionsResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/GridPositionsResolver.cpp (200367 => 200368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/GridPositionsResolver.cpp        2016-05-03 09:18:40 UTC (rev 200367)
+++ trunk/Source/WebCore/rendering/style/GridPositionsResolver.cpp        2016-05-03 11:30:29 UTC (rev 200368)
</span><span class="lines">@@ -59,9 +59,9 @@
</span><span class="cx">     return direction == ForColumns ? ColumnEndSide : RowEndSide;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static const NamedGridLinesMap&amp; gridLinesForSide(const RenderStyle&amp; style, GridPositionSide side)
</del><ins>+static inline GridTrackSizingDirection directionFromSide(GridPositionSide side)
</ins><span class="cx"> {
</span><del>-    return isColumnSide(side) ? style.namedGridColumnLines() : style.namedGridRowLines();
</del><ins>+    return side == ColumnStartSide || side == ColumnEndSide ? ForColumns : ForRows;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static const String implicitNamedGridLineForSide(const String&amp; lineName, GridPositionSide side)
</span><span class="lines">@@ -69,12 +69,93 @@
</span><span class="cx">     return lineName + (isStartSide(side) ? &quot;-start&quot; : &quot;-end&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool GridPositionsResolver::isNonExistentNamedLineOrArea(const String&amp; lineName, const RenderStyle&amp; style, GridPositionSide side)
</del><ins>+NamedLineCollection::NamedLineCollection(const RenderStyle&amp; gridContainerStyle, const String&amp; namedLine, GridTrackSizingDirection direction, unsigned lastLine, unsigned autoRepeatTracksCount)
+    : m_lastLine(lastLine)
+    , m_repetitions(autoRepeatTracksCount)
</ins><span class="cx"> {
</span><del>-    const NamedGridLinesMap&amp; gridLineNames = gridLinesForSide(style, side);
-    return !gridLineNames.contains(implicitNamedGridLineForSide(lineName, side)) &amp;&amp; !gridLineNames.contains(lineName);
</del><ins>+    bool isRowAxis = direction == ForColumns;
+    const NamedGridLinesMap&amp; gridLineNames = isRowAxis ? gridContainerStyle.namedGridColumnLines() : gridContainerStyle.namedGridRowLines();
+    const NamedGridLinesMap&amp; autoRepeatGridLineNames = isRowAxis ? gridContainerStyle.autoRepeatNamedGridColumnLines() : gridContainerStyle.autoRepeatNamedGridRowLines();
+
+    auto linesIterator = gridLineNames.find(namedLine);
+    m_namedLinesIndexes = linesIterator == gridLineNames.end() ? nullptr : &amp;linesIterator-&gt;value;
+
+    auto autoRepeatLinesIterator = autoRepeatGridLineNames.find(namedLine);
+    m_autoRepeatNamedLinesIndexes = autoRepeatLinesIterator == autoRepeatGridLineNames.end() ? nullptr : &amp;autoRepeatLinesIterator-&gt;value;
+
+    m_insertionPoint = isRowAxis ? gridContainerStyle.gridAutoRepeatColumnsInsertionPoint() : gridContainerStyle.gridAutoRepeatRowsInsertionPoint();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool NamedLineCollection::isValidNamedLineOrArea(const String&amp; namedLine, const RenderStyle&amp; gridContainerStyle, GridPositionSide side)
+{
+    bool isRowAxis = directionFromSide(side) == ForColumns;
+    auto&amp; gridLineNames = isRowAxis ? gridContainerStyle.namedGridColumnLines() : gridContainerStyle.namedGridRowLines();
+    auto&amp; autoRepeatGridLineNames = isRowAxis ? gridContainerStyle.autoRepeatNamedGridColumnLines() : gridContainerStyle.autoRepeatNamedGridRowLines();
+
+    if (gridLineNames.contains(namedLine) || autoRepeatGridLineNames.contains(namedLine))
+        return true;
+
+    String implicitName = implicitNamedGridLineForSide(namedLine, side);
+    return gridLineNames.contains(implicitName) || autoRepeatGridLineNames.contains(implicitName);
+}
+
+bool NamedLineCollection::hasNamedLines() const
+{
+    return m_namedLinesIndexes || m_autoRepeatNamedLinesIndexes;
+}
+
+size_t NamedLineCollection::find(unsigned line) const
+{
+    if (line &gt; m_lastLine)
+        return notFound;
+
+    if (!m_autoRepeatNamedLinesIndexes || line &lt; m_insertionPoint)
+        return m_namedLinesIndexes ? m_namedLinesIndexes-&gt;find(line) : notFound;
+
+    if (line &lt;= (m_insertionPoint + m_repetitions)) {
+        size_t localIndex = line - m_insertionPoint;
+
+        // The line names defined in the last line are also present in the first line of the next
+        // repetition (if any). Same for the line names defined in the first line. Note that there
+        // is only one auto-repeated track allowed by the syntax, that's why it's enough to store
+        // indexes 0 and 1 (before and after the track size).
+        if (localIndex == m_repetitions)
+            return m_autoRepeatNamedLinesIndexes-&gt;find(1u);
+        size_t position = m_autoRepeatNamedLinesIndexes-&gt;find(0u);
+        if (position != notFound)
+            return position;
+        return localIndex ? m_autoRepeatNamedLinesIndexes-&gt;find(1u) : notFound;
+    }
+
+    return m_namedLinesIndexes ? m_namedLinesIndexes-&gt;find(line - (m_repetitions - 1)) : notFound;
+}
+
+bool NamedLineCollection::contains(unsigned line) const
+{
+    ASSERT(hasNamedLines());
+    return find(line) != notFound;
+}
+
+unsigned NamedLineCollection::firstPosition() const
+{
+    ASSERT(hasNamedLines());
+    unsigned firstLine = 0;
+
+    if (!m_autoRepeatNamedLinesIndexes) {
+        if (!m_insertionPoint || m_insertionPoint &lt; m_namedLinesIndexes-&gt;at(firstLine))
+            return m_namedLinesIndexes-&gt;at(firstLine) + (m_repetitions ? m_repetitions - 1 : 0);
+        return m_namedLinesIndexes-&gt;at(firstLine);
+    }
+
+    if (!m_namedLinesIndexes)
+        return m_autoRepeatNamedLinesIndexes-&gt;at(firstLine) + m_insertionPoint;
+
+    if (!m_insertionPoint)
+        return m_autoRepeatNamedLinesIndexes-&gt;at(firstLine);
+
+    return std::min(m_namedLinesIndexes-&gt;at(firstLine), m_autoRepeatNamedLinesIndexes-&gt;at(firstLine) + m_insertionPoint);
+}
+
</ins><span class="cx"> static void adjustGridPositionsFromStyle(const RenderStyle&amp; gridContainerStyle, const RenderBox&amp; gridItem, GridTrackSizingDirection direction, GridPosition&amp; initialPosition, GridPosition&amp; finalPosition)
</span><span class="cx"> {
</span><span class="cx">     bool isForColumns = direction == ForColumns;
</span><span class="lines">@@ -88,10 +169,10 @@
</span><span class="cx"> 
</span><span class="cx">     if (gridItem.isOutOfFlowPositioned()) {
</span><span class="cx">         // Early detect the case of non existing named grid lines for positioned items.
</span><del>-        if (initialPosition.isNamedGridArea() &amp;&amp; GridPositionsResolver::isNonExistentNamedLineOrArea(initialPosition.namedGridLine(), gridContainerStyle, initialPositionSide(direction)))
</del><ins>+        if (initialPosition.isNamedGridArea() &amp;&amp; !NamedLineCollection::isValidNamedLineOrArea(initialPosition.namedGridLine(), gridContainerStyle, initialPositionSide(direction)))
</ins><span class="cx">             initialPosition.setAutoPosition();
</span><span class="cx"> 
</span><del>-        if (finalPosition.isNamedGridArea() &amp;&amp; GridPositionsResolver::isNonExistentNamedLineOrArea(finalPosition.namedGridLine(), gridContainerStyle, finalPositionSide(direction)))
</del><ins>+        if (finalPosition.isNamedGridArea() &amp;&amp; !NamedLineCollection::isValidNamedLineOrArea(finalPosition.namedGridLine(), gridContainerStyle, finalPositionSide(direction)))
</ins><span class="cx">             finalPosition.setAutoPosition();
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -102,22 +183,22 @@
</span><span class="cx">         initialPosition.setSpanPosition(1, String());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-unsigned GridPositionsResolver::explicitGridColumnCount(const RenderStyle&amp; gridContainerStyle)
</del><ins>+unsigned GridPositionsResolver::explicitGridColumnCount(const RenderStyle&amp; gridContainerStyle, unsigned autoRepeatTracksCount)
</ins><span class="cx"> {
</span><del>-    return std::min&lt;unsigned&gt;(std::max(gridContainerStyle.gridColumns().size(), gridContainerStyle.namedGridAreaColumnCount()), kGridMaxTracks);
</del><ins>+    return std::min&lt;unsigned&gt;(std::max(gridContainerStyle.gridColumns().size() + autoRepeatTracksCount, gridContainerStyle.namedGridAreaColumnCount()), kGridMaxTracks);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-unsigned GridPositionsResolver::explicitGridRowCount(const RenderStyle&amp; gridContainerStyle)
</del><ins>+unsigned GridPositionsResolver::explicitGridRowCount(const RenderStyle&amp; gridContainerStyle, unsigned autoRepeatTracksCount)
</ins><span class="cx"> {
</span><del>-    return std::min&lt;unsigned&gt;(std::max(gridContainerStyle.gridRows().size(), gridContainerStyle.namedGridAreaRowCount()), kGridMaxTracks);
</del><ins>+    return std::min&lt;unsigned&gt;(std::max(gridContainerStyle.gridRows().size() + autoRepeatTracksCount, gridContainerStyle.namedGridAreaRowCount()), kGridMaxTracks);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static unsigned explicitGridSizeForSide(const RenderStyle&amp; gridContainerStyle, GridPositionSide side)
</del><ins>+static unsigned explicitGridSizeForSide(const RenderStyle&amp; gridContainerStyle, GridPositionSide side, unsigned autoRepeatTracksCount)
</ins><span class="cx"> {
</span><del>-    return isColumnSide(side) ? GridPositionsResolver::explicitGridColumnCount(gridContainerStyle) : GridPositionsResolver::explicitGridRowCount(gridContainerStyle);
</del><ins>+    return isColumnSide(side) ? GridPositionsResolver::explicitGridColumnCount(gridContainerStyle, autoRepeatTracksCount) : GridPositionsResolver::explicitGridRowCount(gridContainerStyle, autoRepeatTracksCount);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static unsigned lookAheadForNamedGridLine(int start, unsigned numberOfLines, const Vector&lt;unsigned&gt;* namedGridLinesIndexes, unsigned gridLastLine)
</del><ins>+static unsigned lookAheadForNamedGridLine(int start, unsigned numberOfLines, unsigned gridLastLine, NamedLineCollection&amp; linesCollection)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(numberOfLines);
</span><span class="cx"> 
</span><span class="lines">@@ -125,11 +206,11 @@
</span><span class="cx">     // See: https://drafts.csswg.org/css-grid/#grid-placement-span-int
</span><span class="cx">     unsigned end = std::max(start, 0);
</span><span class="cx"> 
</span><del>-    if (!namedGridLinesIndexes)
</del><ins>+    if (!linesCollection.hasNamedLines())
</ins><span class="cx">         return std::max(end, gridLastLine + 1) + numberOfLines - 1;
</span><span class="cx"> 
</span><span class="cx">     for (; numberOfLines; ++end) {
</span><del>-        if (end &gt; gridLastLine || namedGridLinesIndexes-&gt;contains(end))
</del><ins>+        if (end &gt; gridLastLine || linesCollection.contains(end))
</ins><span class="cx">             numberOfLines--;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -137,7 +218,7 @@
</span><span class="cx">     return end - 1;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static int lookBackForNamedGridLine(int end, unsigned numberOfLines, const Vector&lt;unsigned&gt;* namedGridLinesIndexes, int gridLastLine)
</del><ins>+static int lookBackForNamedGridLine(int end, unsigned numberOfLines, int gridLastLine, NamedLineCollection&amp; linesCollection)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(numberOfLines);
</span><span class="cx"> 
</span><span class="lines">@@ -145,61 +226,56 @@
</span><span class="cx">     // See: https://drafts.csswg.org/css-grid/#grid-placement-span-int
</span><span class="cx">     int start = std::min(end, gridLastLine);
</span><span class="cx"> 
</span><del>-    if (!namedGridLinesIndexes)
</del><ins>+    if (!linesCollection.hasNamedLines())
</ins><span class="cx">         return std::min(start, -1) - numberOfLines + 1;
</span><span class="cx"> 
</span><span class="cx">     for (; numberOfLines; --start) {
</span><del>-        if (start &lt; 0 || namedGridLinesIndexes-&gt;contains(static_cast&lt;size_t&gt;(start)))
</del><ins>+        if (start &lt; 0 || linesCollection.contains(start))
</ins><span class="cx">             numberOfLines--;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return start + 1;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static int resolveNamedGridLinePositionFromStyle(const RenderStyle&amp; gridContainerStyle, const GridPosition&amp; position, GridPositionSide side)
</del><ins>+static int resolveNamedGridLinePositionFromStyle(const RenderStyle&amp; gridContainerStyle, const GridPosition&amp; position, GridPositionSide side, unsigned autoRepeatTracksCount)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!position.namedGridLine().isNull());
</span><span class="cx"> 
</span><del>-    const NamedGridLinesMap&amp; gridLinesNames = isColumnSide(side) ? gridContainerStyle.namedGridColumnLines() : gridContainerStyle.namedGridRowLines();
-    auto iterator = gridLinesNames.find(position.namedGridLine());
-    const Vector&lt;unsigned&gt;* gridLines = iterator == gridLinesNames.end() ? nullptr : &amp;iterator-&gt;value;
-    unsigned lastLine = explicitGridSizeForSide(gridContainerStyle, side);
</del><ins>+    unsigned lastLine = explicitGridSizeForSide(gridContainerStyle, side, autoRepeatTracksCount);
+    NamedLineCollection linesCollection(gridContainerStyle, position.namedGridLine(), directionFromSide(side), lastLine, autoRepeatTracksCount);
+
</ins><span class="cx">     if (position.isPositive())
</span><del>-        return lookAheadForNamedGridLine(0, std::abs(position.integerPosition()), gridLines, lastLine);
-    return lookBackForNamedGridLine(lastLine, std::abs(position.integerPosition()), gridLines, lastLine);
</del><ins>+        return lookAheadForNamedGridLine(0, std::abs(position.integerPosition()), lastLine, linesCollection);
+    return lookBackForNamedGridLine(lastLine, std::abs(position.integerPosition()), lastLine, linesCollection);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static GridSpan definiteGridSpanWithNamedLineSpanAgainstOpposite(int oppositeLine, const GridPosition&amp; position, GridPositionSide side, const Vector&lt;unsigned&gt;* gridLines, unsigned lastLine)
</del><ins>+static GridSpan definiteGridSpanWithNamedLineSpanAgainstOpposite(int oppositeLine, const GridPosition&amp; position, GridPositionSide side, unsigned lastLine, NamedLineCollection&amp; linesCollection)
</ins><span class="cx"> {
</span><span class="cx">     int start, end;
</span><del>-
</del><span class="cx">     if (side == RowStartSide || side == ColumnStartSide) {
</span><del>-        start = lookBackForNamedGridLine(oppositeLine - 1, position.spanPosition(), gridLines, lastLine);
</del><ins>+        start = lookBackForNamedGridLine(oppositeLine - 1, position.spanPosition(), lastLine, linesCollection);
</ins><span class="cx">         end = oppositeLine;
</span><span class="cx">     } else {
</span><span class="cx">         start = oppositeLine;
</span><del>-        end = lookAheadForNamedGridLine(oppositeLine + 1, position.spanPosition(), gridLines, lastLine);
</del><ins>+        end = lookAheadForNamedGridLine(oppositeLine + 1, position.spanPosition(), lastLine, linesCollection);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return GridSpan::untranslatedDefiniteGridSpan(start, end);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static GridSpan resolveNamedGridLinePositionAgainstOppositePosition(const RenderStyle&amp; gridContainerStyle, int oppositeLine, const GridPosition&amp; position, GridPositionSide side)
</del><ins>+static GridSpan resolveNamedGridLinePositionAgainstOppositePosition(const RenderStyle&amp; gridContainerStyle, int oppositeLine, const GridPosition&amp; position, GridPositionSide side, unsigned autoRepeatTracksCount)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(position.isSpan());
</span><span class="cx">     ASSERT(!position.namedGridLine().isNull());
</span><span class="cx">     // Negative positions are not allowed per the specification and should have been handled during parsing.
</span><span class="cx">     ASSERT(position.spanPosition() &gt; 0);
</span><span class="cx"> 
</span><del>-    const NamedGridLinesMap&amp; gridLinesNames = isColumnSide(side) ? gridContainerStyle.namedGridColumnLines() : gridContainerStyle.namedGridRowLines();
-    auto iterator = gridLinesNames.find(position.namedGridLine());
-    const Vector&lt;unsigned&gt;* gridLines = iterator == gridLinesNames.end() ? nullptr : &amp;iterator-&gt;value;
-    unsigned lastLine = explicitGridSizeForSide(gridContainerStyle, side);
-
-    return definiteGridSpanWithNamedLineSpanAgainstOpposite(oppositeLine, position, side, gridLines, lastLine);
</del><ins>+    unsigned lastLine = explicitGridSizeForSide(gridContainerStyle, side, autoRepeatTracksCount);
+    NamedLineCollection linesCollection(gridContainerStyle, position.namedGridLine(), directionFromSide(side), lastLine, autoRepeatTracksCount);
+    return definiteGridSpanWithNamedLineSpanAgainstOpposite(oppositeLine, position, side, lastLine, linesCollection);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static GridSpan resolveGridPositionAgainstOppositePosition(const RenderStyle&amp; gridContainerStyle, int oppositeLine, const GridPosition&amp; position, GridPositionSide side)
</del><ins>+static GridSpan resolveGridPositionAgainstOppositePosition(const RenderStyle&amp; gridContainerStyle, int oppositeLine, const GridPosition&amp; position, GridPositionSide side, unsigned autoRepeatTracksCount)
</ins><span class="cx"> {
</span><span class="cx">     if (position.isAuto()) {
</span><span class="cx">         if (isStartSide(side))
</span><span class="lines">@@ -212,7 +288,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (!position.namedGridLine().isNull()) {
</span><span class="cx">         // span 2 'c' -&gt; we need to find the appropriate grid line before / after our opposite position.
</span><del>-        return resolveNamedGridLinePositionAgainstOppositePosition(gridContainerStyle, oppositeLine, position, side);
</del><ins>+        return resolveNamedGridLinePositionAgainstOppositePosition(gridContainerStyle, oppositeLine, position, side, autoRepeatTracksCount);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // 'span 1' is contained inside a single grid track regardless of the direction.
</span><span class="lines">@@ -242,21 +318,21 @@
</span><span class="cx">     return position.spanPosition();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static int resolveGridPositionFromStyle(const RenderStyle&amp; gridContainerStyle, const GridPosition&amp; position, GridPositionSide side)
</del><ins>+static int resolveGridPositionFromStyle(const RenderStyle&amp; gridContainerStyle, const GridPosition&amp; position, GridPositionSide side, unsigned autoRepeatTracksCount)
</ins><span class="cx"> {
</span><span class="cx">     switch (position.type()) {
</span><span class="cx">     case ExplicitPosition: {
</span><span class="cx">         ASSERT(position.integerPosition());
</span><span class="cx"> 
</span><span class="cx">         if (!position.namedGridLine().isNull())
</span><del>-            return resolveNamedGridLinePositionFromStyle(gridContainerStyle, position, side);
</del><ins>+            return resolveNamedGridLinePositionFromStyle(gridContainerStyle, position, side, autoRepeatTracksCount);
</ins><span class="cx"> 
</span><span class="cx">         // Handle &lt;integer&gt; explicit position.
</span><span class="cx">         if (position.isPositive())
</span><span class="cx">             return position.integerPosition() - 1;
</span><span class="cx"> 
</span><span class="cx">         unsigned resolvedPosition = std::abs(position.integerPosition()) - 1;
</span><del>-        const unsigned endOfTrack = explicitGridSizeForSide(gridContainerStyle, side);
</del><ins>+        const unsigned endOfTrack = explicitGridSizeForSide(gridContainerStyle, side, autoRepeatTracksCount);
</ins><span class="cx"> 
</span><span class="cx">         return endOfTrack - resolvedPosition;
</span><span class="cx">     }
</span><span class="lines">@@ -268,20 +344,19 @@
</span><span class="cx">         String namedGridLine = position.namedGridLine();
</span><span class="cx">         ASSERT(!position.namedGridLine().isNull());
</span><span class="cx"> 
</span><del>-        const NamedGridLinesMap&amp; gridLineNames = gridLinesForSide(gridContainerStyle, side);
-        auto implicitLine = gridLineNames.find(implicitNamedGridLineForSide(namedGridLine, side));
-        if (implicitLine != gridLineNames.end())
-            return implicitLine-&gt;value[0];
</del><ins>+        unsigned lastLine = explicitGridSizeForSide(gridContainerStyle, side, autoRepeatTracksCount);
+        NamedLineCollection implicitLines(gridContainerStyle, implicitNamedGridLineForSide(namedGridLine, side), directionFromSide(side), lastLine, autoRepeatTracksCount);
+        if (implicitLines.hasNamedLines())
+            return implicitLines.firstPosition();
</ins><span class="cx"> 
</span><span class="cx">         // Otherwise, if there is a named line with the specified name, contributes the first such line to the grid
</span><span class="cx">         // item's placement.
</span><del>-        auto explicitLine = gridLineNames.find(namedGridLine);
-        if (explicitLine != gridLineNames.end())
-            return explicitLine-&gt;value[0];
</del><ins>+        NamedLineCollection explicitLines(gridContainerStyle, namedGridLine, directionFromSide(side), lastLine, autoRepeatTracksCount);
+        if (explicitLines.hasNamedLines())
+            return explicitLines.firstPosition();
</ins><span class="cx"> 
</span><del>-        ASSERT(GridPositionsResolver::isNonExistentNamedLineOrArea(namedGridLine, gridContainerStyle, side));
</del><ins>+        ASSERT(!NamedLineCollection::isValidNamedLineOrArea(namedGridLine, gridContainerStyle, side));
</ins><span class="cx">         // If none of the above works specs mandate to assume that all the lines in the implicit grid have this name.
</span><del>-        unsigned lastLine = explicitGridSizeForSide(gridContainerStyle, side);
</del><span class="cx">         return lastLine + 1;
</span><span class="cx">     }
</span><span class="cx">     case AutoPosition:
</span><span class="lines">@@ -294,7 +369,7 @@
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GridSpan GridPositionsResolver::resolveGridPositionsFromStyle(const RenderStyle&amp; gridContainerStyle, const RenderBox&amp; gridItem, GridTrackSizingDirection direction)
</del><ins>+GridSpan GridPositionsResolver::resolveGridPositionsFromStyle(const RenderStyle&amp; gridContainerStyle, const RenderBox&amp; gridItem, GridTrackSizingDirection direction, unsigned autoRepeatTracksCount)
</ins><span class="cx"> {
</span><span class="cx">     GridPosition initialPosition, finalPosition;
</span><span class="cx">     adjustGridPositionsFromStyle(gridContainerStyle, gridItem, direction, initialPosition, finalPosition);
</span><span class="lines">@@ -308,18 +383,18 @@
</span><span class="cx"> 
</span><span class="cx">     if (initialPosition.shouldBeResolvedAgainstOppositePosition()) {
</span><span class="cx">         // Infer the position from the final position ('auto / 1' or 'span 2 / 3' case).
</span><del>-        auto endLine = resolveGridPositionFromStyle(gridContainerStyle, finalPosition, finalSide);
-        return resolveGridPositionAgainstOppositePosition(gridContainerStyle, endLine, initialPosition, initialSide);
</del><ins>+        auto endLine = resolveGridPositionFromStyle(gridContainerStyle, finalPosition, finalSide, autoRepeatTracksCount);
+        return resolveGridPositionAgainstOppositePosition(gridContainerStyle, endLine, initialPosition, initialSide, autoRepeatTracksCount);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (finalPosition.shouldBeResolvedAgainstOppositePosition()) {
</span><span class="cx">         // Infer our position from the initial position ('1 / auto' or '3 / span 2' case).
</span><del>-        auto startLine = resolveGridPositionFromStyle(gridContainerStyle, initialPosition, initialSide);
-        return resolveGridPositionAgainstOppositePosition(gridContainerStyle, startLine, finalPosition, finalSide);
</del><ins>+        auto startLine = resolveGridPositionFromStyle(gridContainerStyle, initialPosition, initialSide, autoRepeatTracksCount);
+        return resolveGridPositionAgainstOppositePosition(gridContainerStyle, startLine, finalPosition, finalSide, autoRepeatTracksCount);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    int startLine = resolveGridPositionFromStyle(gridContainerStyle, initialPosition, initialSide);
-    int endLine = resolveGridPositionFromStyle(gridContainerStyle, finalPosition, finalSide);
</del><ins>+    int startLine = resolveGridPositionFromStyle(gridContainerStyle, initialPosition, initialSide, autoRepeatTracksCount);
+    int endLine = resolveGridPositionFromStyle(gridContainerStyle, finalPosition, finalSide, autoRepeatTracksCount);
</ins><span class="cx"> 
</span><span class="cx">     if (startLine &gt; endLine)
</span><span class="cx">         std::swap(startLine, endLine);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleGridPositionsResolverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/GridPositionsResolver.h (200367 => 200368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/GridPositionsResolver.h        2016-05-03 09:18:40 UTC (rev 200367)
+++ trunk/Source/WebCore/rendering/style/GridPositionsResolver.h        2016-05-03 11:30:29 UTC (rev 200368)
</span><span class="lines">@@ -46,14 +46,36 @@
</span><span class="cx">     ForRows
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+class NamedLineCollection {
+    WTF_MAKE_NONCOPYABLE(NamedLineCollection);
+public:
+    NamedLineCollection(const RenderStyle&amp;, const String&amp; namedLine, GridTrackSizingDirection, unsigned lastLine, unsigned autoRepeatTracksCount);
+
+    static bool isValidNamedLineOrArea(const String&amp; namedLine, const RenderStyle&amp;, GridPositionSide);
+
+    bool hasNamedLines() const;
+    unsigned firstPosition() const;
+
+    bool contains(unsigned line) const;
+
+private:
+    size_t find(unsigned line) const;
+
+    const Vector&lt;unsigned&gt;* m_namedLinesIndexes { nullptr };
+    const Vector&lt;unsigned&gt;* m_autoRepeatNamedLinesIndexes { nullptr };
+
+    unsigned m_insertionPoint;
+    unsigned m_lastLine;
+    unsigned m_repetitions;
+};
+
</ins><span class="cx"> // Class with all the code related to grid items positions resolution.
</span><span class="cx"> class GridPositionsResolver {
</span><span class="cx"> public:
</span><span class="cx">     static unsigned spanSizeForAutoPlacedItem(const RenderStyle&amp;, const RenderBox&amp;, GridTrackSizingDirection);
</span><del>-    static GridSpan resolveGridPositionsFromStyle(const RenderStyle&amp;, const RenderBox&amp;, GridTrackSizingDirection);
-    static unsigned explicitGridColumnCount(const RenderStyle&amp;);
-    static unsigned explicitGridRowCount(const RenderStyle&amp;);
-    static bool isNonExistentNamedLineOrArea(const String&amp; lineName, const RenderStyle&amp;, GridPositionSide);
</del><ins>+    static GridSpan resolveGridPositionsFromStyle(const RenderStyle&amp;, const RenderBox&amp;, GridTrackSizingDirection, unsigned autoRepeatTracksCount);
+    static unsigned explicitGridColumnCount(const RenderStyle&amp;, unsigned autoRepeatColumnsCount);
+    static unsigned explicitGridRowCount(const RenderStyle&amp;, unsigned autoRepeatRowsCount);
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre>
</div>
</div>

</body>
</html>