[CSS Grid Layout] Implement grid items sizing for fixed minmax grid tracks
authorjchaffraix@webkit.org <jchaffraix@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Jan 2013 02:41:22 +0000 (02:41 +0000)
committerjchaffraix@webkit.org <jchaffraix@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Jan 2013 02:41:22 +0000 (02:41 +0000)
commit33a040ad53a95c05086928f60f848c37803db080
tree4cc891a785e43f91b18be561dfb55529b59dd0ae
parentbef6b4f0da6299fd7d7493554fedfe315298fb9e
[CSS Grid Layout] Implement grid items sizing for fixed minmax grid tracks
https://bugs.webkit.org/show_bug.cgi?id=104700

Reviewed by Tony Chang.

Source/WebCore:

This change implements parts of the minmax() track sizing algorithm. The chosen subset enables us
to resolve any sizing function that doesn't size based on the content (min-content, max-content).

Tests: fast/css-grid-layout/minmax-fixed-logical-height-only.html
       fast/css-grid-layout/minmax-fixed-logical-width-only.html

* rendering/RenderGrid.cpp:
(WebCore::GridTrack::GridTrack):
Added a new member to hold the maximum track breadth.

(WebCore::RenderGrid::computePreferredLogicalWidths):
(WebCore::RenderGrid::computedUsedBreadthOfGridTracks):
Updated these functions to work on both min and max track breadth. In order to match
the specification, if max track breadth < min track breadth, we ignore the max track breadth.
For computedUsedBreadthOfGridTracks, it also involves calling distributeSpaceToTracks.

(WebCore::RenderGrid::computeUsedBreadthOfLength):
New helper function that compute a single length's size.

(WebCore::sortByGridTrackGrowthPotential):
Ordering function for the sorting the track: it orders the track per increasing potential
growth (defined as the difference between max breadth and the currently used breadth).

(WebCore::RenderGrid::distributeSpaceToTracks):
Added this function that matches the specification's algorithm. Only the relevant bits from
the specification were implemented for now (for example, SubsetOfTracksForGrowthBeyondTrackGrowthConstraint
is always the empty set so it was omitted).

* rendering/RenderGrid.h:
Added the new functions and declared GridTrack as public into the WebCore namespace.

* rendering/style/GridTrackSize.h:
(WebCore::GridTrackSize::minTrackBreadth):
(WebCore::GridTrackSize::maxTrackBreadth):
Removed 2 ASSERTs as the layout algorithm doesn't care if the min / max were
set from a single track breadth or through minmax().

LayoutTests:

* fast/css-grid-layout/minmax-fixed-logical-height-only-expected.txt: Added.
* fast/css-grid-layout/minmax-fixed-logical-height-only.html: Added.
* fast/css-grid-layout/minmax-fixed-logical-width-only-expected.txt: Added.
* fast/css-grid-layout/minmax-fixed-logical-width-only.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@139025 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/css-grid-layout/minmax-fixed-logical-height-only-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/minmax-fixed-logical-height-only.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/minmax-fixed-logical-width-only-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/minmax-fixed-logical-width-only.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderGrid.cpp
Source/WebCore/rendering/RenderGrid.h
Source/WebCore/rendering/style/GridTrackSize.h