Title: [136588] trunk
Revision
136588
Author
jchaffr...@webkit.org
Date
2012-12-04 16:25:44 -0800 (Tue, 04 Dec 2012)

Log Message

[CSS Grid Layout] Implement CSS parsing and handling for <track-minmax>
https://bugs.webkit.org/show_bug.cgi?id=103799

Reviewed by Tony Chang.

Source/WebCore:

This change adds support for:
<track-minmax> => minmax( <track-breadth> , <track-breadth> ) | auto | <track-breadth>
(note that we already supported auto | <track-breadth>).

The change is mostly mechanical, the only newness is that GridTrackSize was updated to
hold 2 Lengths internally and we map the single Length case to 2 by duplicating the value
as this matches the rendering algorithm in the spec.

Tests: fast/css-grid-layout/grid-columns-rows-get-set-multiple.html
       fast/css-grid-layout/resources/grid-columns-rows-get-set-multiple.js

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::valueForGridTrackBreadth):
Changed the function to do the conversion of one track breadth (one Length).
This was forgotten in the preparatory change in bug 103703.

(WebCore::valueForGridTrackMinMax):
Convert the value back using valueForGridTrackBreadth.

* css/CSSFunctionValue.cpp:
(WebCore::CSSFunctionValue::CSSFunctionValue):
* css/CSSFunctionValue.h:
(WebCore::CSSFunctionValue::create):
(CSSFunctionValue):
Added a new constructor. This enables us to return minmax(..., ...) when queried
from _javascript_. I couldn't find a better way to serialize inside CSSComputedStyleDeclaration
so that it properly match the function output.

* css/CSSParser.cpp:
(WebCore::CSSParser::parseGridTrackMinMax):
Added parsing for the new syntax. We convert the 2 values into a Pair if we manage to
parse both values correctly.

* css/StyleResolver.cpp:
(WebCore::createGridTrackMinMax):
Updated to handle a Pair - for minmax - and set the 2 values on GridTrackSize.

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::computedUsedBreadthOfGridTracks):
Updated to check the style. For now, we don't handle minmax values.

* rendering/style/GridTrackSize.h:
(WebCore::GridTrackSize::GridTrackSize):
(WebCore::GridTrackSize::length):
(WebCore::GridTrackSize::setLength):
(WebCore::GridTrackSize::minTrackBreadth):
(WebCore::GridTrackSize::maxTrackBreadth):
(WebCore::GridTrackSize::setMinMax):
(WebCore::GridTrackSize::operator==):
Updated the class to handle minmax values. This means that we now always store
2 values (the <length> case being a subset of minmax, however we kept the distinction
to be able to reconstruct a <length> for getComputedStyle).

LayoutTests:

* fast/css-grid-layout/grid-columns-rows-get-set-expected.txt:
* fast/css-grid-layout/grid-columns-rows-get-set-multiple-expected.txt:
* fast/css-grid-layout/grid-columns-rows-get-set-multiple.html:
* fast/css-grid-layout/grid-columns-rows-get-set.html:
* fast/css-grid-layout/resources/grid-columns-rows-get-set-multiple.js:
* fast/css-grid-layout/resources/grid-columns-rows-get-set.js:
Extended the following tests to cover the new grammar.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (136587 => 136588)


