[css-grid] Improve grid container sizing with size constraints and intrinsic sizes
authorsvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Nov 2015 12:56:43 +0000 (12:56 +0000)
committersvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Nov 2015 12:56:43 +0000 (12:56 +0000)
commit81ad778a33a14930efe8c7afc2ef4e40d818eef3
tree15395ca29bd42c129a4009038b0ac9a4d3c07426
parentf1aa4b80f2cb262fcf2fefe1ba3dec8b05490364
[css-grid] Improve grid container sizing with size constraints and intrinsic sizes
https://bugs.webkit.org/show_bug.cgi?id=150679

Reviewed by Darin Adler.

Source/WebCore:

The grid container stores from now on its min-content and
max-content block sizes in order to be able to properly
compute its intrinsic size. It has to redefine
computeIntrinsicLogicalContentHeightUsing() because the
behavior of grid is different to "normal" blocks:

- the min-content size is the sum of the grid container's
track sizes in the appropiate axis when the grid is sized
under a min-content constraint.
- the max-content size is the sum of the grid container's
track sizes in the appropiate axis when the grid is sized
under a max-content constraint.
- the auto block size is the max-content size.

A nice side effect is that we can now properly detect whether
the grid has a definite size on a given axis or not.

Tests: fast/css-grid-layout/absolute-positioning-definite-sizes.html
       fast/css-grid-layout/flex-and-intrinsic-sizes.html
       fast/css-grid-layout/maximize-tracks-definite-indefinite-height.html
       fast/css-grid-layout/maximize-tracks-definite-indefinite-width.html

* rendering/RenderBox.h: made
computeIntrinsicLogicalContentHeightUsing() virtual.
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::GridSizingData::GridSizingData):
(WebCore::RenderGrid::GridSizingData::freeSpaceForDirection):
(WebCore::RenderGrid::GridSizingData::setFreeSpaceForDirection):
(WebCore::RenderGrid::computeTrackBasedLogicalHeight):
(WebCore::RenderGrid::computeTrackSizesForDirection):
(WebCore::RenderGrid::layoutBlock):
(WebCore::RenderGrid::computeIntrinsicLogicalWidths):
(WebCore::RenderGrid::computeIntrinsicLogicalHeight):
(WebCore::RenderGrid::computeIntrinsicLogicalContentHeightUsing):
(WebCore::RenderGrid::computeUsedBreadthOfGridTracks):
(WebCore::RenderGrid::distributeSpaceToTracks):
(WebCore::RenderGrid::tracksAreWiderThanMinTrackBreadth):
(WebCore::RenderGrid::applyStretchAlignmentToTracksIfNeeded):
(WebCore::RenderGrid::layoutGridItems):
(WebCore::RenderGrid::populateGridPositions):
(WebCore::RenderGrid::gridElementIsShrinkToFit): Deleted.
* rendering/RenderGrid.h:

LayoutTests:

* fast/css-grid-layout/absolute-positioning-definite-sizes-expected.txt: Added.
* fast/css-grid-layout/absolute-positioning-definite-sizes.html: Added.
* fast/css-grid-layout/flex-and-intrinsic-sizes-expected.txt: Added.
* fast/css-grid-layout/flex-and-intrinsic-sizes.html: Added.
* fast/css-grid-layout/grid-element-change-columns-repaint.html:
* fast/css-grid-layout/grid-item-change-column-repaint.html:
* fast/css-grid-layout/grid-preferred-logical-widths.html:
* fast/css-grid-layout/maximize-tracks-definite-indefinite-height-expected.txt: Added.
* fast/css-grid-layout/maximize-tracks-definite-indefinite-height.html: Added.
* fast/css-grid-layout/maximize-tracks-definite-indefinite-width-expected.txt: Added.
* fast/css-grid-layout/maximize-tracks-definite-indefinite-width.html: Added.
* fast/css-grid-layout/percent-of-indefinite-track-size.html:
* fast/events/key-events-in-editable-gridbox-expected.txt:
* fast/events/key-events-in-editable-gridbox.html: Added more test
cases for intrinsic and fixed sized heights.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192154 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css-grid-layout/absolute-positioning-definite-sizes-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/absolute-positioning-definite-sizes.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/flex-and-intrinsic-sizes-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/flex-and-intrinsic-sizes.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-element-change-columns-repaint.html
LayoutTests/fast/css-grid-layout/grid-item-change-column-repaint.html
LayoutTests/fast/css-grid-layout/grid-preferred-logical-widths.html
LayoutTests/fast/css-grid-layout/maximize-tracks-definite-indefinite-height-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/maximize-tracks-definite-indefinite-height.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/maximize-tracks-definite-indefinite-width-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/maximize-tracks-definite-indefinite-width.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/percent-of-indefinite-track-size.html
LayoutTests/fast/events/key-events-in-editable-gridbox-expected.txt
LayoutTests/fast/events/key-events-in-editable-gridbox.html
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderGrid.cpp
Source/WebCore/rendering/RenderGrid.h