[css-grid] Implement repeat(auto-fit)
authorsvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Jul 2016 08:57:06 +0000 (08:57 +0000)
committersvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Jul 2016 08:57:06 +0000 (08:57 +0000)
commit25e13800612244064b3bce86e27b8211ff4b30ed
treec46b5e12d8906c34ed7c389fe200a3e9b9a28d2b
parent1c78a1706bf00dde23f54aab2cf1c8b8adec5734
[css-grid] Implement repeat(auto-fit)
https://bugs.webkit.org/show_bug.cgi?id=159771

Reviewed by Darin Adler.

Source/WebCore:

The auto-fit keyword works exactly as the already implemented auto-fill except that all
empty tracks collapse (became 0px). Absolutely positioned items do not participate on the
layout of the grid so they are not considered (a grid with only absolutely positioned items
is considered an empty grid).

Whenever a track collapses the gutters on either side do also collapse. When a collapsed
track's gutters collapse, they coincide exactly. If one side of a collapsed track does not
have a gutter then collapsing its gutters results in no gutter on either "side" of the
collapsed track.

In practice this means that is not possible to know the gap between 2 consecutive auto
repeat tracks without examining some others whenever there are collapsed tracks.

Uncommented the auto-fit cases from Mozilla tests. They have to be adapted as the reftest
machinery requires all the content to be rendered in the original 800x600 viewport.

Tests: fast/css-grid-layout/grid-auto-fit-columns.html
fast/css-grid-layout/grid-auto-fit-rows.html
fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-005-part-1.html
fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-005-part-2.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::valueForGridTrackList): Use the newly added trackSizesForComputedStyle().
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::computeTrackBasedLogicalHeight):
(WebCore::RenderGrid::computeTrackSizesForDirection):
(WebCore::RenderGrid::isEmptyAutoRepeatTrack):
(WebCore::RenderGrid::gridGapForDirection): Returns the gap directly from the style.
(WebCore::RenderGrid::guttersSize): Computes the gap between a startLine and an
endLine. This method may need to inspect some other surrounding tracks to compute the gap.
(WebCore::RenderGrid::computeIntrinsicLogicalWidths):
(WebCore::RenderGrid::computeIntrinsicLogicalHeight):
(WebCore::RenderGrid::computeUsedBreadthOfGridTracks):
(WebCore::RenderGrid::gridTrackSize):
(WebCore::RenderGrid::resolveContentBasedTrackSizingFunctionsForItems):
(WebCore::RenderGrid::computeAutoRepeatTracksCount):
(WebCore::RenderGrid::computeEmptyTracksForAutoRepeat): Returns a Vector with the auto
repeat tracks that are going to be collapsed because they're empty.
(WebCore::RenderGrid::placeItemsOnGrid):
(WebCore::RenderGrid::trackSizesForComputedStyle): Used by ComputedStyle logic to print the
size of tracks. Added in order to hide the actual contents of m_columnPositions and
m_rowPositions to the outter world.
(WebCore::RenderGrid::offsetAndBreadthForPositionedChild):
(WebCore::RenderGrid::gridAreaBreadthForChild):
(WebCore::RenderGrid::populateGridPositionsForDirection): Added some extra code to compute
gaps as they cannot be directly added between tracks in case of having collapsed tracks.
(WebCore::RenderGrid::columnAxisOffsetForChild):
(WebCore::RenderGrid::rowAxisOffsetForChild):
(WebCore::RenderGrid::offsetBetweenTracks): Deleted.
* rendering/RenderGrid.h: Made some API private. Added new required methods/attributes.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::valueForGridTrackList):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::computeTrackBasedLogicalHeight):
(WebCore::RenderGrid::computeTrackSizesForDirection):
(WebCore::RenderGrid::hasAutoRepeatEmptyTracks):
(WebCore::RenderGrid::isEmptyAutoRepeatTrack):
(WebCore::RenderGrid::gridGapForDirection):
(WebCore::RenderGrid::guttersSize):
(WebCore::RenderGrid::computeIntrinsicLogicalWidths):
(WebCore::RenderGrid::computeIntrinsicLogicalHeight):
(WebCore::RenderGrid::computeUsedBreadthOfGridTracks):
(WebCore::RenderGrid::gridTrackSize):
(WebCore::RenderGrid::resolveContentBasedTrackSizingFunctionsForItems):
(WebCore::RenderGrid::computeAutoRepeatTracksCount):
(WebCore::RenderGrid::computeEmptyTracksForAutoRepeat):
(WebCore::RenderGrid::placeItemsOnGrid):
(WebCore::RenderGrid::trackSizesForComputedStyle):
(WebCore::RenderGrid::offsetAndBreadthForPositionedChild):
(WebCore::RenderGrid::assumedRowsSizeForOrthogonalChild):
(WebCore::RenderGrid::gridAreaBreadthForChild):
(WebCore::RenderGrid::populateGridPositionsForDirection):
(WebCore::RenderGrid::columnAxisOffsetForChild):
(WebCore::RenderGrid::rowAxisOffsetForChild):
(WebCore::RenderGrid::offsetBetweenTracks): Deleted.
* rendering/RenderGrid.h:

