Title: [145378] trunk
Revision
145378
Author
[email protected]
Date
2013-03-11 12:07:54 -0700 (Mon, 11 Mar 2013)

Log Message

[CSS Grid Layout] Handle spanning grid items over specified grid tracks
https://bugs.webkit.org/show_bug.cgi?id=111918

Reviewed by Tony Chang.

Source/WebCore:

This change updates the containing block override logic to handle multiple
spanned tracks. This makes the multiple specified grid tracks case work and
will enable us to handle the minmax case once the computation logic has been
updated.

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

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::logicalContentHeightForChild):
(WebCore::RenderGrid::layoutGridItems):
Updated these functions to use gridAreaBreadthForChild.

(WebCore::RenderGrid::gridAreaBreadthForChild):
Added this helper function to handle multiple spanned grid tracks.

* rendering/RenderGrid.h: Added the previous function.

LayoutTests:

* fast/css-grid-layout/grid-item-spanning-resolution-expected.txt:
We now pass all the tests.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (145377 => 145378)


--- trunk/LayoutTests/ChangeLog	2013-03-11 18:43:48 UTC (rev 145377)
+++ trunk/LayoutTests/ChangeLog	2013-03-11 19:07:54 UTC (rev 145378)
@@ -1,3 +1,13 @@
+2013-03-11  Julien Chaffraix  <[email protected]>
+
+        [CSS Grid Layout] Handle spanning grid items over specified grid tracks
+        https://bugs.webkit.org/show_bug.cgi?id=111918
+
+        Reviewed by Tony Chang.
+
+        * fast/css-grid-layout/grid-item-spanning-resolution-expected.txt:
+        We now pass all the tests.
+
 2013-03-11  Christian Biesinger  <[email protected]>
 
         (tests) make nodesFromRect.js print a list of nodes that were found

Modified: trunk/LayoutTests/fast/css-grid-layout/grid-item-spanning-resolution-expected.txt (145377 => 145378)


--- trunk/LayoutTests/fast/css-grid-layout/grid-item-spanning-resolution-expected.txt	2013-03-11 18:43:48 UTC (rev 145377)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-item-spanning-resolution-expected.txt	2013-03-11 19:07:54 UTC (rev 145378)
@@ -1,39 +1,13 @@
 Test that spannig rows / columns inside percentage sized grid areas get properly sized.
 
-FAIL:
-Expected 400 for width, but got 160. 
-
-<div class="grid" data-expected-width="400" data-expected-height="300">
-    <div class="sizedToGridArea firstRowBothColumn" data-offset-x="0" data-offset-y="0" data-expected-width="400" data-expected-height="90"></div>
-</div>
-FAIL:
-Expected 400 for width, but got 160. 
-
-<div class="grid" data-expected-width="400" data-expected-height="300">
-    <div class="sizedToGridArea secondRowBothColumn" data-offset-x="0" data-offset-y="90" data-expected-width="400" data-expected-height="210"></div>
-</div>
-FAIL:
-Expected 300 for height, but got 90. 
-
-<div class="grid" data-expected-width="400" data-expected-height="300">
-    <div class="sizedToGridArea bothRowFirstColumn" data-offset-x="0" data-offset-y="0" data-expected-width="160" data-expected-height="300"></div>
-</div>
-FAIL:
-Expected 300 for height, but got 90. 
-
-<div class="grid" data-expected-width="400" data-expected-height="300">
-    <div class="sizedToGridArea bothRowSecondColumn" data-offset-x="160" data-offset-y="0" data-expected-width="240" data-expected-height="300"></div>
-</div>
-FAIL:
-Expected 400 for width, but got 160. 
-Expected 300 for height, but got 90. 
-
-<div class="grid" data-expected-width="400" data-expected-height="300">
-    <div class="sizedToGridArea bothRowBothColumn" data-offset-x="0" data-offset-y="0" data-expected-width="400" data-expected-height="300"></div>
-</div>
 PASS
 PASS
 PASS
+PASS
+PASS
+PASS
+PASS
+PASS
 FAIL:
 Expected 240 for width, but got 160. 
 Expected 160 for offsetLeft, but got 0. 

Modified: trunk/Source/WebCore/ChangeLog (145377 => 145378)


--- trunk/Source/WebCore/ChangeLog	2013-03-11 18:43:48 UTC (rev 145377)
+++ trunk/Source/WebCore/ChangeLog	2013-03-11 19:07:54 UTC (rev 145378)
@@ -1,3 +1,27 @@
+2013-03-11  Julien Chaffraix  <[email protected]>
+
+        [CSS Grid Layout] Handle spanning grid items over specified grid tracks
+        https://bugs.webkit.org/show_bug.cgi?id=111918
+
+        Reviewed by Tony Chang.
+
+        This change updates the containing block override logic to handle multiple
+        spanned tracks. This makes the multiple specified grid tracks case work and
+        will enable us to handle the minmax case once the computation logic has been
+        updated.
+
+        Test: fast/css-grid-layout/grid-item-spanning-resolution.html
+
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::logicalContentHeightForChild):
+        (WebCore::RenderGrid::layoutGridItems):
+        Updated these functions to use gridAreaBreadthForChild.
+
+        (WebCore::RenderGrid::gridAreaBreadthForChild):
+        Added this helper function to handle multiple spanned grid tracks.
+
+        * rendering/RenderGrid.h: Added the previous function.
+
 2013-03-11  Philip Rogers  <[email protected]>
 
         Replace SVG's static_cast<SVGElement> with toSVGElement()

Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (145377 => 145378)


