[CSS Grid Layout] Add support for min-content
https://bugs.webkit.org/show_bug.cgi?id=106474

Reviewed by Ojan Vafai.

Source/WebCore:

Tests: fast/css-grid-layout/minmax-min-content-column-resolution-columns.html
       fast/css-grid-layout/minmax-min-content-column-resolution-rows.html

This change adds support to properly size min-content as long as the grid items and the grid element
don't have orthogonal writing-modes. Orthogonal writing modes will be handled in a follow-up bug
to keep the patch small-ish.

This change implements a subset of the specification's algorithm, taking some shortcuts where the
extra complexity wasn't a clear win for now: e.g. the specification relies on behavior customization
through functors to share code among more complex cases - like spanning columns / rows. These shortcuts
have been marked as FIXME / comments in the code so that they can be evaluated and fixed as we implement
more of the complexity.

* platform/Length.h:
(WebCore::Length::isMinContent):
(WebCore::Length::isMaxContent):
Helper functions.

* rendering/RenderGrid.cpp:
(WebCore::GridTrack::maxBreadthIfNotInfinite):
Helper function that returns the max breadth if finite and the used breadth otherwise.

(WebCore::RenderGrid::computedUsedBreadthOfGridTracks):
Updated to call resolveContentBasedTrackSizingFunctions.

(WebCore::RenderGrid::computeUsedBreadthOfMinLength):
(WebCore::RenderGrid::computeUsedBreadthOfMaxLength):
(WebCore::RenderGrid::computeUsedBreadthOfSpecifiedLength):
Split computeUsedBreadthOfLength into min and max side so that we can return the default values accordingly.
computeUsedBreadthOfSpecifiedLength shares the common code. Also made these functions 'const'.

(WebCore::RenderGrid::minContentForChild):
This function returns the 'min-content' value based on layout / compute preferred logical widths information.

(WebCore::RenderGrid::resolveContentBasedTrackSizingFunctions):
This is the core function that implements the sizing. It currently doesn't share much code between the branches,
which will be done as we implement more of the algorithm.

(WebCore::RenderGrid::distributeSpaceToTracks):
Clamped the growthShare to positive value only. This is required to handle cases where min-content is bigger
than max track breadth. Added a comment about this deviation from the specification.

(WebCore::RenderGrid::tracksAreWiderThanMinTrackBreadth):
Debug only method. It is a sanity check as our algorithm should *never* shrink the used breadth to a value
smaller than the computed min track breadth.

(WebCore::RenderGrid::layoutGridItems):
Added 2 ASSERT using tracksAreWiderThanMinTrackBreadth.

(WebCore::RenderGrid::resolveGridPosition):
Helper overriden instance.
* rendering/RenderGrid.h:
Added the new functions. Also made more core functions take both grid tracks.

LayoutTests:

* fast/css-grid-layout/minmax-min-content-column-resolution-columns-expected.txt: Added.
* fast/css-grid-layout/minmax-min-content-column-resolution-columns.html: Added.
* fast/css-grid-layout/minmax-min-content-column-resolution-rows-expected.txt: Added.
* fast/css-grid-layout/minmax-min-content-column-resolution-rows.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@140198 268f45cc-cd09-0410-ab3c-d52691b4dbfc