[css-grid] Implement fit-content track size
[WebKit-https.git] / Source / WebCore / ChangeLog
index 3bbab61..cf7f052 100644 (file)
@@ -1,3 +1,98 @@
+2016-09-07  Sergio Villar Senin  <svillar@igalia.com>
+
+        [css-grid] Implement fit-content track size
+        https://bugs.webkit.org/show_bug.cgi?id=161379
+
+        Reviewed by Manuel Rego Casasnovas.
+
+        This implements the new <fit-content> track size which is defined as follows: "Represents
+        the formula min(max-content, max(auto, argument)), which is calculated similar to auto
+        (i.e. minmax(auto, max-content)), except that the track size is clamped at argument if it is
+        greater than the auto minimum."
+
+        From the parsing POV fit-content was implemented as a new type of function which only takes
+        one argument. That forced us to refactor some code because minmax() was the only allowed
+        function for <track-size>s so far.
+
+        The implementation key is a new attribute in GridTrack called growthLimitCap which is
+        precisely the single attribute of fit-content(). Some parts of the track sizing algorithm
+        were adapted to this change like for example the sorting of tracks by growth potential (we
+        need to consider the caps).
+
+        Tests: fast/css-grid-layout/fit-content-columns.html
+        fast/css-grid-layout/fit-content-rows.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::specifiedValueForGridTrackSize): Added support for fit-content sizes.
+        * css/StyleBuilderConverter.h:
+        (WebCore::StyleBuilderConverter::createGridTrackSize): Added support for fit-content sizes.
+        * css/parser/CSSParser.cpp:
+        (WebCore::isGridTrackFixedSized): Added support for fit-content sizes.
+        (WebCore::CSSParser::parseGridTrackSize): Added support for parsing fit-content() functions.
+        * css/parser/CSSPropertyParser.cpp: Added support for parsing fit-content() functions so
+        it'll be available once we switch to the new parser.
+        * rendering/RenderGrid.cpp:
+        (WebCore::GridTrack::baseSize): Just return a LayoutUnit, the return value optimization will
+        keep it fast in any case.
+        (WebCore::GridTrack::growthLimit): Ditto.
+        (WebCore::GridTrack::setGrowthLimit): Added an ASSERT to check that the growth limit is
+        never higher than the cap.
+        (WebCore::GridTrack::infiniteGrowthPotential):
+        (WebCore::GridTrack::plannedSize): Just return a LayoutUnit, the return value optimization will
+        keep it fast in any case.
+        (WebCore::GridTrack::tempSize): Just return a LayoutUnit, the return value optimization will
+        keep it fast in any case.
+        (WebCore::GridTrack::setTempSize): Added as we no longer return a reference in tempSize().
+        (WebCore::GridTrack::growTempSize): New utility function which increases the tempSize.
+        (WebCore::GridTrack::setInfinitelyGrowable):
+        (WebCore::GridTrack::setGrowthLimitCap): Added.
+        (WebCore::GridTrack::growthLimitCap): Ditto.
+        (WebCore::GridTrack::growthLimitIsInfinite): Made private.
+        (WebCore::RenderGrid::GridSizingData::freeSpace): Renamed from freeSpaceForDirection.
+        (WebCore::RenderGrid::GridSizingData::availableSpace): We now cache the available space as
+        it is used to compute relative (percentage) sizes.
+        (WebCore::RenderGrid::GridSizingData::setAvailableSpace): Ditto.
+        (WebCore::RenderGrid::GridSizingData::setFreeSpace): Renamed from setFreeSpaceForDirection.
+        (WebCore::RenderGrid::computeTrackSizesForDirection): Receives the available space instead
+        of the free space.
+        (WebCore::RenderGrid::computeIntrinsicLogicalWidths): Properly initialize free and available
+        spaces.
+        (WebCore::RenderGrid::computeIntrinsicLogicalHeight): Ditto.
+        (WebCore::RenderGrid::computeUsedBreadthOfGridTracks): Use available space to initialize the
+        track sizes. Also use sizingOperation to decide whether or not sizes are indefinite. Last
+        but not least, added support for fit-content tracks.
+        (WebCore::RenderGrid::computeUsedBreadthOfMinLength): Pass a GridTrackSize instead of a GridLength.
+        (WebCore::RenderGrid::computeUsedBreadthOfMaxLength): Ditto.
+        (WebCore::RenderGrid::gridTrackSize): Added support for fit-content.
+        (WebCore::RenderGrid::resolveContentBasedTrackSizingFunctions): Ditto.
+        (WebCore::RenderGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems): Ditto.
+        (WebCore::trackSizeForTrackSizeComputationPhase):
+        (WebCore::sortByGridTrackGrowthPotential): Reworked the function so it properly sorts tracks
+        with growth limit caps to support fit-content().
+        (WebCore::clampGrowthShareIfNeeded): Clamps the given growthShare passed as argument to the
+        track growth limit cap.
+        (WebCore::RenderGrid::distributeSpaceToTracks): Use the new setTempSize() method. Also sort
+        the selected tracks to grow over growth limits in order to respect the track caps eventually
+        set by fit-content (otherwise those tracks could indefinitely grow over the specified value).
+        (WebCore::RenderGrid::tracksAreWiderThanMinTrackBreadth): Use the new defined functions.
+        (WebCore::RenderGrid::applyStretchAlignmentToTracksIfNeeded): Use freeSpace().
+        (WebCore::RenderGrid::populateGridPositionsForDirection): Ditto.
+        (WebCore::GridTrack::infinitelyGrowable): Deleted.
+        (WebCore::RenderGrid::GridSizingData::freeSpaceForDirection): Deleted.
+        (WebCore::RenderGrid::GridSizingData::setFreeSpaceForDirection): Deleted.
+        (WebCore::RenderGrid::trackSizeForTrackSizeComputationPhase): Deleted.
+        * rendering/RenderGrid.h: Changed the signature of some methods. Moved
+        TrackSizeComputationPhase out of the RenderGrid class.
+        * rendering/style/GridTrackSize.h:
+        (WebCore::GridTrackSize::GridTrackSize): Added some extra documentation. Added a new
+        attribute to the constructor to support fit-content GridTrackSizes.
+        (WebCore::GridTrackSize::fitContentTrackBreadth): New method which returns the growth limit
+        cap set by fit-content().
+        (WebCore::GridTrackSize::minTrackBreadth):
+        (WebCore::GridTrackSize::isFitContent): Added.
+        (WebCore::GridTrackSize::length): Deleted.
+        (WebCore::GridTrackSize::isPercentage): Deleted.
+
 2016-09-15  Alejandro G. Castro  <alex@igalia.com>
 
         Fix build warnings in the mediastream code