--- trunk/LayoutTests/ChangeLog	2012-12-05 00:06:02 UTC (rev 136587)
+++ trunk/LayoutTests/ChangeLog	2012-12-05 00:25:44 UTC (rev 136588)
@@ -1,3 +1,18 @@
+2012-12-04  Julien Chaffraix  <jchaffr...@webkit.org>
+
+        [CSS Grid Layout] Implement CSS parsing and handling for <track-minmax>
+        https://bugs.webkit.org/show_bug.cgi?id=103799
+
+        Reviewed by Tony Chang.
+
+        * fast/css-grid-layout/grid-columns-rows-get-set-expected.txt:
+        * fast/css-grid-layout/grid-columns-rows-get-set-multiple-expected.txt:
+        * fast/css-grid-layout/grid-columns-rows-get-set-multiple.html:
+        * fast/css-grid-layout/grid-columns-rows-get-set.html:
+        * fast/css-grid-layout/resources/grid-columns-rows-get-set-multiple.js:
+        * fast/css-grid-layout/resources/grid-columns-rows-get-set.js:
+        Extended the following tests to cover the new grammar.
+
 2012-12-04  Florin Malita  <fmal...@chromium.org>
 
         Unreviewed gardening - add missing js-test-pre.js include to avoid use-href-update-crash.svg

Modified: trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-expected.txt (136587 => 136588)


--- trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-expected.txt	2012-12-05 00:06:02 UTC (rev 136587)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-expected.txt	2012-12-05 00:25:44 UTC (rev 136588)
@@ -16,6 +16,9 @@
 PASS getComputedStyle(gridWithEMElement, '').getPropertyValue('-webkit-grid-rows') is '150px'
 PASS getComputedStyle(gridWithViewPortPercentageElement, '').getPropertyValue('-webkit-grid-columns') is '64px'
 PASS getComputedStyle(gridWithViewPortPercentageElement, '').getPropertyValue('-webkit-grid-rows') is '60px'
+PASS getComputedStyle(gridWithMinMax, '').getPropertyValue('-webkit-grid-columns') is 'minmax(10%, 15px)'
+PASS getComputedStyle(gridWithMinMax, '').getPropertyValue('-webkit-grid-rows') is 'minmax(20px, 50%)'
+
 Test getting wrong values for -webkit-grid-columns and -webkit-grid-rows through CSS (they should resolve to the default: 'none')
 PASS getComputedStyle(gridWithFitContentElement, '').getPropertyValue('-webkit-grid-columns') is 'none'
 PASS getComputedStyle(gridWithFitContentElement, '').getPropertyValue('-webkit-grid-rows') is 'none'
@@ -35,7 +38,21 @@
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is 'auto'
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is '80px'
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is '150px'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is 'minmax(55%, 45px)'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is 'minmax(30px, 40%)'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is 'minmax(220px, 48px)'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is 'minmax(80px, 50px)'
 
+Test setting grid-columns and grid-rows to bad minmax value through JS
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is 'none'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is 'none'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is 'none'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is 'none'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is 'none'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is 'none'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is 'none'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is 'none'
+
 Test setting grid-columns and grid-rows back to 'none' through JS
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is '18px'
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is '66px'

Modified: trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-multiple-expected.txt (136587 => 136588)


--- trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-multiple-expected.txt	2012-12-05 00:06:02 UTC (rev 136587)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-multiple-expected.txt	2012-12-05 00:25:44 UTC (rev 136588)
@@ -18,6 +18,8 @@
 PASS getComputedStyle(gridWithPercentAndViewportPercent, '').getPropertyValue('-webkit-grid-rows') is '35% 168px'
 PASS getComputedStyle(gridWithFitContentAndFitAvailable, '').getPropertyValue('-webkit-grid-columns') is 'none'
 PASS getComputedStyle(gridWithFitContentAndFitAvailable, '').getPropertyValue('-webkit-grid-rows') is 'none'
+PASS getComputedStyle(gridWithMinMaxAndFixed, '').getPropertyValue('-webkit-grid-columns') is 'minmax(45px, 30%) 15px'
+PASS getComputedStyle(gridWithMinMaxAndFixed, '').getPropertyValue('-webkit-grid-rows') is '120px minmax(35%, 10px)'
 
 Test the initial value
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is 'none'
@@ -32,6 +34,8 @@
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is 'auto auto'
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is 'auto 160px 22px'
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is '56% 100px auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is '160px minmax(16px, 20px)'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is 'minmax(10%, 15%) auto'
 
 Test getting wrong values set from CSS
 PASS getComputedStyle(gridWithNoneAndAuto, '').getPropertyValue('-webkit-grid-columns') is 'none'