LayoutTests:

Uncommented the auto-fit cases. Split the Mozilla's 005 test in two because it was not
possible to fit all the content in a viewport without scrollbars.

* fast/css-grid-layout/grid-auto-fit-columns-expected.txt: Added.
* fast/css-grid-layout/grid-auto-fit-columns.html: Added.
* fast/css-grid-layout/grid-auto-fit-rows-expected.txt: Added.
* fast/css-grid-layout/grid-auto-fit-rows.html: Added.
* fast/css-grid-layout/grid-element-auto-repeat-get-set-expected.txt:
* fast/css-grid-layout/grid-element-auto-repeat-get-set.html:
* fast/css-grid-layout/grid-only-abspos-item-computed-style-crash-expected.txt:
* fast/css-grid-layout/grid-only-abspos-item-computed-style-crash.html:
* fast/css-grid-layout/grid-positioned-items-padding-expected.txt:
* fast/css-grid-layout/grid-positioned-items-padding.html:
* fast/css-grid-layout/grid-template-columns-rows-computed-style-gaps-content-alignment-expected.txt:
* fast/css-grid-layout/grid-template-columns-rows-computed-style-gaps-content-alignment.html:
* fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-001-expected.html:
* fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-001.html:
* fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-002-expected.html:
* fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-002.html:
* fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-003-expected.html:
* fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-003.html:
* fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-004-expected.html:
* fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-004.html:
* fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-005-part-1-expected.html: Renamed from LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-005-expected.html.
* fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-005-part-1.html: Copied from LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-005.html.
* fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-005-part-2-expected.html: Added.
* fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-005-part-2.html: Renamed from LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-005.html.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203680 268f45cc-cd09-0410-ab3c-d52691b4dbfc
29 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css-grid-layout/grid-auto-fit-columns-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-auto-fit-columns.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-auto-fit-rows-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-auto-fit-rows.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-element-auto-repeat-get-set-expected.txt
LayoutTests/fast/css-grid-layout/grid-element-auto-repeat-get-set.html
LayoutTests/fast/css-grid-layout/grid-only-abspos-item-computed-style-crash-expected.txt
LayoutTests/fast/css-grid-layout/grid-only-abspos-item-computed-style-crash.html
LayoutTests/fast/css-grid-layout/grid-positioned-items-padding-expected.txt
LayoutTests/fast/css-grid-layout/grid-positioned-items-padding.html
LayoutTests/fast/css-grid-layout/grid-template-columns-rows-computed-style-gaps-content-alignment-expected.txt
LayoutTests/fast/css-grid-layout/grid-template-columns-rows-computed-style-gaps-content-alignment.html
LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-001-expected.html
LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-001.html
LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-002-expected.html
LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-002.html
LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-003-expected.html
LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-003.html
LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-004-expected.html
LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-004.html
LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-005-part-1-expected.html [moved from LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-005-expected.html with 55% similarity]
LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-005-part-1.html [moved from LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-005.html with 55% similarity]
LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-005-part-2-expected.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-005-part-2.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/rendering/RenderGrid.cpp
Source/WebCore/rendering/RenderGrid.h