[CSS Grid Layout] Support sparse in auto-placement algorithm
authorrego@igalia.com <rego@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Jul 2014 21:23:49 +0000 (21:23 +0000)
committerrego@igalia.com <rego@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Jul 2014 21:23:49 +0000 (21:23 +0000)
commit70f2e3091ab2563facd0056ca15594437a2dbdf3
tree6dfac9239d93776cdb2e49f9dd13520a21ce0d7a
parentb5da530f000b2914b99f8f61a3b8d53418600289
[CSS Grid Layout] Support sparse in auto-placement algorithm
https://bugs.webkit.org/show_bug.cgi?id=134544

Reviewed by Sergio Villar Senin.

Source/WebCore:
This patch implements sparse mode for auto-placement algorithm, which is
the default mode in the new grid-auto-flow syntax. It keeps track of the
auto-placement cursor in
RenderGrid::placeAutoMajorAxisItemsOnGrid() and updates it accordingly
when auto-positioned items are placed.
If we're in dense mode it resets the cursor after each item (which keeps
the old behavior that was using dense mode by default).

GridIterator has been adapted to look for empty areas from a given
position in both directions.

Test: fast/css-grid-layout/grid-auto-flow-sparse.html

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::GridIterator::GridIterator): Modify constructor to
add an optional argument for the varying index. This allows to look for
empty areas in both axis.
(WebCore::RenderGrid::placeAutoMajorAxisItemsOnGrid): Defined the
auto-placement cursor and rested after each item if we're in dense mode.
(WebCore::RenderGrid::placeAutoMajorAxisItemOnGrid): Use auto-placement
cursor to look for empty areas from the last auto-positioned item
placed.
* rendering/RenderGrid.h: Modify placeAutoMajorAxisItemOnGrid() header
to receive the auto-placement cursor.

LayoutTests:
Test cases have been adapted accordingly, adding new cases to cover both
sparse and dense options.

* fast/css-grid-layout/grid-auto-flow-resolution-expected.txt:
* fast/css-grid-layout/grid-auto-flow-resolution.html:
* fast/css-grid-layout/grid-auto-flow-sparse-expected.txt: Added.
* fast/css-grid-layout/grid-auto-flow-sparse.html: Added.
* fast/css-grid-layout/grid-container-change-named-grid-lines-recompute-child.html:
* fast/css-grid-layout/grid-item-auto-placement-automatic-span-expected.txt:
* fast/css-grid-layout/grid-item-auto-placement-automatic-span.html:
* fast/css-grid-layout/grid-item-auto-placement-definite-span-expected.txt:
* fast/css-grid-layout/grid-item-auto-placement-definite-span.html:
* fast/css-grid-layout/grid-item-removal-auto-placement-update.html:
* fast/css-grid-layout/named-grid-lines-with-named-grid-areas-resolution.html:
* fast/css-grid-layout/resources/grid.css:
(.autoRowAutoColumnSpanning2):
(.autoRowSpanning2AutoColumn):
(.autoRowSpanning2AutoColumnSpanning3):
(.autoRowSpanning3AutoColumnSpanning2):
(.gridAutoFlowColumnDense):
(.gridAutoFlowRowDense):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@171082 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css-grid-layout/grid-auto-flow-resolution-expected.txt
LayoutTests/fast/css-grid-layout/grid-auto-flow-resolution.html
LayoutTests/fast/css-grid-layout/grid-auto-flow-sparse-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-auto-flow-sparse.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-container-change-named-grid-lines-recompute-child.html
LayoutTests/fast/css-grid-layout/grid-item-auto-placement-automatic-span-expected.txt
LayoutTests/fast/css-grid-layout/grid-item-auto-placement-automatic-span.html
LayoutTests/fast/css-grid-layout/grid-item-auto-placement-definite-span-expected.txt
LayoutTests/fast/css-grid-layout/grid-item-auto-placement-definite-span.html
LayoutTests/fast/css-grid-layout/grid-item-removal-auto-placement-update.html
LayoutTests/fast/css-grid-layout/named-grid-lines-with-named-grid-areas-resolution.html
LayoutTests/fast/css-grid-layout/resources/grid.css
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderGrid.cpp
Source/WebCore/rendering/RenderGrid.h