@@ -54,6 +58,8 @@
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is '5% 510px'
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is 'none'
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is 'none'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is 'none'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is 'none'
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-multiple.html (136587 => 136588)


--- trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-multiple.html	2012-12-05 00:06:02 UTC (rev 136587)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-multiple.html	2012-12-05 00:25:44 UTC (rev 136588)
@@ -54,6 +54,12 @@
     -webkit-grid-columns: -webkit-content-available;
     -webkit-grid-rows: -webkit-fitcontent -webkit-fit-available;
 }
+.gridWithMinMaxAndFixed {
+    display: -webkit-grid;
+    -webkit-grid-columns: minmax(45px, 30%) 15px;
+    -webkit-grid-rows: 12em minmax(35%, 10px);
+    font: 10px Ahem;
+}
 </style>
 <script src=""
 </head>
@@ -67,6 +73,7 @@
 <div class="gridWithThreeItems" id="gridWithThreeItems"></div>
 <div class="gridWithPercentAndViewportPercent" id="gridWithPercentAndViewportPercent"></div>
 <div class="gridWithFitContentAndFitAvailable" id="gridWithFitContentAndFitAvailable"></div>
+<div class="gridWithMinMaxAndFixed" id="gridWithMinMaxAndFixed"></div>
 <script src=""
 <script src=""
 </body>

Modified: trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set.html (136587 => 136588)


--- trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set.html	2012-12-05 00:06:02 UTC (rev 136587)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set.html	2012-12-05 00:25:44 UTC (rev 136588)
@@ -42,6 +42,10 @@
     -webkit-grid-columns: -webkit-fit-available;
     -webkit-grid-rows: -webkit-fit-available;
 }
+.gridWithMinMax {
+    -webkit-grid-columns: minmax(10%, 15px);
+    -webkit-grid-rows: minmax(20px, 50%);
+}
 </style>
 <script src=""
 </head>
@@ -54,6 +58,7 @@
 <div class="grid gridWithViewPortPercentage" id="gridWithViewPortPercentageElement"></div>
 <div class="grid gridWithFitContent" id="gridWithFitContentElement"></div>
 <div class="grid gridWithFitAvailable" id="gridWithFitAvailableElement"></div>
+<div class="grid gridWithMinMax" id="gridWithMinMax"></div>
 <script src=""
 <script src=""
 </body>

Modified: trunk/LayoutTests/fast/css-grid-layout/resources/grid-columns-rows-get-set-multiple.js (136587 => 136588)


--- trunk/LayoutTests/fast/css-grid-layout/resources/grid-columns-rows-get-set-multiple.js	2012-12-05 00:06:02 UTC (rev 136587)
+++ trunk/LayoutTests/fast/css-grid-layout/resources/grid-columns-rows-get-set-multiple.js	2012-12-05 00:25:44 UTC (rev 136588)
@@ -29,6 +29,10 @@
 shouldBe("getComputedStyle(gridWithFitContentAndFitAvailable, '').getPropertyValue('-webkit-grid-columns')", "'none'");
 shouldBe("getComputedStyle(gridWithFitContentAndFitAvailable, '').getPropertyValue('-webkit-grid-rows')", "'none'");
 
+var gridWithMinMaxAndFixed = document.getElementById("gridWithMinMaxAndFixed");
+shouldBe("getComputedStyle(gridWithMinMaxAndFixed, '').getPropertyValue('-webkit-grid-columns')", "'minmax(45px, 30%) 15px'");
+shouldBe("getComputedStyle(gridWithMinMaxAndFixed, '').getPropertyValue('-webkit-grid-rows')", "'120px minmax(35%, 10px)'");
+
 debug("");
 debug("Test the initial value");
 var element = document.createElement("div");