--- trunk/Source/WebCore/rendering/RenderGrid.cpp	2013-03-11 18:43:48 UTC (rev 145377)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp	2013-03-11 19:07:54 UTC (rev 145378)
@@ -359,8 +359,7 @@
     if (!child->needsLayout())
         child->setNeedsLayout(true, MarkOnlyThis);
 
-    const GridCoordinate& coordinate = cachedGridCoordinate(child);
-    child->setOverrideContainingBlockContentLogicalWidth(columnTracks[coordinate.columnIndex].m_usedBreadth);
+    child->setOverrideContainingBlockContentLogicalWidth(gridAreaBreadthForChild(child, ForColumns, columnTracks));
     child->clearOverrideContainingBlockContentLogicalHeight();
     child->layout();
     return child->logicalHeight();
@@ -645,8 +644,6 @@
     for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
         LayoutPoint childPosition = findChildLogicalPosition(child, columnTracks, rowTracks);
 
-        const GridCoordinate& childCoordinate = cachedGridCoordinate(child);
-
         // Because the grid area cannot be styled, we don't need to adjust
         // the grid breadth to account for 'box-sizing'.
         LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOverrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogicalWidth() : LayoutUnit();
@@ -654,11 +651,13 @@
 
         // FIXME: For children in a content sized track, we clear the overrideContainingBlockContentLogicalHeight
         // in minContentForChild / maxContentForChild which means that we will always relayout the child.
-        if (oldOverrideContainingBlockContentLogicalWidth != columnTracks[childCoordinate.columnIndex].m_usedBreadth || oldOverrideContainingBlockContentLogicalHeight != rowTracks[childCoordinate.rowIndex].m_usedBreadth)
+        LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForChild(child, ForColumns, columnTracks);
+        LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadthForChild(child, ForRows, rowTracks);
+        if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingBlockContentLogicalWidth || oldOverrideContainingBlockContentLogicalHeight != overrideContainingBlockContentLogicalHeight)
             child->setNeedsLayout(true, MarkOnlyThis);
 
-        child->setOverrideContainingBlockContentLogicalWidth(columnTracks[childCoordinate.columnIndex].m_usedBreadth);
-        child->setOverrideContainingBlockContentLogicalHeight(rowTracks[childCoordinate.rowIndex].m_usedBreadth);
+        child->setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockContentLogicalWidth);
+        child->setOverrideContainingBlockContentLogicalHeight(overrideContainingBlockContentLogicalHeight);
 
         // FIXME: Grid items should stretch to fill their cells. Once we
         // implement grid-{column,row}-align, we can also shrink to fit. For
@@ -742,6 +741,23 @@
     return 0;
 }
 
+LayoutUnit RenderGrid::gridAreaBreadthForChild(const RenderBox* child, TrackSizingDirection direction, const Vector<GridTrack>& tracks) const
+{
+    const GridCoordinate& coordinate = cachedGridCoordinate(child);
+    size_t trackIndex = (direction == ForColumns) ? coordinate.columnIndex : coordinate.rowIndex;
+    OwnPtr<GridSpan> span = resolveGridPositionsFromStyle(child, direction);
+    if (!span) {
+        // FIXME: We don't support spanning with auto positions yet. Once we do, this is wrong.
+        span = adoptPtr(new GridSpan(trackIndex, trackIndex));
+    }
+
+    ASSERT(span->initialPositionIndex == trackIndex);
+    LayoutUnit gridAreaBreadth = 0;
+    for (; trackIndex <= span->finalPositionIndex; ++trackIndex)
+        gridAreaBreadth += tracks[trackIndex].m_usedBreadth;
+    return gridAreaBreadth;
+}
+
 LayoutPoint RenderGrid::findChildLogicalPosition(RenderBox* child, const Vector<GridTrack>& columnTracks, const Vector<GridTrack>& rowTracks)
 {
     const GridCoordinate& coordinate = cachedGridCoordinate(child);

Modified: trunk/Source/WebCore/rendering/RenderGrid.h (145377 => 145378)


--- trunk/Source/WebCore/rendering/RenderGrid.h	2013-03-11 18:43:48 UTC (rev 145377)
+++ trunk/Source/WebCore/rendering/RenderGrid.h	2013-03-11 19:07:54 UTC (rev 145378)
@@ -125,6 +125,8 @@
     };
     size_t resolveGridPositionFromStyle(const GridPosition&, GridPositionSide) const;
 
+    LayoutUnit gridAreaBreadthForChild(const RenderBox* child, TrackSizingDirection, const Vector<GridTrack>&) const;
+
 #ifndef NDEBUG
     bool tracksAreWiderThanMinTrackBreadth(TrackSizingDirection, const Vector<GridTrack>&);
     bool gridWasPopulated() const { return !m_grid.isEmpty() && !m_grid[0].isEmpty(); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to