No subject


Mon Jan 28 08:41:14 PST 2013


8833">r148833</a>, <a href=3D"http://trac.webkit.org/projects/webkit/chan=
geset/148878">r148878</a>, <a href=3D"http://trac.webkit.org/projects/web=
kit/changeset/150403">r150403</a> by &lt;jchaffraix at chromium.org&gt;

Source/WebCore:

Both grid-{column|row}-end and negative positions were not
properly handled in our grid position resolution code. We were
using the same code to resolve all the grid positions without
considering the edges of the grid.

Also refactored the grid size estimation in
resolveGridPositionsFromStyle() so we can use it for the grid size
estimation. The code no longer requires the grid to be filled at
that moment as the specs changed to use the &quot;explicit grid&quot; whi=
ch
is independent of grid items (only depends on style).

Test: fast/css-grid-layout/grid-item-negative-position-resolution.html

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::maximumIndexInDirection):
(WebCore::RenderGrid::resolveGridPositionsFromStyle):
(WebCore::adjustGridPositionForSide):
(WebCore::RenderGrid::resolveGridPositionFromStyle):
* rendering/RenderGrid.h:

LayoutTests:

Added a new test to check negative position resolution. Also added
several new test cases to check that we properly resolve grid
positions in the grid edges.

* fast/css-grid-layout/grid-item-negative-position-resolution-expected.tx=
t: Added.
* fast/css-grid-layout/grid-item-negative-position-resolution.html: Added=
.
* fast/css-grid-layout/grid-item-spanning-resolution-expected.txt:
* fast/css-grid-layout/grid-item-spanning-resolution.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href=3D"#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a=
></li>
<li><a href=3D"#trunkLayoutTestsfastcssgridlayoutgriditemspanningresoluti=
onexpectedtxt">trunk/LayoutTests/fast/css-grid-layout/grid-item-spanning-=
resolution-expected.txt</a></li>
<li><a href=3D"#trunkLayoutTestsfastcssgridlayoutgriditemspanningresoluti=
onhtml">trunk/LayoutTests/fast/css-grid-layout/grid-item-spanning-resolut=
ion.html</a></li>
<li><a href=3D"#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeL=
og</a></li>
<li><a href=3D"#trunkSourceWebCorerenderingRenderGridcpp">trunk/Source/We=
bCore/rendering/RenderGrid.cpp</a></li>
<li><a href=3D"#trunkSourceWebCorerenderingRenderGridh">trunk/Source/WebC=
ore/rendering/RenderGrid.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href=3D"#trunkLayoutTestsfastcssgridlayoutgriditemnegativeposition=
resolutionexpectedtxt">trunk/LayoutTests/fast/css-grid-layout/grid-item-n=
egative-position-resolution-expected.txt</a></li>
<li><a href=3D"#trunkLayoutTestsfastcssgridlayoutgriditemnegativeposition=
resolutionhtml">trunk/LayoutTests/fast/css-grid-layout/grid-item-negative=
-position-resolution.html</a></li>
</ul>