@@ -65,6 +69,14 @@
 shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'auto 160px 22px'");
 shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'56% 100px auto'");
 
+element = document.createElement("div");
+document.body.appendChild(element);
+element.style.font = "10px Ahem";
+element.style.webkitGridColumns = "16em minmax(16px, 20px)";
+element.style.webkitGridRows = "minmax(10%, 15%) auto";
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'160px minmax(16px, 20px)'");
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'minmax(10%, 15%) auto'");
+
 debug("");
 debug("Test getting wrong values set from CSS");
 var gridWithNoneAndAuto = document.getElementById("gridWithNoneAndAuto");
@@ -125,3 +137,10 @@
 element.style.webkitGridRows = "-webkit-fit-available -webkit-fit-available";
 shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'none'");
 shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'none'");
+
+element = document.createElement("div");
+document.body.appendChild(element);
+element.style.webkitGridColumns = "auto minmax(16px, auto)";
+element.style.webkitGridRows = "minmax(auto, 15%) 10vw";
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'none'");
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'none'");

Modified: trunk/LayoutTests/fast/css-grid-layout/resources/grid-columns-rows-get-set.js (136587 => 136588)


--- trunk/LayoutTests/fast/css-grid-layout/resources/grid-columns-rows-get-set.js	2012-12-05 00:06:02 UTC (rev 136587)
+++ trunk/LayoutTests/fast/css-grid-layout/resources/grid-columns-rows-get-set.js	2012-12-05 00:25:44 UTC (rev 136588)
@@ -25,6 +25,11 @@
 shouldBe("getComputedStyle(gridWithViewPortPercentageElement, '').getPropertyValue('-webkit-grid-columns')", "'64px'");
 shouldBe("getComputedStyle(gridWithViewPortPercentageElement, '').getPropertyValue('-webkit-grid-rows')", "'60px'");
 
+var gridWithMinMax = document.getElementById("gridWithMinMax");
+shouldBe("getComputedStyle(gridWithMinMax, '').getPropertyValue('-webkit-grid-columns')", "'minmax(10%, 15px)'");
+shouldBe("getComputedStyle(gridWithMinMax, '').getPropertyValue('-webkit-grid-rows')", "'minmax(20px, 50%)'");
+
+debug("");
 debug("Test getting wrong values for -webkit-grid-columns and -webkit-grid-rows through CSS (they should resolve to the default: 'none')");
 var gridWithFitContentElement = document.getElementById("gridWithFitContentElement");
 shouldBe("getComputedStyle(gridWithFitContentElement, '').getPropertyValue('-webkit-grid-columns')", "'none'");
@@ -69,7 +74,59 @@
 shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'80px'");
 shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'150px'");
 
+element = document.createElement("div");
+document.body.appendChild(element);
+element.style.webkitGridColumns = "minmax(55%, 45px)";
+element.style.webkitGridRows = "minmax(30px, 40%)";
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'minmax(55%, 45px)'");
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'minmax(30px, 40%)'");
+
+element = document.createElement("div");
+document.body.appendChild(element);
+element.style.font = "10px Ahem";
+element.style.webkitGridColumns = "minmax(22em, 8vh)";
+element.style.webkitGridRows = "minmax(10vw, 5em)";
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'minmax(220px, 48px)'");
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'minmax(80px, 50px)'");
+
 debug("");
