[CSS Grid Layout] Invalid initialization of track sizes with non spanning grid items
authorsvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Feb 2015 16:14:16 +0000 (16:14 +0000)
committersvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Feb 2015 16:14:16 +0000 (16:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140763

Reviewed by Antti Koivisto.

Source/WebCore:

Content sized tracks with non-spanning grid items were not
properly sized because the growth limit was sometimes infinity
(-1) after calling resolveContentBasedTrackSizingFunctions() when
it should not. This patch adds an special initialization phase for
non-spanning grid items as the new track sizing algorithm
describes.

Granted, that was handled in the old algorithm in
distributeSpaceToTracks() as a special case. The problem is that
it regressed after the optimization added in r173868 because that
method is no longer called when the space to distribute is 0.

That's why we could fix this by allowing calls to
distributeSpaceToTracks() with spaceToDistribute>=0 but by fixing
it with an explicit initialization our implementation becomes
closer to the new algorithm and the initialization is now explicit
in the code instead of a side effect of calling
distributeSpaceToTracks() with no space to be distributed. It also
brings a slight performance improvement as we save sorts and hash
lookups.

I also took the change to add caching to several GridTrackSize
methods that were hot on the profiler (each one accounted for ~1%
of the total time, now they account for ~0.3% each).

Test: fast/css-grid-layout/grid-initialize-span-one-items.html

* rendering/RenderGrid.cpp:
(WebCore::GridItemWithSpan::span): New helper method for ASSERTs.
(WebCore::RenderGrid::resolveContentBasedTrackSizingFunctions):
Exclude non spanning grid items from the calls to
resolveContentBasedTrackSizingFunctionsForItems().
(WebCore::RenderGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems):
New method to resolve track sizes only using non-spanning grid
items.
(WebCore::RenderGrid::resolveContentBasedTrackSizingFunctionsForItems):
Ensure that it isn't called for non-spanning grid items.
* rendering/RenderGrid.h:
* rendering/style/GridTrackSize.h:
(WebCore::GridTrackSize::GridTrackSize): Cache return values.
(WebCore::GridTrackSize::setLength): Ditto.
(WebCore::GridTrackSize::setMinMax): Ditto.
(WebCore::GridTrackSize::cacheMinMaxTrackBreadthTypes): New method
that caches the return values for hasXXXTrackBreadth() methods.
(WebCore::GridTrackSize::hasMinOrMaxContentMinTrackBreadth): Use
the cached return value.
(WebCore::GridTrackSize::hasMaxContentMaxTrackBreadth): Ditto.
(WebCore::GridTrackSize::hasMinContentMaxTrackBreadth): Ditto.
(WebCore::GridTrackSize::hasMinOrMaxContentMaxTrackBreadth): Ditto.
(WebCore::GridTrackSize::hasMaxContentMinTrackBreadth): Ditto.
(WebCore::GridTrackSize::hasMinContentMinTrackBreadth): Ditto.
(WebCore::GridTrackSize::hasMinContentMinTrackBreadthAndMinOrMaxContentMaxTrackBreadth):
Ditto.
(WebCore::GridTrackSize::hasMaxContentMinTrackBreadthAndMaxContentMaxTrackBreadth):
Ditto.

LayoutTests:

* fast/css-grid-layout/grid-content-sized-columns-resolution-expected.txt:
* fast/css-grid-layout/grid-content-sized-columns-resolution.html:
* fast/css-grid-layout/grid-initialize-span-one-items-expected.txt: Added.
* fast/css-grid-layout/grid-initialize-span-one-items.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/css-grid-layout/grid-content-sized-columns-resolution-expected.txt
LayoutTests/fast/css-grid-layout/grid-content-sized-columns-resolution.html
LayoutTests/fast/css-grid-layout/grid-initialize-span-one-items-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-initialize-span-one-items.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

index 61f774a..6b97516 100644 (file)
@@ -1,3 +1,15 @@
+2015-01-23  Sergio Villar Senin  <svillar@igalia.com>
+
+        [CSS Grid Layout] Invalid initialization of track sizes with non spanning grid items
+        https://bugs.webkit.org/show_bug.cgi?id=140763
+
+        Reviewed by Antti Koivisto.
+
+        * fast/css-grid-layout/grid-content-sized-columns-resolution-expected.txt:
+        * fast/css-grid-layout/grid-content-sized-columns-resolution.html:
+        * fast/css-grid-layout/grid-initialize-span-one-items-expected.txt: Added.
+        * fast/css-grid-layout/grid-initialize-span-one-items.html: Added.
+
 2015-02-11  Chris Fleizach  <cfleizach@apple.com>
 
         AX: Undeprecate ios-simulator accessibility tests
index 8a5fa59..5607245 100644 (file)
@@ -13,7 +13,7 @@ PASS window.getComputedStyle(gridMaxContentAndMaxContentFixed, '').getPropertyVa
 
 Check that items are processed by ascending span to compute track breadths forbidding extra space distribution.
 PASS window.getComputedStyle(gridMinContentFixedAndAutoUnsortedConstrained, '').getPropertyValue('-webkit-grid-template-columns') is "0px 40px"
-PASS window.getComputedStyle(gridAutoAndAutoUnsortedConstrained, '').getPropertyValue('-webkit-grid-template-columns') is "5px 35px"
+PASS window.getComputedStyle(gridAutoAndAutoUnsortedConstrained, '').getPropertyValue('-webkit-grid-template-columns') is "10px 30px"
 PASS window.getComputedStyle(gridMinContentAndMinContentFixedUnsortedConstrained, '').getPropertyValue('-webkit-grid-template-columns') is "0px 40px"
 PASS window.getComputedStyle(gridMaxContentAndMinContentUnsortedConstrained, '').getPropertyValue('-webkit-grid-template-columns') is "0px 70px"
 PASS window.getComputedStyle(gridFixedMinContentAndMaxContentUnsortedConstrained, '').getPropertyValue('-webkit-grid-template-columns') is "10px 70px"
@@ -27,7 +27,7 @@ PASS window.getComputedStyle(gridMaxContentAndMaxContentFixedUnsortedConstrained
 
 Check that items are processed by ascending span to compute track breadths allowing extra space distribution.
 PASS window.getComputedStyle(gridMinContentFixedAndAutoUnsorted, '').getPropertyValue('-webkit-grid-template-columns') is "15px 90px"
-PASS window.getComputedStyle(gridAutoAndAutoUnsorted, '').getPropertyValue('-webkit-grid-template-columns') is "30px 60px"
+PASS window.getComputedStyle(gridAutoAndAutoUnsorted, '').getPropertyValue('-webkit-grid-template-columns') is "60px 30px"
 PASS window.getComputedStyle(gridMinContentAndMinContentFixedUnsorted, '').getPropertyValue('-webkit-grid-template-columns') is "0px 40px"
 PASS window.getComputedStyle(gridMaxContentAndMinContentUnsorted, '').getPropertyValue('-webkit-grid-template-columns') is "0px 70px"
 PASS window.getComputedStyle(gridFixedMinContentAndMaxContentUnsorted, '').getPropertyValue('-webkit-grid-template-columns') is "10px 70px"
index abd6659..aff4295 100644 (file)
@@ -316,7 +316,7 @@ testGridColumnsValues("gridMaxContentAndMaxContentFixed", "55px 35px");
 debug("");
 debug("Check that items are processed by ascending span to compute track breadths forbidding extra space distribution.");
 testGridColumnsValues("gridMinContentFixedAndAutoUnsortedConstrained", "0px 40px");
-testGridColumnsValues("gridAutoAndAutoUnsortedConstrained", "5px 35px");
+testGridColumnsValues("gridAutoAndAutoUnsortedConstrained", "10px 30px");
 testGridColumnsValues("gridMinContentAndMinContentFixedUnsortedConstrained", "0px 40px");
 testGridColumnsValues("gridMaxContentAndMinContentUnsortedConstrained", "0px 70px");
 testGridColumnsValues("gridFixedMinContentAndMaxContentUnsortedConstrained", "10px 70px");
@@ -331,7 +331,7 @@ testGridColumnsValues("gridMaxContentAndMaxContentFixedUnsortedConstrained", "40
 debug("");
 debug("Check that items are processed by ascending span to compute track breadths allowing extra space distribution.");
 testGridColumnsValues("gridMinContentFixedAndAutoUnsorted", "15px 90px");
-testGridColumnsValues("gridAutoAndAutoUnsorted", "30px 60px");
+testGridColumnsValues("gridAutoAndAutoUnsorted", "60px 30px");
 testGridColumnsValues("gridMinContentAndMinContentFixedUnsorted", "0px 40px");
 testGridColumnsValues("gridMaxContentAndMinContentUnsorted", "0px 70px");
 testGridColumnsValues("gridFixedMinContentAndMaxContentUnsorted", "10px 70px");
diff --git a/LayoutTests/fast/css-grid-layout/grid-initialize-span-one-items-expected.txt b/LayoutTests/fast/css-grid-layout/grid-initialize-span-one-items-expected.txt
new file mode 100644 (file)
index 0000000..efe1c69
--- /dev/null
@@ -0,0 +1,33 @@
+This test checks that content sized tracks are initialized using non-spanning grid items.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.getComputedStyle(gridAutoAndAuto, '').getPropertyValue('-webkit-grid-template-columns') is "10px 90px"
+PASS window.getComputedStyle(gridAutoAndAutoReversed, '').getPropertyValue('-webkit-grid-template-columns') is "90px 10px"
+PASS window.getComputedStyle(gridFixedMinContentFixedMaxContent, '').getPropertyValue('-webkit-grid-template-columns') is "50px 50px"
+PASS window.getComputedStyle(gridFixedMinContentFixedMaxContentTwoEmptyChildren, '').getPropertyValue('-webkit-grid-template-columns') is "50px 50px"
+PASS window.getComputedStyle(gridFixedMinContentFixedMaxContentFixedSizeChild, '').getPropertyValue('-webkit-grid-template-columns') is "60px 40px"
+PASS window.getComputedStyle(gridMaxContentAndAuto, '').getPropertyValue('-webkit-grid-template-columns') is "80px 20px"
+PASS window.getComputedStyle(gridMaxContentAndAutoReversed, '').getPropertyValue('-webkit-grid-template-columns') is "90px 10px"
+PASS window.getComputedStyle(gridMinContentAndAuto, '').getPropertyValue('-webkit-grid-template-columns') is "10px 90px"
+PASS window.getComputedStyle(gridMinContentAndAutoReversed, '').getPropertyValue('-webkit-grid-template-columns') is "20px 80px"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+X
+XXX XX XXX
+X
+XXX XX XXX
+XXX XX XXX
+XXX XX XXX
+XXXXXX
+XXX XX XXX
+X
+XXX XX XXX
+X
+XXX XX XXX
+X
+XXX XX XXX
+X
+XXX XX XXX
diff --git a/LayoutTests/fast/css-grid-layout/grid-initialize-span-one-items.html b/LayoutTests/fast/css-grid-layout/grid-initialize-span-one-items.html
new file mode 100644 (file)
index 0000000..02b40d6
--- /dev/null
@@ -0,0 +1,88 @@
+<!DOCTYPE html>
+<head>
+<link href="resources/grid.css" rel="stylesheet"/>
+<style>
+ .grid {
+     font: 10px/1 Ahem;
+ }
+ .gridAutoAndAuto {
+     -webkit-grid-template-columns: auto auto;
+ }
+ .gridFixedMinContentFixedMaxContent {
+    -webkit-grid-template-columns: minmax(50px, -webkit-min-content) minmax(40px, -webkit-max-content);
+ }
+ .gridMaxContentAndAuto {
+     -webkit-grid-template-columns: -webkit-max-content auto;
+ }
+ .gridMinContentAndAuto {
+     -webkit-grid-template-columns: -webkit-min-content auto;
+ }
+</style>
+<script src="../../resources/js-test.js"></script>
+</head>
+<body>
+<div class="grid gridAutoAndAuto" id="gridAutoAndAuto">
+    <div class="firstRowFirstColumn">X</div>
+    <div class="firstRowBothColumn">XXX XX XXX</div>
+</div>
+
+<div class="grid gridAutoAndAuto" id="gridAutoAndAutoReversed">
+    <div class="firstRowSecondColumn">X</div>
+    <div class="firstRowBothColumn">XXX XX XXX</div>
+</div>
+
+<div class="grid gridFixedMinContentFixedMaxContent" id="gridFixedMinContentFixedMaxContent">
+    <div class="sizedToGridArea firstRowFirstColumn"></div>
+    <div class="firstRowBothColumn">XXX XX XXX</div>
+</div>
+
+<div class="grid gridFixedMinContentFixedMaxContent" id="gridFixedMinContentFixedMaxContentTwoEmptyChildren">
+    <div class="sizedToGridArea firstRowFirstColumn"></div>
+    <div class="sizedToGridArea firstRowSecondColumn"></div>
+    <div class="firstRowBothColumn">XXX XX XXX</div>
+</div>
+
+<div class="grid gridFixedMinContentFixedMaxContent" id="gridFixedMinContentFixedMaxContentFixedSizeChild">
+    <div class="firstRowFirstColumn">XXXXXX</div>
+    <div class="firstRowBothColumn">XXX XX XXX</div>
+</div>
+
+<div class="grid gridMaxContentAndAuto" id="gridMaxContentAndAuto">
+    <div class="firstRowFirstColumn">X</div>
+    <div class="firstRowBothColumn">XXX XX XXX</div>
+</div>
+
+<div class="grid gridMaxContentAndAuto" id="gridMaxContentAndAutoReversed">
+    <div class="firstRowSecondColumn">X</div>
+    <div class="firstRowBothColumn">XXX XX XXX</div>
+</div>
+
+<div class="grid gridMinContentAndAuto" id="gridMinContentAndAuto">
+    <div class="firstRowFirstColumn">X</div>
+    <div class="firstRowBothColumn">XXX XX XXX</div>
+</div>
+
+<div class="grid gridMinContentAndAuto" id="gridMinContentAndAutoReversed">
+    <div class="firstRowSecondColumn">X</div>
+    <div class="firstRowBothColumn">XXX XX XXX</div>
+</div>
+
+<script>
+function testGridColumnsValues(id, computedColumnValue)
+{
+    shouldBeEqualToString("window.getComputedStyle(" + id + ", '').getPropertyValue('-webkit-grid-template-columns')", computedColumnValue);
+}
+
+description('This test checks that content sized tracks are initialized using non-spanning grid items.');
+
+testGridColumnsValues("gridAutoAndAuto", "10px 90px");
+testGridColumnsValues("gridAutoAndAutoReversed", "90px 10px");
+testGridColumnsValues("gridFixedMinContentFixedMaxContent", "50px 50px");
+testGridColumnsValues("gridFixedMinContentFixedMaxContentTwoEmptyChildren", "50px 50px");
+testGridColumnsValues("gridFixedMinContentFixedMaxContentFixedSizeChild", "60px 40px");
+testGridColumnsValues("gridMaxContentAndAuto", "80px 20px");
+testGridColumnsValues("gridMaxContentAndAutoReversed", "90px 10px");
+testGridColumnsValues("gridMinContentAndAuto", "10px 90px");
+testGridColumnsValues("gridMinContentAndAutoReversed", "20px 80px");
+</script>
+</body>
index 48a0369..d1b1895 100644 (file)
@@ -1,3 +1,66 @@
+2015-01-23  Sergio Villar Senin  <svillar@igalia.com>
+
+        [CSS Grid Layout] Invalid initialization of track sizes with non spanning grid items
+        https://bugs.webkit.org/show_bug.cgi?id=140763
+
+        Reviewed by Antti Koivisto.
+
+        Content sized tracks with non-spanning grid items were not
+        properly sized because the growth limit was sometimes infinity
+        (-1) after calling resolveContentBasedTrackSizingFunctions() when
+        it should not. This patch adds an special initialization phase for
+        non-spanning grid items as the new track sizing algorithm
+        describes.
+
+        Granted, that was handled in the old algorithm in
+        distributeSpaceToTracks() as a special case. The problem is that
+        it regressed after the optimization added in r173868 because that
+        method is no longer called when the space to distribute is 0.
+
+        That's why we could fix this by allowing calls to
+        distributeSpaceToTracks() with spaceToDistribute>=0 but by fixing
+        it with an explicit initialization our implementation becomes
+        closer to the new algorithm and the initialization is now explicit
+        in the code instead of a side effect of calling
+        distributeSpaceToTracks() with no space to be distributed. It also
+        brings a slight performance improvement as we save sorts and hash
+        lookups.
+
+        I also took the change to add caching to several GridTrackSize
+        methods that were hot on the profiler (each one accounted for ~1%
+        of the total time, now they account for ~0.3% each).
+
+        Test: fast/css-grid-layout/grid-initialize-span-one-items.html
+
+        * rendering/RenderGrid.cpp:
+        (WebCore::GridItemWithSpan::span): New helper method for ASSERTs.
+        (WebCore::RenderGrid::resolveContentBasedTrackSizingFunctions):
+        Exclude non spanning grid items from the calls to
+        resolveContentBasedTrackSizingFunctionsForItems().
+        (WebCore::RenderGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems):
+        New method to resolve track sizes only using non-spanning grid
+        items.
+        (WebCore::RenderGrid::resolveContentBasedTrackSizingFunctionsForItems):
+        Ensure that it isn't called for non-spanning grid items.
+        * rendering/RenderGrid.h:
+        * rendering/style/GridTrackSize.h:
+        (WebCore::GridTrackSize::GridTrackSize): Cache return values.
+        (WebCore::GridTrackSize::setLength): Ditto.
+        (WebCore::GridTrackSize::setMinMax): Ditto.
+        (WebCore::GridTrackSize::cacheMinMaxTrackBreadthTypes): New method
+        that caches the return values for hasXXXTrackBreadth() methods.
+        (WebCore::GridTrackSize::hasMinOrMaxContentMinTrackBreadth): Use
+        the cached return value.
+        (WebCore::GridTrackSize::hasMaxContentMaxTrackBreadth): Ditto.
+        (WebCore::GridTrackSize::hasMinContentMaxTrackBreadth): Ditto.
+        (WebCore::GridTrackSize::hasMinOrMaxContentMaxTrackBreadth): Ditto.
+        (WebCore::GridTrackSize::hasMaxContentMinTrackBreadth): Ditto.
+        (WebCore::GridTrackSize::hasMinContentMinTrackBreadth): Ditto.
+        (WebCore::GridTrackSize::hasMinContentMinTrackBreadthAndMinOrMaxContentMaxTrackBreadth):
+        Ditto.
+        (WebCore::GridTrackSize::hasMaxContentMinTrackBreadthAndMaxContentMaxTrackBreadth):
+        Ditto.
+
 2015-02-12  Zan Dobersek  <zdobersek@igalia.com>
 
         Remove the USE(ACCELERATED_COMPOSITING) guard from the
index 5b93f33..56e78b7 100644 (file)
@@ -584,6 +584,9 @@ public:
 
     RenderBox& gridItem() const { return m_gridItem; }
     GridCoordinate coordinate() const { return m_coordinate; }
+#if !ASSERT_DISABLED
+    size_t span() const { return m_span; }
+#endif
 
     bool operator<(const GridItemWithSpan other) const
     {
@@ -619,12 +622,14 @@ void RenderGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio
     HashSet<RenderBox*> itemsSet;
     for (auto trackIndex : sizingData.contentSizedTracksIndex) {
         GridIterator iterator(m_grid, direction, trackIndex);
+        GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[trackIndex] : sizingData.rowTracks[trackIndex];
 
         while (RenderBox* gridItem = iterator.nextGridItem()) {
             if (itemsSet.add(gridItem).isNewEntry) {
                 const GridCoordinate& coordinate = cachedGridCoordinate(*gridItem);
-                // We should not include items spanning more than one track that span tracks with flexible sizing functions.
-                if (integerSpanForDirection(coordinate, direction) == 1 || !spanningItemCrossesFlexibleSizedTracks(coordinate, direction))
+                if (integerSpanForDirection(coordinate, direction) == 1)
+                    resolveContentBasedTrackSizingFunctionsForNonSpanningItems(direction, coordinate, *gridItem, track, sizingData.columnTracks);
+                else if (!spanningItemCrossesFlexibleSizedTracks(coordinate, direction))
                     sizingData.itemsSortedByIncreasingSpan.append(GridItemWithSpan(*gridItem, coordinate, direction));
             }
         }
@@ -645,8 +650,25 @@ void RenderGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio
     }
 }
 
+void RenderGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems(GridTrackSizingDirection direction, const GridCoordinate& coordinate, RenderBox& gridItem, GridTrack& track, Vector<GridTrack>& columnTracks)
+{
+    const GridResolvedPosition trackPosition = (direction == ForColumns) ? coordinate.columns.resolvedInitialPosition : coordinate.rows.resolvedInitialPosition;
+    GridTrackSize trackSize = gridTrackSize(direction, trackPosition.toInt());
+
+    if (trackSize.hasMinContentMinTrackBreadth())
+        track.setBaseSize(std::max(track.baseSize(), minContentForChild(gridItem, direction, columnTracks)));
+    else if (trackSize.hasMaxContentMinTrackBreadth())
+        track.setBaseSize(std::max(track.baseSize(), maxContentForChild(gridItem, direction, columnTracks)));
+
+    if (trackSize.hasMinContentMaxTrackBreadth())
+        track.setGrowthLimit(std::max(track.growthLimit(), minContentForChild(gridItem, direction, columnTracks)));
+    else if (trackSize.hasMaxContentMaxTrackBreadth())
+        track.setGrowthLimit(std::max(track.growthLimit(), maxContentForChild(gridItem, direction, columnTracks)));
+}
+
 void RenderGrid::resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizingDirection direction, GridSizingData& sizingData, GridItemWithSpan& gridItemWithSpan, FilterFunction filterFunction, SizingFunction sizingFunction, AccumulatorGetter trackGetter, AccumulatorGrowFunction trackGrowthFunction, FilterFunction growAboveMaxBreadthFilterFunction)
 {
+    ASSERT(gridItemWithSpan.span() > 1);
     const GridCoordinate& coordinate = gridItemWithSpan.coordinate();
     const GridResolvedPosition initialTrackPosition = (direction == ForColumns) ? coordinate.columns.resolvedInitialPosition : coordinate.rows.resolvedInitialPosition;
     const GridResolvedPosition finalTrackPosition = (direction == ForColumns) ? coordinate.columns.resolvedFinalPosition : coordinate.rows.resolvedFinalPosition;
index d886c72..11e4f12 100644 (file)
@@ -91,6 +91,7 @@ private:
     typedef const LayoutUnit& (GridTrack::* AccumulatorGetter)() const;
     typedef void (GridTrack::* AccumulatorGrowFunction)(LayoutUnit);
     typedef bool (GridTrackSize::* FilterFunction)() const;
+    void resolveContentBasedTrackSizingFunctionsForNonSpanningItems(GridTrackSizingDirection, const GridCoordinate&, RenderBox& gridItem, GridTrack&, Vector<GridTrack>& columnTracks);
     void resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizingDirection, GridSizingData&, GridItemWithSpan&, FilterFunction, SizingFunction, AccumulatorGetter, AccumulatorGrowFunction, FilterFunction growAboveMaxBreadthFilterFunction = nullptr);
     void distributeSpaceToTracks(Vector<GridTrack*>&, Vector<unsigned>* growAboveMaxBreadthTrackIndexes, AccumulatorGetter, AccumulatorGrowFunction, GridSizingData&, LayoutUnit& availableLogicalSpace);
 
index 3e33524..ddff6cc 100644 (file)
@@ -46,15 +46,16 @@ enum GridTrackSizeType {
 class GridTrackSize {
 public:
     GridTrackSize(LengthType type = Undefined)
-        : m_type(LengthTrackSizing)
-        , m_minTrackBreadth(type)
-        , m_maxTrackBreadth(type)
     {
+        setLength(GridLength(Length(type)));
     }
 
     GridTrackSize(const GridLength& minTrackBreadth, const GridLength& maxTrackBreadth)
+        : m_type(MinMaxTrackSizing)
+        , m_minTrackBreadth(minTrackBreadth)
+        , m_maxTrackBreadth(maxTrackBreadth)
     {
-        setMinMax(minTrackBreadth, maxTrackBreadth);
+        cacheMinMaxTrackBreadthTypes();
     }
 
     const GridLength& length() const
@@ -71,6 +72,7 @@ public:
         m_type = LengthTrackSizing;
         m_minTrackBreadth = length;
         m_maxTrackBreadth = length;
+        cacheMinMaxTrackBreadthTypes();
     }
 
     const GridLength& minTrackBreadth() const
@@ -98,6 +100,7 @@ public:
         m_type = MinMaxTrackSizing;
         m_minTrackBreadth = minTrackBreadth;
         m_maxTrackBreadth = maxTrackBreadth;
+        cacheMinMaxTrackBreadthTypes();
     }
 
     GridTrackSizeType type() const { return m_type; }
@@ -111,18 +114,31 @@ public:
         return m_type == other.m_type && m_minTrackBreadth == other.m_minTrackBreadth && m_maxTrackBreadth == other.m_maxTrackBreadth;
     }
 
-    bool hasMinOrMaxContentMinTrackBreadth() const { return minTrackBreadth().isLength() && (minTrackBreadth().length().isMinContent() || minTrackBreadth().length().isMaxContent()); }
-    bool hasMaxContentMinTrackBreadth() const { return minTrackBreadth().isLength() && minTrackBreadth().length().isMaxContent(); }
-    bool hasMinOrMaxContentMaxTrackBreadth() const { return maxTrackBreadth().isLength() && (maxTrackBreadth().length().isMinContent() || maxTrackBreadth().length().isMaxContent()); }
-    bool hasMaxContentMaxTrackBreadth() const { return maxTrackBreadth().isLength() && maxTrackBreadth().length().isMaxContent(); }
-    bool hasMinContentMinTrackBreadthAndMinOrMaxContentMaxTrackBreadth() const { return minTrackBreadth().isLength() && minTrackBreadth().length().isMinContent() && hasMinOrMaxContentMaxTrackBreadth(); }
-    bool hasMaxContentMinTrackBreadthAndMaxContentMaxTrackBreadth() const { return hasMaxContentMinTrackBreadth() && hasMaxContentMaxTrackBreadth(); }
+    void cacheMinMaxTrackBreadthTypes()
+    {
+        m_minTrackBreadthIsMinContent = minTrackBreadth().isLength() && minTrackBreadth().length().isMinContent();
+        m_minTrackBreadthIsMaxContent = minTrackBreadth().isLength() && minTrackBreadth().length().isMaxContent();
+        m_maxTrackBreadthIsMaxContent = maxTrackBreadth().isLength() && maxTrackBreadth().length().isMaxContent();
+        m_maxTrackBreadthIsMinContent = maxTrackBreadth().isLength() && maxTrackBreadth().length().isMinContent();
+    }
 
+    bool hasMinOrMaxContentMinTrackBreadth() const { return m_minTrackBreadthIsMaxContent || m_minTrackBreadthIsMinContent; }
+    bool hasMaxContentMaxTrackBreadth() const { return m_maxTrackBreadthIsMaxContent; }
+    bool hasMinContentMaxTrackBreadth() const { return m_maxTrackBreadthIsMinContent; }
+    bool hasMinOrMaxContentMaxTrackBreadth() const { return m_maxTrackBreadthIsMaxContent || m_maxTrackBreadthIsMinContent; }
+    bool hasMaxContentMinTrackBreadth() const { return m_minTrackBreadthIsMaxContent; }
+    bool hasMinContentMinTrackBreadth() const { return m_minTrackBreadthIsMinContent; }
+    bool hasMinContentMinTrackBreadthAndMinOrMaxContentMaxTrackBreadth() const { return m_minTrackBreadthIsMinContent && hasMinOrMaxContentMaxTrackBreadth(); }
+    bool hasMaxContentMinTrackBreadthAndMaxContentMaxTrackBreadth() const { return m_minTrackBreadthIsMaxContent && m_maxTrackBreadthIsMaxContent; }
 
 private:
     GridTrackSizeType m_type;
     GridLength m_minTrackBreadth;
     GridLength m_maxTrackBreadth;
+    bool m_minTrackBreadthIsMaxContent;
+    bool m_minTrackBreadthIsMinContent;
+    bool m_maxTrackBreadthIsMaxContent;
+    bool m_maxTrackBreadthIsMinContent;
 };
 
 } // namespace WebCore