[CSS Grid Layout] Interaction between auto-placement and column / row spanning
authorrego@igalia.com <rego@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jun 2014 16:41:08 +0000 (16:41 +0000)
committerrego@igalia.com <rego@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jun 2014 16:41:08 +0000 (16:41 +0000)
commit158006a43f194eecc6012c72b5ecc372be787da8
tree72ed33391de323e554a5afe0de51a20a7f727386
parentf90adc2301144d6a66bc4c86a2a14a8404fd4899
[CSS Grid Layout] Interaction between auto-placement and column / row spanning
https://bugs.webkit.org/show_bug.cgi?id=110633

Reviewed by Sergio Villar Senin.

Source/WebCore:
Modify auto-placement algorithm in order to support span in both
definite and automatic positions.

This patch fixes examples like:
grid-row: auto;
grid-column: 2 / span 3;

And also:
grid-row: auto;
grid-column: span 3;

Tests: fast/css-grid-layout/grid-item-auto-placement-automatic-span.html
       fast/css-grid-layout/grid-item-auto-placement-definite-span.html

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::GridIterator::isEmptyAreaEnough): New method that
checks if a grid area is or not empty.
(WebCore::RenderGrid::GridIterator::nextEmptyGridArea): Updated method
that now receives two arguments with the span value in both directions.
(WebCore::RenderGrid::ensureGridSize): Renamed from gridRow(). Adapted
method to grow in both directions at the same time if needed. It ensures
that the grid is big enough to insert a new item.
(WebCore::RenderGrid::insertItemIntoGrid): Only leave the method that
receives a GridCoordinate. It uses ensureGridSize() before inserting the
item in the grid.
(WebCore::RenderGrid::populateExplicitGridAndOrderIterator): Ensure that
the grid is big enough to place the largest span for auto-positioned
items.
(WebCore::RenderGrid::createEmptyGridAreaAtSpecifiedPositionsOutsideGrid):
New method that returns a GridCoordinate outside current grid with the
requested dimensions.
(WebCore::RenderGrid::placeSpecifiedMajorAxisItemsOnGrid): Adapted
method to calculate the item's span and use the new version of
nextEmptyGridArea(). If an empty area is not found it uses
createEmptyGridAreaAtSpecifiedPositionsOutsideGrid() to place the item.
(WebCore::RenderGrid::placeAutoMajorAxisItemOnGrid): Ditto.
(WebCore::RenderGrid::growGrid): Renamed to ensureGridSize().
* rendering/RenderGrid.h: Modify methods headers and add new method
signature.
* rendering/style/GridCoordinate.h:
(WebCore::GridSpan::integerSpan): Add new simple method to return the
span value of a position.
* rendering/style/GridResolvedPosition.cpp:
(WebCore::GridResolvedPosition::resolveGridPositionsFromAutoPlacementPosition):
Implement method to take into account span in auto-placement algorithm.
(WebCore::GridResolvedPosition::adjustGridPositionsFromStyle): Add new
checks related with named grid line spans in auto-positioned items,
which is not allowed according to the spec.
* rendering/style/GridResolvedPosition.h: Update method header.

LayoutTests:
Add new specific test cases for span in auto-placement algorithm.

* fast/css-grid-layout/grid-item-auto-placement-automatic-span-expected.txt: Added.
* fast/css-grid-layout/grid-item-auto-placement-automatic-span.html: Added.
* fast/css-grid-layout/grid-item-auto-placement-definite-span-expected.txt: Added.
* fast/css-grid-layout/grid-item-auto-placement-definite-span.html: Added.
* fast/css-grid-layout/grid-item-spanning-resolution.html: Update test
case now that span in auto-positioned items is supported.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170531 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css-grid-layout/grid-item-auto-placement-automatic-span-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-item-auto-placement-automatic-span.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-item-auto-placement-definite-span-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-item-auto-placement-definite-span.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-item-spanning-resolution.html
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderGrid.cpp
Source/WebCore/rendering/RenderGrid.h
Source/WebCore/rendering/style/GridCoordinate.h
Source/WebCore/rendering/style/GridResolvedPosition.cpp
Source/WebCore/rendering/style/GridResolvedPosition.h