+debug("Test setting grid-columns and grid-rows to bad minmax value through JS");
+element = document.createElement("div");
+document.body.appendChild(element);
+// No comma.
+element.style.webkitGridColumns = "minmax(10px 20px)";
+// Only 1 argument provided.
+element.style.webkitGridRows = "minmax(10px)";
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'none'");
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'none'");
+
+element = document.createElement("div");
+document.body.appendChild(element);
+// Nested minmax.
+element.style.webkitGridColumns = "minmax(minmax(10px, 20px), 20px)";
+// Only 2 arguments are allowed.
+element.style.webkitGridRows = "minmax(10px, 20px, 30px)";
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'none'");
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'none'");
+
+element = document.createElement("div");
+document.body.appendChild(element);
+// No breadth value.
+element.style.webkitGridColumns = "minmax()";
+// No comma.
+element.style.webkitGridRows = "minmax(30px 30% 30em)";
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'none'");
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'none'");
+
+element = document.createElement("div");
+document.body.appendChild(element);
+// Auto is not allowed inside minmax.
+element.style.webkitGridColumns = "minmax(auto, 8vh)";
+element.style.webkitGridRows = "minmax(10vw, auto)";
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'none'");
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'none'");
+
+debug("");
 debug("Test setting grid-columns and grid-rows back to 'none' through JS");
 element.style.webkitGridColumns = "18px";
 element.style.webkitGridRows = "66px";

Modified: trunk/Source/WebCore/ChangeLog (136587 => 136588)


--- trunk/Source/WebCore/ChangeLog	2012-12-05 00:06:02 UTC (rev 136587)
+++ trunk/Source/WebCore/ChangeLog	2012-12-05 00:25:44 UTC (rev 136588)
@@ -1,3 +1,63 @@
+2012-12-04  Julien Chaffraix  <jchaffr...@webkit.org>
+
+        [CSS Grid Layout] Implement CSS parsing and handling for <track-minmax>
+        https://bugs.webkit.org/show_bug.cgi?id=103799
+
+        Reviewed by Tony Chang.
+
+        This change adds support for:
+        <track-minmax> => minmax( <track-breadth> , <track-breadth> ) | auto | <track-breadth>
+        (note that we already supported auto | <track-breadth>).
+
+        The change is mostly mechanical, the only newness is that GridTrackSize was updated to
+        hold 2 Lengths internally and we map the single Length case to 2 by duplicating the value
+        as this matches the rendering algorithm in the spec.
+
+        Tests: fast/css-grid-layout/grid-columns-rows-get-set-multiple.html
+               fast/css-grid-layout/resources/grid-columns-rows-get-set-multiple.js
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::valueForGridTrackBreadth):
+        Changed the function to do the conversion of one track breadth (one Length).
+        This was forgotten in the preparatory change in bug 103703.
+
+        (WebCore::valueForGridTrackMinMax):
+        Convert the value back using valueForGridTrackBreadth.
+
+        * css/CSSFunctionValue.cpp:
+        (WebCore::CSSFunctionValue::CSSFunctionValue):
+        * css/CSSFunctionValue.h:
+        (WebCore::CSSFunctionValue::create):
+        (CSSFunctionValue):
+        Added a new constructor. This enables us to return minmax(..., ...) when queried
+        from _javascript_. I couldn't find a better way to serialize inside CSSComputedStyleDeclaration
+        so that it properly match the function output.
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseGridTrackMinMax):
+        Added parsing for the new syntax. We convert the 2 values into a Pair if we manage to
+        parse both values correctly.
+
+        * css/StyleResolver.cpp:
+        (WebCore::createGridTrackMinMax):
+        Updated to handle a Pair - for minmax - and set the 2 values on GridTrackSize.
+
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::computedUsedBreadthOfGridTracks):
+        Updated to check the style. For now, we don't handle minmax values.
+
+        * rendering/style/GridTrackSize.h:
+        (WebCore::GridTrackSize::GridTrackSize):
+        (WebCore::GridTrackSize::length):
+        (WebCore::GridTrackSize::setLength):
+        (WebCore::GridTrackSize::minTrackBreadth):
+        (WebCore::GridTrackSize::maxTrackBreadth):
+        (WebCore::GridTrackSize::setMinMax):
+        (WebCore::GridTrackSize::operator==):
+        Updated the class to handle minmax values. This means that we now always store
+        2 values (the <length> case being a subset of minmax, however we kept the distinction
+        to be able to reconstruct a <length> for getComputedStyle).
+
 2012-12-04  Elliott Sprehn  <espr...@chromium.org>
 
         parser* methods in ContainerNode should not support DocumentFragment

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (136587 => 136588)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2012-12-05 00:06:02 UTC (rev 136587)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2012-12-05 00:25:44 UTC (rev 136588)
@@ -30,6 +30,7 @@
 #include "CSSAspectRatioValue.h"
 #include "CSSBasicShapes.h"
 #include "CSSBorderImage.h"