</div>
<div id=3D"patch">
<h3>Diff</h3>
<a id=3D"trunkLayoutTestsChangeLog"></a>
<div class=3D"modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (154730 =
=3D> 154731)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/LayoutTests/ChangeLog	2013-08-28 09:58:33 =
UTC (rev 154730)
+++ trunk/LayoutTests/ChangeLog	2013-08-28 10:26:10 UTC (rev 154731)
</span><span class=3D"lines">@@ -1,5 +1,23 @@
</span><span class=3D"cx"> 2013-08-28  Sergio Villar Senin  &lt;svillar at i=
galia.com&gt;
</span><span class=3D"cx">=20
</span><ins>+        [CSS Grid Layout] Fix grid position resolution
+        https://bugs.webkit.org/show_bug.cgi?id=3D119801
+
+        Reviewed by Andreas Kling.
+
+        From Blink r148833, r148878, r150403 by &lt;jchaffraix at chromium.=
org&gt;
+
+        Added a new test to check negative position resolution. Also add=
ed
+        several new test cases to check that we properly resolve grid
+        positions in the grid edges.
+
+        * fast/css-grid-layout/grid-item-negative-position-resolution-ex=
pected.txt: Added.
+        * fast/css-grid-layout/grid-item-negative-position-resolution.ht=
ml: Added.
+        * fast/css-grid-layout/grid-item-spanning-resolution-expected.tx=
t:
+        * fast/css-grid-layout/grid-item-spanning-resolution.html:
+
+2013-08-28  Sergio Villar Senin  &lt;svillar at igalia.com&gt;
+
</ins><span class=3D"cx">         [CSS Grid Layout] infinity should be de=
fined as a negative value
</span><span class=3D"cx">         https://bugs.webkit.org/show_bug.cgi?i=
d=3D107053
</span><span class=3D"cx">=20
</span></span></pre></div>
<a id=3D"trunkLayoutTestsfastcssgridlayoutgriditemnegativepositionresolut=
ionexpectedtxt"></a>
<div class=3D"addfile"><h4>Added: trunk/LayoutTests/fast/css-grid-layout/=
grid-item-negative-position-resolution-expected.txt (0 =3D> 154731)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/LayoutTests/fast/css-grid-layout/grid-item=
-negative-position-resolution-expected.txt	                        (rev 0=
)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-item-negative-position-re=
solution-expected.txt	2013-08-28 10:26:10 UTC (rev 154731)
</span><span class=3D"lines">@@ -0,0 +1,6 @@
</span><ins>+Test that negative grid positions are correctly resolved.
+
+PASS
+PASS
+PASS
+PASS
</ins><span class=3D"cx">Property changes on: trunk/LayoutTests/fast/css-=
grid-layout/grid-item-negative-position-resolution-expected.txt
</span><span class=3D"cx">_______________________________________________=
____________________
</span></span></pre></div>
<a id=3D"svneolstyle"></a>
<div class=3D"addfile"><h4>Added: svn:eol-style</h4></div>
<a id=3D"trunkLayoutTestsfastcssgridlayoutgriditemnegativepositionresolut=
ionhtml"></a>
<div class=3D"addfile"><h4>Added: trunk/LayoutTests/fast/css-grid-layout/=
grid-item-negative-position-resolution.html (0 =3D> 154731)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/LayoutTests/fast/css-grid-layout/grid-item=
-negative-position-resolution.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-item-negative-position-re=
solution.html	2013-08-28 10:26:10 UTC (rev 154731)
</span><span class=3D"lines">@@ -0,0 +1,71 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.overridePreference(&quot;WebKitCSSGridLayoutEnabled&quot;=
, 1);
+&lt;/script&gt;
+&lt;link href=3D&quot;resources/grid.css&quot; rel=3D&quot;stylesheet&qu=
ot;&gt;
+&lt;style&gt;
+.grid {
+    -webkit-grid-definition-columns: 50px 100px;
+    -webkit-grid-definition-rows: 50px 100px;
+    /* To detect how much we extend the grid. */
+    -webkit-grid-auto-columns: 200px;
+    -webkit-grid-auto-rows: 200px;
+
+    /* Make the grid shrink-to-fit. */
+    position: absolute;
+}
+
+.negativeStartPositionGrowGridInColumnDirection {
+    -webkit-grid-column: -1 / auto;
+    -webkit-grid-row: 1;
+}
+
+.negativeStartPositionGrowGridInRowDirection {
+    -webkit-grid-column: 1;
+    -webkit-grid-row: -1 / auto;
+}
+
+.negativeEndPositionStartNegativeInColumnDirection {
+    -webkit-grid-column: -3 / -1;
+    -webkit-grid-row: 1;
+}
+
+.negativeEndPositionStartNegativeInRowDirection {
+    -webkit-grid-column: -5 / -2;
+    -webkit-grid-row: 1;
+}
+&lt;/style&gt;
+&lt;script src=3D&quot;../../resources/check-layout.js&quot;&gt;&lt;/scr=
ipt&gt;
+&lt;body onload=3D&quot;checkLayout('.grid');&quot;&gt;
+
+&lt;p&gt;Test that negative grid positions are correctly resolved.&lt;/p=
&gt;
+
+&lt;div style=3D&quot;position: relative&quot;&gt;
+&lt;div class=3D&quot;grid&quot; data-expected-width=3D&quot;350&quot; d=
ata-expected-height=3D&quot;150&quot;&gt;
+    &lt;div class=3D&quot;sizedToGridArea negativeStartPositionGrowGridI=
nColumnDirection&quot; data-offset-x=3D&quot;150&quot; data-offset-y=3D&q=
uot;0&quot; data-expected-width=3D&quot;200&quot; data-expected-height=3D=
&quot;50&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div style=3D&quot;position: relative&quot;&gt;
+&lt;div class=3D&quot;grid&quot; data-expected-width=3D&quot;150&quot; d=
ata-expected-height=3D&quot;350&quot;&gt;
+    &lt;div class=3D&quot;sizedToGridArea negativeStartPositionGrowGridI=
nRowDirection&quot; data-offset-x=3D&quot;0&quot; data-offset-y=3D&quot;1=
50&quot; data-expected-width=3D&quot;50&quot; data-expected-height=3D&quo=
t;200&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div style=3D&quot;position: relative&quot;&gt;
+&lt;div class=3D&quot;grid&quot; data-expected-width=3D&quot;150&quot; d=
ata-expected-height=3D&quot;150&quot;&gt;
+    &lt;div class=3D&quot;sizedToGridArea negativeEndPositionStartNegati=
veInColumnDirection&quot; data-offset-x=3D&quot;0&quot; data-offset-y=3D&=
quot;0&quot; data-expected-width=3D&quot;150&quot; data-expected-height=3D=
&quot;50&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div style=3D&quot;position: relative&quot;&gt;
+&lt;div class=3D&quot;grid&quot; data-expected-width=3D&quot;150&quot; d=
ata-expected-height=3D&quot;150&quot;&gt;
+    &lt;div class=3D&quot;sizedToGridArea negativeEndPositionStartNegati=
veInRowDirection&quot; data-offset-x=3D&quot;0&quot; data-offset-y=3D&quo=
t;0&quot; data-expected-width=3D&quot;50&quot; data-expected-height=3D&qu=
ot;50&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/div&gt;
+
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class=3D"cx">Property changes on: trunk/LayoutTests/fast/css-=
grid-layout/grid-item-negative-position-resolution.html
</span><span class=3D"cx">_______________________________________________=
____________________
</span></span></pre></div>
<a id=3D"svnmimetype"></a>
<div class=3D"addfile"><h4>Added: svn:mime-type</h4></div>
<a id=3D"svneolstyle"></a>
<div class=3D"addfile"><h4>Added: svn:eol-style</h4></div>
<a id=3D"trunkLayoutTestsfastcssgridlayoutgriditemspanningresolutionexpec=
tedtxt"></a>
<div class=3D"modfile"><h4>Modified: trunk/LayoutTests/fast/css-grid-layo=
ut/grid-item-spanning-resolution-expected.txt (154730 =3D> 154731)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/LayoutTests/fast/css-grid-layout/grid-item=
-spanning-resolution-expected.txt	2013-08-28 09:58:33 UTC (rev 154730)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-item-spanning-resolution-=
expected.txt	2013-08-28 10:26:10 UTC (rev 154731)
</span><span class=3D"lines">@@ -11,3 +11,4 @@
</span><span class=3D"cx"> PASS
</span><span class=3D"cx"> PASS
</span><span class=3D"cx"> PASS
</span><ins>+PASS
</ins></span></pre></div>
<a id=3D"trunkLayoutTestsfastcssgridlayoutgriditemspanningresolutionhtml"=
></a>
<div class=3D"modfile"><h4>Modified: trunk/LayoutTests/fast/css-grid-layo=
ut/grid-item-spanning-resolution.html (154730 =3D> 154731)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/LayoutTests/fast/css-grid-layout/grid-item=
-spanning-resolution.html	2013-08-28 09:58:33 UTC (rev 154730)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-item-spanning-resolution.=
html	2013-08-28 10:26:10 UTC (rev 154731)
</span><span class=3D"lines">@@ -13,6 +13,13 @@
</span><span class=3D"cx">     height: 300px;
</span><span class=3D"cx"> }
</span><span class=3D"cx">=20
</span><ins>+#bigGrid {
+    -webkit-grid-definition-columns: 25% 25% 25% 25%;
+    -webkit-grid-definition-rows: 25% 25% 25% 25%;
+    height: 100px;
+    width: 200px;
+}
+
</ins><span class=3D"cx"> .negativeOverflowRowFirstColumn {
</span><span class=3D"cx">     -webkit-grid-row: 1 / -5;
</span><span class=3D"cx">     -webkit-grid-column: 1;
</span><span class=3D"lines">@@ -32,6 +39,16 @@
</span><span class=3D"cx">     -webkit-grid-row: 1;
</span><span class=3D"cx">     -webkit-grid-column: 1 / 5;
</span><span class=3D"cx"> }
</span><ins>+
+.secondRowSecondColumnNoSpan {
+    -webkit-grid-column: 2 / 3;
+    -webkit-grid-row: 2 / 3;
+}
+
+.thirdRowThirdColumnNoSpan {
+    -webkit-grid-column: 3 / 4;
+    -webkit-grid-row: 3 / 4;
+}
</ins><span class=3D"cx"> &lt;/style&gt;
</span><span class=3D"cx"> &lt;script src=3D&quot;../../resources/check-l=
ayout.js&quot;&gt;&lt;/script&gt;
</span><span class=3D"cx"> &lt;body onload=3D&quot;checkLayout('.grid');&=
quot;&gt;
</span><span class=3D"lines">@@ -100,9 +117,14 @@
</span><span class=3D"cx">=20
</span><span class=3D"cx"> &lt;div style=3D&quot;position: relative&quot;=
&gt;
</span><span class=3D"cx"> &lt;div class=3D&quot;grid&quot; data-expected=
-width=3D&quot;400&quot; data-expected-height=3D&quot;300&quot;&gt;
</span><del>-    &lt;div class=3D&quot;sizedToGridArea autoSecondRowAutoF=
irstColumn&quot; data-offset-x=3D&quot;0&quot; data-offset-y=3D&quot;90&q=
uot; data-expected-width=3D&quot;160&quot; data-expected-height=3D&quot;2=
10&quot;&gt;&lt;/div&gt;
</del><ins>+    &lt;div class=3D&quot;sizedToGridArea autoSecondRowAutoFi=
rstColumn&quot; data-offset-x=3D&quot;0&quot; data-offset-y=3D&quot;0&quo=
t; data-expected-width=3D&quot;160&quot; data-expected-height=3D&quot;90&=
quot;&gt;&lt;/div&gt;
</ins><span class=3D"cx"> &lt;/div&gt;
</span><span class=3D"cx"> &lt;/div&gt;
</span><span class=3D"cx">=20
</span><ins>+&lt;div style=3D&quot;position: relative&quot;&gt;
+&lt;div class=3D&quot;grid&quot; id=3D&quot;bigGrid&quot; data-expected-=
width=3D&quot;200&quot; data-expected-height=3D&quot;100&quot;&gt;
+    &lt;div class=3D&quot;sizedToGridArea secondRowSecondColumnNoSpan&qu=
ot; data-offset-x=3D&quot;50&quot; data-offset-y=3D&quot;25&quot; data-ex=
pected-width=3D&quot;50&quot; data-expected-height=3D&quot;25&quot;&gt;&l=
t;/div&gt;
+    &lt;div class=3D&quot;sizedToGridArea thirdRowThirdColumnNoSpan&quot=
; data-offset-x=3D&quot;100&quot; data-offset-y=3D&quot;50&quot; data-exp=
ected-width=3D&quot;50&quot; data-expected-height=3D&quot;25&quot;&gt;&lt=
;/div&gt;
+&lt;/div&gt;
</ins><span class=3D"cx"> &lt;/body&gt;
</span><span class=3D"cx"> &lt;/html&gt;
</span></span></pre></div>
<a id=3D"trunkSourceWebCoreChangeLog"></a>
<div class=3D"modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (1547=
30 =3D> 154731)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/Source/WebCore/ChangeLog	2013-08-28 09:58:=
33 UTC (rev 154730)
+++ trunk/Source/WebCore/ChangeLog	2013-08-28 10:26:10 UTC (rev 154731)
</span><span class=3D"lines">@@ -1,5 +1,34 @@
</span><span class=3D"cx"> 2013-08-28  Sergio Villar Senin  &lt;svillar at i=
galia.com&gt;
</span><span class=3D"cx">=20
</span><ins>+        [CSS Grid Layout] Fix grid position resolution
+        https://bugs.webkit.org/show_bug.cgi?id=3D119801
+
+        Reviewed by Andreas Kling.
+
+        From Blink r148833, r148878, r150403 by &lt;jchaffraix at chromium.=
org&gt;
+
+        Both grid-{column|row}-end and negative positions were not
+        properly handled in our grid position resolution code. We were
+        using the same code to resolve all the grid positions without
+        considering the edges of the grid.
+
+        Also refactored the grid size estimation in
+        resolveGridPositionsFromStyle() so we can use it for the grid si=
ze
+        estimation. The code no longer requires the grid to be filled at
+        that moment as the specs changed to use the &quot;explicit grid&=
quot; which
+        is independent of grid items (only depends on style).
+
+        Test: fast/css-grid-layout/grid-item-negative-position-resolutio=
n.html
+
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::maximumIndexInDirection):
+        (WebCore::RenderGrid::resolveGridPositionsFromStyle):
+        (WebCore::adjustGridPositionForSide):
+        (WebCore::RenderGrid::resolveGridPositionFromStyle):
+        * rendering/RenderGrid.h:
+
+2013-08-28  Sergio Villar Senin  &lt;svillar at igalia.com&gt;
+
</ins><span class=3D"cx">         [CSS Grid Layout] infinity should be de=
fined as a negative value
</span><span class=3D"cx">         https://bugs.webkit.org/show_bug.cgi?i=
d=3D107053
</span><span class=3D"cx">=20
</span></span></pre></div>
<a id=3D"trunkSourceWebCorerenderingRenderGridcpp"></a>
<div class=3D"modfile"><h4>Modified: trunk/Source/WebCore/rendering/Rende=
rGrid.cpp (154730 =3D> 154731)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/Source/WebCore/rendering/RenderGrid.cpp	20=
13-08-28 09:58:33 UTC (rev 154730)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp	2013-08-28 10:26:10 UTC=
 (rev 154731)
