<!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>[192153] trunk</title>
</head>
<body>

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

<h3>Log Message</h3>
<pre>[css-grid] Grid placement conflict handling
https://bugs.webkit.org/show_bug.cgi?id=150891

Reviewed by Darin Adler.

Source/WebCore:

If the placement for a grid item contains two lines, and the
start line is further end-ward than the end line, swap the two
lines. If the start line is equal to the end line, remove the
end line.

Test: fast/css-grid-layout/swap-lines-if-start-is-further-endward-than-end-line.html

* rendering/style/GridResolvedPosition.cpp:
(WebCore::resolveNamedGridLinePositionFromStyle):
(WebCore::resolveGridPositionFromStyle):
(WebCore::GridResolvedPosition::GridResolvedPosition):
(WebCore::GridResolvedPosition::resolveGridPositionsFromStyle):
(WebCore::adjustGridPositionForSide): Deleted.
* rendering/style/GridResolvedPosition.h:
(WebCore::GridResolvedPosition::prev):

LayoutTests:

Updated the expectations for
named-grid-lines-with-named-grid-areas-dynamic-get-set.html
because two of the tests where positioning an item with a
start-line &gt; end-line (it was removing the end line instead of
swapping them).

* fast/css-grid-layout/named-grid-lines-with-named-grid-areas-dynamic-get-set.html:
* fast/css-grid-layout/swap-lines-if-start-is-further-endward-than-end-line-expected.html: Added.
* fast/css-grid-layout/swap-lines-if-start-is-further-endward-than-end-line.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastcssgridlayoutnamedgridlineswithnamedgridareasdynamicgetsethtml">trunk/LayoutTests/fast/css-grid-layout/named-grid-lines-with-named-grid-areas-dynamic-get-set.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleGridResolvedPositioncpp">trunk/Source/WebCore/rendering/style/GridResolvedPosition.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleGridResolvedPositionh">trunk/Source/WebCore/rendering/style/GridResolvedPosition.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcssgridlayoutswaplinesifstartisfurtherendwardthanendlineexpectedhtml">trunk/LayoutTests/fast/css-grid-layout/swap-lines-if-start-is-further-endward-than-end-line-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastcssgridlayoutswaplinesifstartisfurtherendwardthanendlinehtml">trunk/LayoutTests/fast/css-grid-layout/swap-lines-if-start-is-further-endward-than-end-line.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (192152 => 192153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-11-09 12:13:06 UTC (rev 192152)
+++ trunk/LayoutTests/ChangeLog        2015-11-09 12:24:38 UTC (rev 192153)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2015-11-05  Sergio Villar Senin  &lt;svillar@igalia.com&gt;
+
+        [css-grid] Grid placement conflict handling
+        https://bugs.webkit.org/show_bug.cgi?id=150891
+
+        Reviewed by Darin Adler.
+
+        Updated the expectations for
+        named-grid-lines-with-named-grid-areas-dynamic-get-set.html
+        because two of the tests where positioning an item with a
+        start-line &gt; end-line (it was removing the end line instead of
+        swapping them).
+
+        * fast/css-grid-layout/named-grid-lines-with-named-grid-areas-dynamic-get-set.html:
+        * fast/css-grid-layout/swap-lines-if-start-is-further-endward-than-end-line-expected.html: Added.
+        * fast/css-grid-layout/swap-lines-if-start-is-further-endward-than-end-line.html: Added.
+
</ins><span class="cx"> 2015-11-09  Xabier Rodriguez Calvar  &lt;calvaris@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed.
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssgridlayoutnamedgridlineswithnamedgridareasdynamicgetsethtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/css-grid-layout/named-grid-lines-with-named-grid-areas-dynamic-get-set.html (192152 => 192153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css-grid-layout/named-grid-lines-with-named-grid-areas-dynamic-get-set.html        2015-11-09 12:13:06 UTC (rev 192152)
+++ trunk/LayoutTests/fast/css-grid-layout/named-grid-lines-with-named-grid-areas-dynamic-get-set.html        2015-11-09 12:24:38 UTC (rev 192153)
</span><span class="lines">@@ -130,8 +130,8 @@
</span><span class="cx">     testLayout({ 'areas': templateAreaOne, 'columns': columnRepeatedNames, 'rows': rowRepeatedNames }, itemsRepeat);
</span><span class="cx">     testLayout({ 'columns': columnRepeatedNames, 'areas': templateAreaOne, 'rows': rowRepeatedNames }, itemsRepeat);
</span><span class="cx"> 
</span><del>-    var itemsRepeatTwo = [ { 'column': 'd', 'row': 'c', 'x': '0', 'y': '150', 'width': '350', 'height': '200' },
-                           { 'column': 'd-start / d-end', 'row': 'c-start / c-end', 'x': '0', 'y': '150', 'width': '350', 'height': '200'},
</del><ins>+    var itemsRepeatTwo = [ { 'column': 'd', 'row': 'c', 'x': '0', 'y': '50', 'width': '350', 'height': '100' },
+                           { 'column': 'd-start / d-end', 'row': 'c-start / c-end', 'x': '0', 'y': '50', 'width': '350', 'height': '100'},
</ins><span class="cx">                            { 'column': 'c', 'row': 'd', 'x': '150', 'y': '0', 'width': '200', 'height': '150' } ];
</span><span class="cx"> 
</span><span class="cx">     testLayout({ 'areas': templateAreaTwo, 'areas': templateAreaOne, 'columns': columnRepeatedNames, 'rows': rowRepeatedNames }, itemsRepeat);
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssgridlayoutswaplinesifstartisfurtherendwardthanendlineexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css-grid-layout/swap-lines-if-start-is-further-endward-than-end-line-expected.html (0 => 192153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css-grid-layout/swap-lines-if-start-is-further-endward-than-end-line-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/swap-lines-if-start-is-further-endward-than-end-line-expected.html        2015-11-09 12:24:38 UTC (rev 192153)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;style&gt;
+.grid {
+    -webkit-grid-template-columns: [a] 50px [b] 50px [c] 50px [d];
+    -webkit-grid-auto-rows: 20px;
+    -webkit-grid-auto-columns: 20px;
+}
+&lt;/style&gt;
+
+&lt;div class=&quot;grid&quot;&gt;
+
+    &lt;div style=&quot;-webkit-grid-column: 1 / 3; background-color: gray&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;-webkit-grid-column: 1 / -2; background-color: purple&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;-webkit-grid-column: -2 / 4; background-color: orange&quot;&gt;&lt;/div&gt;
+
+    &lt;div style=&quot;-webkit-grid-column: 2 / d; background-color: gray&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;-webkit-grid-column: b / -1; background-color: purple&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;-webkit-grid-column: c / d; background-color: orange&quot;&gt;&lt;/div&gt;
+
+    &lt;div style=&quot;-webkit-grid-column: a -1 / 3; background-color: gray&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;-webkit-grid-column: b 1 / -1; background-color: purple&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;-webkit-grid-column: c -1 / d; background-color: orange&quot;&gt;&lt;/div&gt;
+
+    &lt;div style=&quot;-webkit-grid-column: 2 / 3; background-color: blue&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;-webkit-grid-column: 1 / 3; background-color: lightblue&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;-webkit-grid-column: 2 / 4; background-color: maroon&quot;&gt;&lt;/div&gt;
+
+    &lt;div style=&quot;-webkit-grid-column: -3 / -3; background-color: lightgreen&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;-webkit-grid-column: 3 / 3; background-color: green&quot;&gt;&lt;/div&gt;
+
+&lt;/div&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/css-grid-layout/swap-lines-if-start-is-further-endward-than-end-line-expected.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkLayoutTestsfastcssgridlayoutswaplinesifstartisfurtherendwardthanendlinehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css-grid-layout/swap-lines-if-start-is-further-endward-than-end-line.html (0 => 192153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css-grid-layout/swap-lines-if-start-is-further-endward-than-end-line.html                                (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/swap-lines-if-start-is-further-endward-than-end-line.html        2015-11-09 12:24:38 UTC (rev 192153)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;style&gt;
+.grid {
+    -webkit-grid-template-columns: [a] 50px [b] 50px [c] 50px [d];
+    -webkit-grid-auto-rows: 20px;
+    -webkit-grid-auto-columns: 20px;
+}
+&lt;/style&gt;
+
+&lt;div class=&quot;grid&quot;&gt;
+
+    &lt;div style=&quot;-webkit-grid-column: 3 / 1; background-color: gray&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;-webkit-grid-column: -2 / 1; background-color: purple&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;-webkit-grid-column: 4 / -2; background-color: orange&quot;&gt;&lt;/div&gt;
+
+    &lt;div style=&quot;-webkit-grid-column: d / 2; background-color: gray&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;-webkit-grid-column: -1 / b; background-color: purple&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;-webkit-grid-column: d / c; background-color: orange&quot;&gt;&lt;/div&gt;
+
+    &lt;div style=&quot;-webkit-grid-column: 3 / a -1; background-color: gray&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;-webkit-grid-column: -1 / b 1; background-color: purple&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;-webkit-grid-column: d / c -1; background-color: orange&quot;&gt;&lt;/div&gt;
+
+    &lt;!-- Check that we do not break already valid use cases. --&gt;
+    &lt;div style=&quot;-webkit-grid-column: -3 / -2; background-color: blue&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;-webkit-grid-column: -4 / -2; background-color: lightblue&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;-webkit-grid-column: -3 / -1; background-color: maroon&quot;&gt;&lt;/div&gt;
+
+    &lt;div style=&quot;-webkit-grid-column: 2 / 2; background-color: lightgreen&quot;&gt;&lt;/div&gt;
+    &lt;div style=&quot;-webkit-grid-column: c / c; background-color: green&quot;&gt;&lt;/div&gt;
+
+&lt;/div&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/css-grid-layout/swap-lines-if-start-is-further-endward-than-end-line.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (192152 => 192153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-11-09 12:13:06 UTC (rev 192152)
+++ trunk/Source/WebCore/ChangeLog        2015-11-09 12:24:38 UTC (rev 192153)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2015-11-05  Sergio Villar Senin  &lt;svillar@igalia.com&gt;
+
+        [css-grid] Grid placement conflict handling
+        https://bugs.webkit.org/show_bug.cgi?id=150891
+
+        Reviewed by Darin Adler.
+
+        If the placement for a grid item contains two lines, and the
+        start line is further end-ward than the end line, swap the two
+        lines. If the start line is equal to the end line, remove the
+        end line.
+
+        Test: fast/css-grid-layout/swap-lines-if-start-is-further-endward-than-end-line.html
+
+        * rendering/style/GridResolvedPosition.cpp:
+        (WebCore::resolveNamedGridLinePositionFromStyle):
+        (WebCore::resolveGridPositionFromStyle):
+        (WebCore::GridResolvedPosition::GridResolvedPosition):
+        (WebCore::GridResolvedPosition::resolveGridPositionsFromStyle):
+        (WebCore::adjustGridPositionForSide): Deleted.
+        * rendering/style/GridResolvedPosition.h:
+        (WebCore::GridResolvedPosition::prev):
+
</ins><span class="cx"> 2015-11-08  Gyuyoung Kim  &lt;gyuyoung.kim@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [EFL] Add UserAgentEFl.cpp|h
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleGridResolvedPositioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/GridResolvedPosition.cpp (192152 => 192153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/GridResolvedPosition.cpp        2015-11-09 12:13:06 UTC (rev 192152)
+++ trunk/Source/WebCore/rendering/style/GridResolvedPosition.cpp        2015-11-09 12:24:38 UTC (rev 192153)
</span><span class="lines">@@ -114,15 +114,6 @@
</span><span class="cx">     return resolvedPosition ? GridResolvedPosition(resolvedPosition - 1) : GridResolvedPosition(0);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static GridResolvedPosition adjustGridPositionForSide(unsigned resolvedPosition, GridPositionSide side)
-{
-    // An item finishing on the N-th line belongs to the N-1-th cell.
-    if (side == ColumnEndSide || side == RowEndSide)
-        return adjustGridPositionForRowEndColumnEndSide(resolvedPosition);
-
-    return GridResolvedPosition(resolvedPosition);
-}
-
</del><span class="cx"> static GridResolvedPosition resolveNamedGridLinePositionFromStyle(const RenderStyle&amp; gridContainerStyle, const GridPosition&amp; position, GridPositionSide side)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!position.namedGridLine().isNull());
</span><span class="lines">@@ -133,7 +124,7 @@
</span><span class="cx">         if (position.isPositive())
</span><span class="cx">             return 0;
</span><span class="cx">         const unsigned lastLine = explicitGridSizeForSide(gridContainerStyle, side);
</span><del>-        return adjustGridPositionForSide(lastLine, side);
</del><ins>+        return lastLine;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     unsigned namedGridLineIndex;
</span><span class="lines">@@ -141,7 +132,7 @@
</span><span class="cx">         namedGridLineIndex = std::min&lt;unsigned&gt;(position.integerPosition(), it-&gt;value.size()) - 1;
</span><span class="cx">     else
</span><span class="cx">         namedGridLineIndex = std::max&lt;int&gt;(0, it-&gt;value.size() - abs(position.integerPosition()));
</span><del>-    return adjustGridPositionForSide(it-&gt;value[namedGridLineIndex], side);
</del><ins>+    return it-&gt;value[namedGridLineIndex];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static inline unsigned firstNamedGridLineBeforePosition(unsigned position, const Vector&lt;unsigned&gt;&amp; gridLines)
</span><span class="lines">@@ -255,7 +246,7 @@
</span><span class="cx"> 
</span><span class="cx">         // Handle &lt;integer&gt; explicit position.
</span><span class="cx">         if (position.isPositive())
</span><del>-            return adjustGridPositionForSide(position.integerPosition() - 1, side);
</del><ins>+            return position.integerPosition() - 1;
</ins><span class="cx"> 
</span><span class="cx">         unsigned resolvedPosition = abs(position.integerPosition()) - 1;
</span><span class="cx">         const unsigned endOfTrack = explicitGridSizeForSide(gridContainerStyle, side);
</span><span class="lines">@@ -264,7 +255,7 @@
</span><span class="cx">         if (endOfTrack &lt; resolvedPosition)
</span><span class="cx">             return 0;
</span><span class="cx"> 
</span><del>-        return adjustGridPositionForSide(endOfTrack - resolvedPosition, side);
</del><ins>+        return endOfTrack - resolvedPosition;
</ins><span class="cx">     }
</span><span class="cx">     case NamedGridAreaPosition:
</span><span class="cx">     {
</span><span class="lines">@@ -277,13 +268,13 @@
</span><span class="cx">         const NamedGridLinesMap&amp; gridLineNames = gridLinesForSide(gridContainerStyle, side);
</span><span class="cx">         auto implicitLine = gridLineNames.find(implicitNamedGridLineForSide(namedGridLine, side));
</span><span class="cx">         if (implicitLine != gridLineNames.end())
</span><del>-            return adjustGridPositionForSide(implicitLine-&gt;value[0], side);
</del><ins>+            return implicitLine-&gt;value[0];
</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><span class="cx">         auto explicitLine = gridLineNames.find(namedGridLine);
</span><span class="cx">         if (explicitLine != gridLineNames.end())
</span><del>-            return adjustGridPositionForSide(explicitLine-&gt;value[0], side);
</del><ins>+            return explicitLine-&gt;value[0];
</ins><span class="cx"> 
</span><span class="cx">         // If none of the above works specs mandate us to treat it as auto BUT we should have detected it before calling
</span><span class="cx">         // this function in resolveGridPositionsFromStyle(). We should be covered anyway by the ASSERT at the beginning
</span><span class="lines">@@ -306,7 +297,10 @@
</span><span class="cx">     ASSERT(position.integerPosition());
</span><span class="cx">     unsigned integerPosition = position.integerPosition() - 1;
</span><span class="cx"> 
</span><del>-    m_integerPosition = adjustGridPositionForSide(integerPosition, side).m_integerPosition;
</del><ins>+    if (isStartSide(side) &amp;&amp; integerPosition)
+        --integerPosition;
+
+    m_integerPosition = integerPosition;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GridUnresolvedSpan GridResolvedPosition::unresolvedSpanFromStyle(const RenderStyle&amp; gridContainerStyle, const RenderBox&amp; gridItem, GridTrackSizingDirection direction)
</span><span class="lines">@@ -326,10 +320,13 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!unresolvedSpan.requiresAutoPlacement());
</span><span class="cx"> 
</span><ins>+    // We must create the GridSpan using finalPosition.prev() because GridSpan stores cell indexes and
+    // an item finishing on the N-th line belongs to the N-1-th cell.
+
</ins><span class="cx">     if (unresolvedSpan.initialPosition().shouldBeResolvedAgainstOppositePosition()) {
</span><span class="cx">         // Infer the position from the final position ('auto / 1' or 'span 2 / 3' case).
</span><span class="cx">         auto finalResolvedPosition = resolveGridPositionFromStyle(gridContainerStyle, unresolvedSpan.finalPosition(), unresolvedSpan.finalPositionSide());
</span><del>-        return resolveGridPositionAgainstOppositePosition(gridContainerStyle, finalResolvedPosition, unresolvedSpan.initialPosition(), unresolvedSpan.initialPositionSide());
</del><ins>+        return resolveGridPositionAgainstOppositePosition(gridContainerStyle, finalResolvedPosition.prev(), unresolvedSpan.initialPosition(), unresolvedSpan.initialPositionSide());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (unresolvedSpan.finalPosition().shouldBeResolvedAgainstOppositePosition()) {
</span><span class="lines">@@ -341,8 +338,10 @@
</span><span class="cx">     GridResolvedPosition resolvedInitialPosition = resolveGridPositionFromStyle(gridContainerStyle, unresolvedSpan.initialPosition(), unresolvedSpan.initialPositionSide());
</span><span class="cx">     GridResolvedPosition resolvedFinalPosition = resolveGridPositionFromStyle(gridContainerStyle, unresolvedSpan.finalPosition(), unresolvedSpan.finalPositionSide());
</span><span class="cx"> 
</span><del>-    // If 'grid-row-end' specifies a line at or before that specified by 'grid-row-start', it computes to 'span 1'.
-    return GridSpan(resolvedInitialPosition, std::max&lt;GridResolvedPosition&gt;(resolvedInitialPosition, resolvedFinalPosition));
</del><ins>+    if (resolvedInitialPosition &gt; resolvedFinalPosition)
+        std::swap(resolvedInitialPosition, resolvedFinalPosition);
+
+    return GridSpan(resolvedInitialPosition, std::max(resolvedInitialPosition, resolvedFinalPosition.prev()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleGridResolvedPositionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/GridResolvedPosition.h (192152 => 192153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/GridResolvedPosition.h        2015-11-09 12:13:06 UTC (rev 192152)
+++ trunk/Source/WebCore/rendering/style/GridResolvedPosition.h        2015-11-09 12:24:38 UTC (rev 192153)
</span><span class="lines">@@ -133,6 +133,11 @@
</span><span class="cx">         return GridResolvedPosition(m_integerPosition + 1);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    GridResolvedPosition prev() const
+    {
+        return m_integerPosition ? m_integerPosition - 1 : 0;
+    }
+
</ins><span class="cx">     static GridSpan resolveGridPositionsFromAutoPlacementPosition(const RenderStyle&amp;, const RenderBox&amp;, GridTrackSizingDirection, const GridResolvedPosition&amp;);
</span><span class="cx">     static GridSpan resolveGridPositionsFromStyle(const GridUnresolvedSpan&amp;, const RenderStyle&amp;);
</span><span class="cx">     static GridUnresolvedSpan unresolvedSpanFromStyle(const RenderStyle&amp;, const RenderBox&amp;, GridTrackSizingDirection);
</span></span></pre>
</div>
</div>

</body>
</html>