+#include "CSSFunctionValue.h"
 #include "CSSLineBoxContainValue.h"
 #include "CSSParser.h"
 #include "CSSPrimitiveValue.h"
@@ -999,18 +1000,28 @@
 }
 #endif
 
-static PassRefPtr<CSSValue> valueForGridTrackBreadth(const GridTrackSize& trackSize, const RenderStyle* style, RenderView *renderView)
+static PassRefPtr<CSSValue> valueForGridTrackBreadth(const Length& trackBreadth, const RenderStyle* style, RenderView *renderView)
 {
-    if (trackSize.length().isAuto())
+    if (trackBreadth.isAuto())
         return cssValuePool().createIdentifierValue(CSSValueAuto);
-    if (trackSize.length().isViewportPercentage())
-        return zoomAdjustedPixelValue(valueForLength(trackSize.length(), 0, renderView), style);
-    return zoomAdjustedPixelValueForLength(trackSize.length(), style);
+    if (trackBreadth.isViewportPercentage())
+        return zoomAdjustedPixelValue(valueForLength(trackBreadth, 0, renderView), style);
+    return zoomAdjustedPixelValueForLength(trackBreadth, style);
 }
 
 static PassRefPtr<CSSValue> valueForGridTrackMinMax(const GridTrackSize& trackSize, const RenderStyle* style, RenderView* renderView)
 {
-    return valueForGridTrackBreadth(trackSize, style, renderView);
+    switch (trackSize.type()) {
+    case LengthTrackSizing:
+        return valueForGridTrackBreadth(trackSize.length(), style, renderView);
+    case MinMaxTrackSizing:
+        RefPtr<CSSValueList> minMaxTrackBreadths = CSSValueList::createCommaSeparated();
+        minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.minTrackBreadth(), style, renderView));
+        minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.maxTrackBreadth(), style, renderView));
+        return CSSFunctionValue::create("minmax(", minMaxTrackBreadths);
+    }
+    ASSERT_NOT_REACHED();
+    return 0;
 }
 
 static PassRefPtr<CSSValue> valueForGridTrackGroup(const Vector<GridTrackSize>& trackSizes, const RenderStyle* style, RenderView* renderView)

Modified: trunk/Source/WebCore/css/CSSFunctionValue.cpp (136587 => 136588)


--- trunk/Source/WebCore/css/CSSFunctionValue.cpp	2012-12-05 00:06:02 UTC (rev 136587)
+++ trunk/Source/WebCore/css/CSSFunctionValue.cpp	2012-12-05 00:25:44 UTC (rev 136588)
@@ -42,6 +42,13 @@
         m_args = CSSValueList::createFromParserValueList(function->args.get());
 }
 
+CSSFunctionValue::CSSFunctionValue(String name, PassRefPtr<CSSValueList> args)
+    : CSSValue(FunctionClass)
+    , m_name(name)
+    , m_args(args)
+{
+}
+
 String CSSFunctionValue::customCssText() const
 {
     StringBuilder result;

Modified: trunk/Source/WebCore/css/CSSFunctionValue.h (136587 => 136588)


--- trunk/Source/WebCore/css/CSSFunctionValue.h	2012-12-05 00:06:02 UTC (rev 136587)
+++ trunk/Source/WebCore/css/CSSFunctionValue.h	2012-12-05 00:25:44 UTC (rev 136588)
@@ -40,12 +40,18 @@
         return adoptRef(new CSSFunctionValue(function));
     }
 