</span><span class=3D"lines">@@ -327,16 +327,6 @@
</span><span class=3D"cx">     return trackStyles[i];
</span><span class=3D"cx"> }
</span><span class=3D"cx">=20
</span><del>-static size_t estimatedGridSizeForPosition(const GridPositio=
n&amp; position)
-{
-    if (position.isAuto())
-        return 1;
-
-    // Negative explicit values never grow the grid as they are clamped =
against
-    // the explicit grid's size. Thus we don't special case them here.
-    return std::max(position.integerPosition(), 1);
-}
-
</del><span class=3D"cx"> size_t RenderGrid::explicitGridColumnCount() co=
nst
</span><span class=3D"cx"> {
</span><span class=3D"cx">     return style()-&gt;gridColumns().size();
</span><span class=3D"lines">@@ -352,19 +342,14 @@
</span><span class=3D"cx">     size_t maximumIndex =3D std::max&lt;size_t=
&gt;(1, (direction =3D=3D ForColumns) ? explicitGridColumnCount() : expli=
citGridRowCount());
</span><span class=3D"cx">=20
</span><span class=3D"cx">     for (RenderBox* child =3D firstChildBox();=
 child; child =3D child-&gt;nextSiblingBox()) {
</span><del>-        // This function bypasses the cache (cachedGridCoord=
inate()) as it is used to build it.
-        // Also we can't call resolveGridPositionsFromStyle here as it a=
ssumes that the grid is build and we are in
-        // the middle of building it. However we should be able to share=
 more code with the previous logic (FIXME).
-        const GridPosition&amp; initialPosition =3D (direction =3D=3D Fo=
rColumns) ? child-&gt;style()-&gt;gridItemColumnStart() : child-&gt;style=
()-&gt;gridItemRowStart();
-        const GridPosition&amp; finalPosition =3D (direction =3D=3D ForC=
olumns) ? child-&gt;style()-&gt;gridItemColumnEnd() : child-&gt;style()-&=
gt;gridItemRowEnd();
</del><ins>+        OwnPtr&lt;GridSpan&gt; positions =3D resolveGridPosit=
ionsFromStyle(child, direction);
</ins><span class=3D"cx">=20
</span><del>-        size_t estimatedSizeForInitialPosition =3D estimated=
GridSizeForPosition(initialPosition);
-        size_t estimatedSizeForFinalPosition =3D estimatedGridSizeForPos=
ition(finalPosition);
-        ASSERT(estimatedSizeForInitialPosition);
-        ASSERT(estimatedSizeForFinalPosition);
</del><ins>+        // |positions| is null if we need to run the auto-pla=
cement algorithm. Our estimation ignores
+        // this case as the auto-placement algorithm will grow the grid =
as needed.
+        if (!positions)
+            continue;
</ins><span class=3D"cx">=20
</span><del>-        maximumIndex =3D std::max(maximumIndex, estimatedSiz=
eForInitialPosition);
-        maximumIndex =3D std::max(maximumIndex, estimatedSizeForFinalPos=
ition);
</del><ins>+        maximumIndex =3D std::max(maximumIndex, positions-&gt=
;finalPositionIndex + 1);
</ins><span class=3D"cx">     }
</span><span class=3D"cx">=20
</span><span class=3D"cx">     return maximumIndex;
</span><span class=3D"lines">@@ -730,8 +715,6 @@
</span><span class=3D"cx">=20
</span><span class=3D"cx"> PassOwnPtr&lt;RenderGrid::GridSpan&gt; RenderG=
rid::resolveGridPositionsFromStyle(const RenderBox* gridItem, TrackSizing=
Direction direction) const
</span><span class=3D"cx"> {
</span><del>-    ASSERT(gridWasPopulated());
-
</del><span class=3D"cx">     const GridPosition&amp; initialPosition =3D=
 (direction =3D=3D ForColumns) ? gridItem-&gt;style()-&gt;gridItemColumnS=
tart() : gridItem-&gt;style()-&gt;gridItemRowStart();
</span><span class=3D"cx">     const GridPositionSide initialPositionSide=
 =3D (direction =3D=3D ForColumns) ? ColumnStartSide : RowStartSide;
</span><span class=3D"cx">     const GridPosition&amp; finalPosition =3D =
(direction =3D=3D ForColumns) ? gridItem-&gt;style()-&gt;gridItemColumnEn=
d() : gridItem-&gt;style()-&gt;gridItemRowEnd();
</span><span class=3D"lines">@@ -767,26 +750,32 @@
</span><span class=3D"cx">     return adoptPtr(new GridSpan(resolvedIniti=
alPosition, resolvedFinalPosition));
</span><span class=3D"cx"> }
</span><span class=3D"cx">=20
</span><del>-size_t RenderGrid::resolveGridPositionFromStyle(const GridPo=
sition&amp; position, GridPositionSide side) const
</del><ins>+static size_t adjustGridPositionForSide(size_t resolvedPositi=
on, RenderGrid::GridPositionSide side)
</ins><span class=3D"cx"> {
</span><del>-    ASSERT(gridWasPopulated());
</del><ins>+    // An item finishing on the N-th line belongs to the N-1-=
th cell.
+    if (side =3D=3D RenderGrid::ColumnEndSide || side =3D=3D RenderGrid:=
:RowEndSide)
+        return resolvedPosition ? resolvedPosition - 1 : 0;
</ins><span class=3D"cx">=20
</span><ins>+    return resolvedPosition;
+}
+
+size_t RenderGrid::resolveGridPositionFromStyle(const GridPosition&amp; =
position, GridPositionSide side) const
+{
</ins><span class=3D"cx">     // FIXME: Handle other values for grid-{row=
,column} like ranges or line names.
</span><span class=3D"cx">     switch (position.type()) {
</span><span class=3D"cx">     case IntegerPosition: {
</span><ins>+        ASSERT(position.integerPosition());
</ins><span class=3D"cx">         if (position.isPositive())
</span><del>-            return position.integerPosition() - 1;
</del><ins>+            return adjustGridPositionForSide(position.integer=
Position() - 1, side);
</ins><span class=3D"cx">=20
</span><del>-        size_t resolvedPosition =3D abs(position.integerPosi=
tion());
-        // FIXME: This returns one less than the expected result for sid=
e =3D=3D ColumnStartSide or RowStartSide as we don't properly convert
-        // the grid line to its grid track. However this avoids the issu=
e of growing the grid when inserting the item (e.g. -1 / auto).
</del><ins>+        size_t resolvedPosition =3D abs(position.integerPosit=
ion()) - 1;
</ins><span class=3D"cx">         const size_t endOfTrack =3D (side =3D=3D=
 ColumnStartSide || side =3D=3D ColumnEndSide) ? explicitGridColumnCount(=
) : explicitGridRowCount();
</span><span class=3D"cx">=20
</span><span class=3D"cx">         // Per http://lists.w3.org/Archives/Pu=
blic/www-style/2013Mar/0589.html, we clamp negative value to the first li=
ne.
</span><span class=3D"cx">         if (endOfTrack &lt; resolvedPosition)
</span><span class=3D"cx">             return 0;
</span><span class=3D"cx">=20
</span><del>-        return endOfTrack - resolvedPosition;
</del><ins>+        return adjustGridPositionForSide(endOfTrack - resolve=
dPosition, side);
</ins><span class=3D"cx">     }
</span><span class=3D"cx">     case AutoPosition:
</span><span class=3D"cx">         // 'auto' depends on the opposite posi=
tion for resolution (e.g. grid-row: auto / 1).
</span></span></pre></div>
<a id=3D"trunkSourceWebCorerenderingRenderGridh"></a>
<div class=3D"modfile"><h4>Modified: trunk/Source/WebCore/rendering/Rende=
rGrid.h (154730 =3D> 154731)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/Source/WebCore/rendering/RenderGrid.h	2013=
-08-28 09:58:33 UTC (rev 154730)
+++ trunk/Source/WebCore/rendering/RenderGrid.h	2013-08-28 10:26:10 UTC (=
rev 154731)
</span><span class=3D"lines">@@ -44,6 +44,13 @@
</span><span class=3D"cx">     virtual bool avoidsFloats() const OVERRIDE=
 { return true; }
</span><span class=3D"cx">     virtual bool canCollapseAnonymousBlockChil=
d() const OVERRIDE { return false; }
</span><span class=3D"cx">=20
</span><ins>+    enum GridPositionSide {
+        ColumnStartSide,
+        ColumnEndSide,
+        RowStartSide,
+        RowEndSide
+    };
+
</ins><span class=3D"cx"> private:
</span><span class=3D"cx">     virtual bool isRenderGrid() const OVERRIDE=
 { return true; }
</span><span class=3D"cx">     virtual void computeIntrinsicLogicalWidths=
(LayoutUnit&amp; minLogicalWidth, LayoutUnit&amp; maxLogicalWidth) const =
OVERRIDE;
</span><span class=3D"lines">@@ -122,12 +129,6 @@
</span><span class=3D"cx">=20
</span><span class=3D"cx">     GridSpan resolveGridPositionsFromAutoPlace=
mentPosition(const RenderBox*, TrackSizingDirection, size_t) const;
</span><span class=3D"cx">     PassOwnPtr&lt;GridSpan&gt; resolveGridPosi=
tionsFromStyle(const RenderBox*, TrackSizingDirection) const;
</span><del>-    enum GridPositionSide {
-        ColumnStartSide,
-        ColumnEndSide,
-        RowStartSide,
-        RowEndSide
-    };
</del><span class=3D"cx">     size_t resolveGridPositionFromStyle(const G=
ridPosition&amp;, GridPositionSide) const;
</span><span class=3D"cx">=20
</span><span class=3D"cx">     LayoutUnit gridAreaBreadthForChild(const R=
enderBox* child, TrackSizingDirection, const Vector&lt;GridTrack&gt;&amp;=
) const;
</span></span></pre>
</div>
</div>

</body>
</html>


More information about the webkit-changes mailing list