+    static PassRefPtr<CSSFunctionValue> create(String name, PassRefPtr<CSSValueList> args)
+    {
+        return adoptRef(new CSSFunctionValue(name, args));
+    }
+
     String customCssText() const;
 
     void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
 
 private:
     explicit CSSFunctionValue(CSSParserFunction*);
+    CSSFunctionValue(String, PassRefPtr<CSSValueList>);
 
     String m_name;
     RefPtr<CSSValueList> m_args;

Modified: trunk/Source/WebCore/css/CSSParser.cpp (136587 => 136588)


--- trunk/Source/WebCore/css/CSSParser.cpp	2012-12-05 00:06:02 UTC (rev 136587)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2012-12-05 00:25:44 UTC (rev 136588)
@@ -4537,11 +4537,28 @@
 {
     CSSParserValue* currentValue = m_valueList->current();
     if (currentValue->id == CSSValueAuto) {
-        RefPtr<CSSPrimitiveValue> autoValue = cssValuePool().createIdentifierValue(CSSValueAuto);
-        values->append(autoValue.release());
+        values->append(cssValuePool().createIdentifierValue(CSSValueAuto));
         return true;
     }
 
+    if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase(currentValue->function->name, "minmax(")) {
+        // The spec defines the following grammar: minmax( <track-breadth> , <track-breadth> )
+        CSSParserValueList* arguments = currentValue->function->args.get();
+        if (!arguments || arguments->size() != 3 || !isComma(arguments->valueAt(1)))
+            return false;
+
+        RefPtr<CSSPrimitiveValue> minTrackBreadth = parseGridBreadth(arguments->valueAt(0));
+        if (!minTrackBreadth)
+            return false;
+
+        RefPtr<CSSPrimitiveValue> maxTrackBreadth = parseGridBreadth(arguments->valueAt(2));
+        if (!maxTrackBreadth)
+            return false;
+
+        values->append(createPrimitiveValuePair(minTrackBreadth, maxTrackBreadth));
+        return true;
+    }
+
     if (PassRefPtr<CSSPrimitiveValue> trackBreadth = parseGridBreadth(currentValue)) {
         values->append(trackBreadth);
         return true;

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (136587 => 136588)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2012-12-05 00:06:02 UTC (rev 136587)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2012-12-05 00:25:44 UTC (rev 136588)
@@ -2688,11 +2688,22 @@
 
 static bool createGridTrackMinMax(CSSPrimitiveValue* primitiveValue, StyleResolver* selector, GridTrackSize& trackSize)
 {
-    Length workingLength;
-    if (!createGridTrackBreadth(primitiveValue, selector, workingLength))
+    Pair* minMaxTrackBreadth = primitiveValue->getPairValue();
+    if (!minMaxTrackBreadth) {
+        Length workingLength;
+        if (!createGridTrackBreadth(primitiveValue, selector, workingLength))
+            return false;
+
+        trackSize.setLength(workingLength);
+        return true;
+    }
+
+    Length minTrackBreadth;
+    Length maxTrackBreadth;
+    if (!createGridTrackBreadth(minMaxTrackBreadth->first(), selector, minTrackBreadth) || !createGridTrackBreadth(minMaxTrackBreadth->second(), selector, maxTrackBreadth))
         return false;
 
-    trackSize.setLength(workingLength);
+    trackSize.setMinMax(minTrackBreadth, maxTrackBreadth);
     return true;
 }
 

Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (136587 => 136588)


--- trunk/Source/WebCore/rendering/RenderGrid.cpp	2012-12-05 00:06:02 UTC (rev 136587)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp	2012-12-05 00:25:44 UTC (rev 136588)
@@ -141,13 +141,21 @@
     const Vector<GridTrackSize>& trackStyles = (direction == ForColumns) ? style()->gridColumns() : style()->gridRows();
     for (size_t i = 0; i < trackStyles.size(); ++i) {
         GridTrack track;
-        Length trackLength = trackStyles[i].length();
-        // FIXME: we stil need to support calc() here (bug 103761)
-        if (trackLength.isFixed() || trackLength.isPercent() || trackLength.isViewportPercentage())
-            track.m_usedBreadth = valueForLength(trackLength, direction == ForColumns ? logicalWidth() : computeContentLogicalHeight(MainOrPreferredSize, style()->logicalHeight()), view());
-        else
+        switch (trackStyles[i].type()) {
+        case LengthTrackSizing: {
+            Length trackLength = trackStyles[i].length();
+            // FIXME: We stil need to support calc() here (bug 103761).
+            if (trackLength.isFixed() || trackLength.isPercent() || trackLength.isViewportPercentage())
+                track.m_usedBreadth = valueForLength(trackLength, direction == ForColumns ? logicalWidth() : computeContentLogicalHeight(MainOrPreferredSize, style()->logicalHeight()), view());
+            else
+                notImplemented();
+
+            break;
+        }
+        case MinMaxTrackSizing:
+            // FIXME: Implement support for minmax track sizing (bug 103311).
             notImplemented();
-
+        }
         tracks.append(track);
     }
 }

Modified: trunk/Source/WebCore/rendering/style/GridTrackSize.h (136587 => 136588)


--- trunk/Source/WebCore/rendering/style/GridTrackSize.h	2012-12-05 00:06:02 UTC (rev 136587)
+++ trunk/Source/WebCore/rendering/style/GridTrackSize.h	2012-12-05 00:25:44 UTC (rev 136588)
@@ -36,40 +36,66 @@
 namespace WebCore {
 
 enum GridTrackSizeType {
-    LengthTrackSizing
+    LengthTrackSizing,
+    MinMaxTrackSizing
 };
 
 class GridTrackSize {
 public:
     GridTrackSize()
         : m_type(LengthTrackSizing)
-        , m_length(Undefined)
+        , m_minTrackBreadth(Undefined)
+        , m_maxTrackBreadth(Undefined)
     {
     }
 
     const Length& length() const
     {
         ASSERT(m_type == LengthTrackSizing);
-        ASSERT(!m_length.isUndefined());
-        return m_length;
+        ASSERT(!m_minTrackBreadth.isUndefined());
+        ASSERT(m_minTrackBreadth == m_maxTrackBreadth);
+        return m_minTrackBreadth;
     }
 
     void setLength(const Length& length)
     {
         m_type = LengthTrackSizing;
-        m_length = length;
+        m_minTrackBreadth = length;
+        m_maxTrackBreadth = length;
     }
 
+    const Length& minTrackBreadth() const
+    {
+        ASSERT(m_type == MinMaxTrackSizing);
+        ASSERT(!m_minTrackBreadth.isUndefined());
+        return m_minTrackBreadth;
+    }
+
+    const Length& maxTrackBreadth() const
+    {
+        ASSERT(m_type == MinMaxTrackSizing);
+        ASSERT(!m_maxTrackBreadth.isUndefined());
+        return m_maxTrackBreadth;
+    }
+
+    void setMinMax(const Length& minTrackBreadth, const Length& maxTrackBreadth)
+    {
+        m_type = MinMaxTrackSizing;
+        m_minTrackBreadth = minTrackBreadth;
+        m_maxTrackBreadth = maxTrackBreadth;
+    }
+
     GridTrackSizeType type() const { return m_type; }
 
     bool operator==(const GridTrackSize& other) const
     {
-        return m_type == other.m_type && m_length == other.m_length;
+        return m_type == other.m_type && m_minTrackBreadth == other.m_minTrackBreadth && m_maxTrackBreadth == m_maxTrackBreadth;
     }
 
 private:
     GridTrackSizeType m_type;
-    Length m_length;
+    Length m_minTrackBreadth;
+    Length m_maxTrackBreadth;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to