Diff
Modified: trunk/LayoutTests/ChangeLog (102182 => 102183)
--- trunk/LayoutTests/ChangeLog 2011-12-06 22:41:56 UTC (rev 102182)
+++ trunk/LayoutTests/ChangeLog 2011-12-06 23:11:05 UTC (rev 102183)
@@ -1,3 +1,18 @@
+2011-12-06 Julien Chaffraix <[email protected]>
+
+ CSS Grid Layout: Add support for parsing multiple grid-columns or grid-rows
+ https://bugs.webkit.org/show_bug.cgi?id=73272
+
+ Reviewed by Tony Chang.
+
+ * fast/css-grid-layout/grid-columns-rows-get-set-expected.txt:
+ * fast/css-grid-layout/resources/grid-columns-rows-get-set.js:
+ Added more testing for the single case.
+
+ * fast/css-grid-layout/grid-columns-rows-get-set-multiple-expected.txt: Added.
+ * fast/css-grid-layout/grid-columns-rows-get-set-multiple.html: Added.
+ * fast/css-grid-layout/resources/grid-columns-rows-get-set-multiple.js: Added.
+
2011-12-06 Darin Adler <[email protected]>
Generated some new expected results for Lion.
Modified: trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-expected.txt (102182 => 102183)
--- trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-expected.txt 2011-12-06 22:41:56 UTC (rev 102182)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-expected.txt 2011-12-06 23:11:05 UTC (rev 102183)
@@ -26,6 +26,12 @@
PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is '40%'
PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is 'auto'
PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is 'auto'
+
+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'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is 'none'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is 'none'
PASS successfullyParsed is true
TEST COMPLETE
Added: trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-multiple-expected.txt (0 => 102183)
--- trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-multiple-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-multiple-expected.txt 2011-12-06 23:11:05 UTC (rev 102183)
@@ -0,0 +1,52 @@
+Test that setting and getting grid-columns and grid-rows works as expected
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Test getting |display| set through CSS
+PASS getComputedStyle(gridWithFixedElement, '').getPropertyValue('-webkit-grid-columns') is '7px 11px'
+PASS getComputedStyle(gridWithFixedElement, '').getPropertyValue('-webkit-grid-rows') is '17px 2px'
+PASS getComputedStyle(gridWithPercentElement, '').getPropertyValue('-webkit-grid-columns') is '53% 99%'
+PASS getComputedStyle(gridWithPercentElement, '').getPropertyValue('-webkit-grid-rows') is '27% 52%'
+PASS getComputedStyle(gridWithAutoElement, '').getPropertyValue('-webkit-grid-columns') is 'auto auto'
+PASS getComputedStyle(gridWithAutoElement, '').getPropertyValue('-webkit-grid-rows') is 'auto auto'
+PASS getComputedStyle(gridWithEMElement, '').getPropertyValue('-webkit-grid-columns') is '100px 120px'
+PASS getComputedStyle(gridWithEMElement, '').getPropertyValue('-webkit-grid-rows') is '150px 170px'
+PASS getComputedStyle(gridWithThreeItems, '').getPropertyValue('-webkit-grid-columns') is '15px auto 100px'
+PASS getComputedStyle(gridWithThreeItems, '').getPropertyValue('-webkit-grid-rows') is '120px 18px auto'
+
+Test the initial value
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is 'none'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is 'none'
+
+Test getting and setting display through JS
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is '18px 22px'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is '66px 70px'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is '55% 80%'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is '40% 63%'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is 'auto auto'
+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'
+
+Test getting wrong values set from CSS
+PASS getComputedStyle(gridWithNoneAndAuto, '').getPropertyValue('-webkit-grid-columns') is 'none'
+PASS getComputedStyle(gridWithNoneAndAuto, '').getPropertyValue('-webkit-grid-rows') is 'none'
+PASS getComputedStyle(gridWithNoneAndFixed, '').getPropertyValue('-webkit-grid-columns') is 'none'
+PASS getComputedStyle(gridWithNoneAndFixed, '').getPropertyValue('-webkit-grid-rows') is 'none'
+
+Test setting and getting wrong values from 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'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is 'none'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is 'none'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-multiple-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-multiple.html (0 => 102183)
--- trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-multiple.html (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-multiple.html 2011-12-06 23:11:05 UTC (rev 102183)
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+.gridWithFixed {
+ display: -webkit-grid;
+ -webkit-grid-columns: 7px 11px;
+ -webkit-grid-rows: 17px 2px;
+}
+
+.gridWithPercent {
+ display: -webkit-grid;
+ -webkit-grid-columns: 53% 99%;
+ -webkit-grid-rows: 27% 52%;
+}
+.gridWithAuto {
+ display: -webkit-grid;
+ -webkit-grid-columns: auto auto;
+ -webkit-grid-rows: auto auto;
+}
+.gridWithEM {
+ display: -webkit-grid;
+ -webkit-grid-columns: 10em 12em;
+ -webkit-grid-rows: 15em 17em;
+ font: 10px Ahem;
+}
+.gridWithNoneAndAuto {
+ display: -webkit-grid;
+ -webkit-grid-columns: none auto;
+ -webkit-grid-rows: none auto;
+}
+.gridNoneWithAndFixed {
+ display: -webkit-grid;
+ -webkit-grid-columns: none 15px;
+ -webkit-grid-rows: none 22px;
+}
+.gridWithThreeItems {
+ display: -webkit-grid;
+ -webkit-grid-columns: 15px auto 10em;
+ -webkit-grid-rows: 12em 18px auto;
+ font: 10px Ahem;
+}
+</style>
+<script src=""
+</head>
+<body>
+<div class="gridWithFixed" id="gridWithFixedElement"></div>
+<div class="gridWithPercent" id="gridWithPercentElement"></div>
+<div class="gridWithAuto" id="gridWithAutoElement"></div>
+<div class="gridWithEM" id="gridWithEMElement"></div>
+<div class="gridWithNoneAndAuto" id="gridWithNoneAndAuto"></div>
+<div class="gridWithNoneAndFixed" id="gridWithNoneAndFixed"></div>
+<div class="gridWithThreeItems" id="gridWithThreeItems"></div>
+<script src=""
+<script src=""
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-multiple.html
___________________________________________________________________
Added: svn:executable
Added: svn:eol-style
Added: trunk/LayoutTests/fast/css-grid-layout/resources/grid-columns-rows-get-set-multiple.js (0 => 102183)
--- trunk/LayoutTests/fast/css-grid-layout/resources/grid-columns-rows-get-set-multiple.js (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/resources/grid-columns-rows-get-set-multiple.js 2011-12-06 23:11:05 UTC (rev 102183)
@@ -0,0 +1,105 @@
+description('Test that setting and getting grid-columns and grid-rows works as expected');
+
+debug("Test getting |display| set through CSS");
+var gridWithFixedElement = document.getElementById("gridWithFixedElement");
+shouldBe("getComputedStyle(gridWithFixedElement, '').getPropertyValue('-webkit-grid-columns')", "'7px 11px'");
+shouldBe("getComputedStyle(gridWithFixedElement, '').getPropertyValue('-webkit-grid-rows')", "'17px 2px'");
+
+var gridWithPercentElement = document.getElementById("gridWithPercentElement");
+shouldBe("getComputedStyle(gridWithPercentElement, '').getPropertyValue('-webkit-grid-columns')", "'53% 99%'");
+shouldBe("getComputedStyle(gridWithPercentElement, '').getPropertyValue('-webkit-grid-rows')", "'27% 52%'");
+
+var gridWithAutoElement = document.getElementById("gridWithAutoElement");
+shouldBe("getComputedStyle(gridWithAutoElement, '').getPropertyValue('-webkit-grid-columns')", "'auto auto'");
+shouldBe("getComputedStyle(gridWithAutoElement, '').getPropertyValue('-webkit-grid-rows')", "'auto auto'");
+
+var gridWithEMElement = document.getElementById("gridWithEMElement");
+shouldBe("getComputedStyle(gridWithEMElement, '').getPropertyValue('-webkit-grid-columns')", "'100px 120px'");
+shouldBe("getComputedStyle(gridWithEMElement, '').getPropertyValue('-webkit-grid-rows')", "'150px 170px'");
+
+var gridWithThreeItems = document.getElementById("gridWithThreeItems");
+shouldBe("getComputedStyle(gridWithThreeItems, '').getPropertyValue('-webkit-grid-columns')", "'15px auto 100px'");
+shouldBe("getComputedStyle(gridWithThreeItems, '').getPropertyValue('-webkit-grid-rows')", "'120px 18px auto'");
+
+debug("");
+debug("Test the initial value");
+var element = document.createElement("div");
+document.body.appendChild(element);
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'none'");
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'none'");
+
+debug("");
+debug("Test getting and setting display through JS");
+element.style.webkitGridColumns = "18px 22px";
+element.style.webkitGridRows = "66px 70px";
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'18px 22px'");
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'66px 70px'");
+
+element = document.createElement("div");
+document.body.appendChild(element);
+element.style.webkitGridColumns = "55% 80%";
+element.style.webkitGridRows = "40% 63%";
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'55% 80%'");
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'40% 63%'");
+
+element = document.createElement("div");
+document.body.appendChild(element);
+element.style.webkitGridColumns = "auto auto";
+element.style.webkitGridRows = "auto auto";
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'auto auto'");
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'auto auto'");
+
+element = document.createElement("div");
+document.body.appendChild(element);
+element.style.font = "10px Ahem";
+element.style.webkitGridColumns = "auto 16em 22px";
+element.style.webkitGridRows = "56% 10em auto";
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'auto 160px 22px'");
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'56% 100px auto'");
+
+debug("");
+debug("Test getting wrong values set from CSS");
+var gridWithNoneAndAuto = document.getElementById("gridWithNoneAndAuto");
+shouldBe("getComputedStyle(gridWithNoneAndAuto, '').getPropertyValue('-webkit-grid-columns')", "'none'");
+shouldBe("getComputedStyle(gridWithNoneAndAuto, '').getPropertyValue('-webkit-grid-rows')", "'none'");
+
+var gridWithNoneAndFixed = document.getElementById("gridWithNoneAndFixed");
+shouldBe("getComputedStyle(gridWithNoneAndFixed, '').getPropertyValue('-webkit-grid-columns')", "'none'");
+shouldBe("getComputedStyle(gridWithNoneAndFixed, '').getPropertyValue('-webkit-grid-rows')", "'none'");
+
+debug("");
+debug("Test setting and getting wrong values from JS");
+element = document.createElement("div");
+document.body.appendChild(element);
+element.style.webkitGridColumns = "none auto";
+element.style.webkitGridRows = "none auto";
+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 = "none 16em";
+element.style.webkitGridRows = "none 56%";
+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 = "none none";
+element.style.webkitGridRows = "none none";
+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 none";
+element.style.webkitGridRows = "auto none";
+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 none 16em";
+element.style.webkitGridRows = "auto 18em none";
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'none'");
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'none'");
Property changes on: trunk/LayoutTests/fast/css-grid-layout/resources/grid-columns-rows-get-set-multiple.js
___________________________________________________________________
Added: svn:executable
Added: svn:eol-style
Modified: trunk/LayoutTests/fast/css-grid-layout/resources/grid-columns-rows-get-set.js (102182 => 102183)
--- trunk/LayoutTests/fast/css-grid-layout/resources/grid-columns-rows-get-set.js 2011-12-06 22:41:56 UTC (rev 102182)
+++ trunk/LayoutTests/fast/css-grid-layout/resources/grid-columns-rows-get-set.js 2011-12-06 23:11:05 UTC (rev 102183)
@@ -48,3 +48,14 @@
element.style.webkitGridRows = "auto";
shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'auto'");
shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'auto'");
+
+debug("");
+debug("Test setting grid-columns and grid-rows back to 'none' through JS");
+element.style.webkitGridColumns = "18px";
+element.style.webkitGridRows = "66px";
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'18px'");
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'66px'");
+element.style.webkitGridColumns = "none";
+element.style.webkitGridRows = "none";
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'none'");
+shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'none'");
Modified: trunk/Source/WebCore/ChangeLog (102182 => 102183)
--- trunk/Source/WebCore/ChangeLog 2011-12-06 22:41:56 UTC (rev 102182)
+++ trunk/Source/WebCore/ChangeLog 2011-12-06 23:11:05 UTC (rev 102183)
@@ -1,3 +1,59 @@
+2011-12-06 Julien Chaffraix <[email protected]>
+
+ CSS Grid Layout: Add support for parsing multiple grid-columns or grid-rows
+ https://bugs.webkit.org/show_bug.cgi?id=73272
+
+ Reviewed by Tony Chang.
+
+ Test: fast/css-grid-layout/grid-columns-rows-get-set-multiple.html
+
+ Updated our supported syntax to match the following:
+ <track-list> := [ <track-breadth> ]+ | 'none'
+ <track-breadth> := <length> | <percentage> | 'auto'
+ (the naming loosely matches the specification)
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::valueForGridTrackBreadth): Added function to handle a breadth
+ (extended with 'auto' that the spec puts in <track-minmax>).
+
+ (WebCore::valueForGridTrackList): Create a space seperated list of
+ track breadth or none.
+
+ (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Updated
+ to use the new functions.
+
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::parseGridTrackList): Extended the function to
+ match the new syntax.
+
+ * css/CSSStyleApplyProperty.cpp:
+ (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty): Removed our
+ simple implementation. Replaced by the CSSStyleSelector functions.
+
+ * css/CSSStyleSelector.cpp:
+ (WebCore::createGridTrackBreadth):
+ (WebCore::createGridTrackList):
+ Added those 2 functions to convert the CSSPrimitiveValue to a Vector
+ as expected by RenderStyle.
+
+ (WebCore::CSSStyleSelector::applyProperty): Added our 2 properties
+ now that it is not handled by CSSStyleApplyProperty.
+
+ * rendering/style/RenderStyle.h:
+ (WebCore::InheritedFlags::gridColumns):
+ (WebCore::InheritedFlags::gridRows):
+ (WebCore::InheritedFlags::setGridColumns):
+ (WebCore::InheritedFlags::setGridRows):
+ (WebCore::InheritedFlags::initialGridColumns):
+ (WebCore::InheritedFlags::initialGridRows):
+ Updated the previous methods to take a Vector of Length.
+
+ (WebCore::InheritedFlags::initialGridTrackValue):
+ Needed function to return a Vector with one 'none' Length (the initial
+ value per the specification).
+
+ * rendering/style/StyleGridData.h: Updated to use a Vector.
+
2011-12-06 David Reveman <[email protected]>
[Chromium] Implement tile-sized painting using SkPicture.
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (102182 => 102183)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2011-12-06 22:41:56 UTC (rev 102182)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2011-12-06 23:11:05 UTC (rev 102183)
@@ -794,16 +794,29 @@
#endif
#if ENABLE(CSS_GRID_LAYOUT)
-static PassRefPtr<CSSValue> valueForGridTrackList(const Length& trackLength, const RenderStyle* style, CSSValuePool* cssValuePool)
+static PassRefPtr<CSSValue> valueForGridTrackBreadth(const Length& trackLength, const RenderStyle* style, CSSValuePool* cssValuePool)
{
if (trackLength.isPercent())
return cssValuePool->createValue(trackLength);
if (trackLength.isAuto())
return cssValuePool->createIdentifierValue(CSSValueAuto);
- if (trackLength.isUndefined())
- return cssValuePool->createIdentifierValue(CSSValueNone);
return zoomAdjustedPixelValue(trackLength.value(), style, cssValuePool);
}
+
+static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<Length>& trackLengths, const RenderStyle* style, CSSValuePool* cssValuePool)
+{
+ // We should have at least an element!
+ ASSERT(trackLengths.size());
+
+ // Handle the 'none' case here.
+ if (trackLengths.size() == 1 && trackLengths[0].isUndefined())
+ return cssValuePool->createIdentifierValue(CSSValueNone);
+
+ RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
+ for (size_t i = 0; i < trackLengths.size(); ++i)
+ list->append(valueForGridTrackBreadth(trackLengths[i], style, cssValuePool));
+ return list.release();
+}
#endif
static PassRefPtr<CSSValue> getDelayValue(const AnimationList* animList, CSSValuePool* cssValuePool)
@@ -1515,12 +1528,10 @@
}
#if ENABLE(CSS_GRID_LAYOUT)
case CSSPropertyWebkitGridColumns: {
- Length gridColumns = style->gridColumns();
- return valueForGridTrackList(gridColumns, style.get(), cssValuePool);
+ return valueForGridTrackList(style->gridColumns(), style.get(), cssValuePool);
}
case CSSPropertyWebkitGridRows: {
- Length gridRows = style->gridRows();
- return valueForGridTrackList(gridRows, style.get(), cssValuePool);
+ return valueForGridTrackList(style->gridRows(), style.get(), cssValuePool);
}
#endif
case CSSPropertyHeight:
Modified: trunk/Source/WebCore/css/CSSParser.cpp (102182 => 102183)
--- trunk/Source/WebCore/css/CSSParser.cpp 2011-12-06 22:41:56 UTC (rev 102182)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2011-12-06 23:11:05 UTC (rev 102183)
@@ -3526,16 +3526,26 @@
bool CSSParser::parseGridTrackList(int propId, bool important)
{
CSSParserValue* value = m_valueList->current();
- if (value->id == CSSValueNone || value->id == CSSValueAuto) {
+ if (value->id == CSSValueNone) {
+ if (m_valueList->next())
+ return false;
+
addProperty(propId, cssValuePool()->createIdentifierValue(value->id), important);
return true;
}
- if (validUnit(value, FLength | FPercent, m_strict)) {
- addProperty(propId, createPrimitiveNumericValue(value), important);
- return true;
+ RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated();
+ while (value) {
+ bool valid = validUnit(value, FLength | FPercent, m_strict) || value->id == CSSValueAuto;
+ if (!valid)
+ return false;
+
+ RefPtr<CSSPrimitiveValue> primitiveValue = value->id == CSSValueAuto ? cssValuePool()->createIdentifierValue(CSSValueAuto) : createPrimitiveNumericValue(value);
+ values->append(primitiveValue.release());
+ value = m_valueList->next();
}
- return false;
+ addProperty(propId, values.release(), important);
+ return true;
}
#endif
Modified: trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp (102182 => 102183)
--- trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp 2011-12-06 22:41:56 UTC (rev 102182)
+++ trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp 2011-12-06 23:11:05 UTC (rev 102183)
@@ -1331,11 +1331,6 @@
setPropertyHandler(CSSPropertyBottom, ApplyPropertyLength<&RenderStyle::bottom, &RenderStyle::setBottom, &RenderStyle::initialOffset, AutoEnabled>::createHandler());
setPropertyHandler(CSSPropertyLeft, ApplyPropertyLength<&RenderStyle::left, &RenderStyle::setLeft, &RenderStyle::initialOffset, AutoEnabled>::createHandler());
-#if ENABLE(CSS_GRID_LAYOUT)
- setPropertyHandler(CSSPropertyWebkitGridColumns, ApplyPropertyLength<&RenderStyle::gridColumns, &RenderStyle::setGridColumns, &RenderStyle::initialGridColumns, AutoEnabled, IntrinsicDisabled, MinIntrinsicDisabled, NoneEnabled, UndefinedEnabled>::createHandler());
- setPropertyHandler(CSSPropertyWebkitGridRows, ApplyPropertyLength<&RenderStyle::gridRows, &RenderStyle::setGridRows, &RenderStyle::initialGridRows, AutoEnabled, IntrinsicDisabled, MinIntrinsicDisabled, NoneEnabled, UndefinedEnabled>::createHandler());
-#endif
-
setPropertyHandler(CSSPropertyWidth, ApplyPropertyLength<&RenderStyle::width, &RenderStyle::setWidth, &RenderStyle::initialSize, AutoEnabled, IntrinsicEnabled, MinIntrinsicEnabled, NoneDisabled, UndefinedDisabled, FlexWidth>::createHandler());
setPropertyHandler(CSSPropertyHeight, ApplyPropertyLength<&RenderStyle::height, &RenderStyle::setHeight, &RenderStyle::initialSize, AutoEnabled, IntrinsicEnabled, MinIntrinsicEnabled, NoneDisabled, UndefinedDisabled, FlexHeight>::createHandler());
Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (102182 => 102183)
--- trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-12-06 22:41:56 UTC (rev 102182)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-12-06 23:11:05 UTC (rev 102183)
@@ -2506,6 +2506,61 @@
return m_element && m_element->isSVGElement();
}
+#if ENABLE(CSS_GRID_LAYOUT)
+
+static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, CSSStyleSelector* selector, Length& length)
+{
+ if (primitiveValue->getIdent() == CSSValueAuto) {
+ length = Length();
+ return true;
+ }
+
+ int type = primitiveValue->primitiveType();
+ if (CSSPrimitiveValue::isUnitTypeLength(type)) {
+ length = primitiveValue->computeLength<Length>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom());
+ length.setQuirk(primitiveValue->isQuirkValue());
+ return true;
+ }
+
+ if (type == CSSPrimitiveValue::CSS_PERCENTAGE) {
+ length = Length(primitiveValue->getDoubleValue(), Percent);
+ return true;
+ }
+
+ return false;
+}
+
+static bool createGridTrackList(CSSValue* value, Vector<Length>& lengths, CSSStyleSelector* selector)
+{
+ // Handle 'none'.
+ if (value->isPrimitiveValue()) {
+ CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
+ if (primitiveValue->getIdent() == CSSValueNone) {
+ lengths.append(Length(Undefined));
+ return true;
+ }
+ return false;
+ }
+
+ if (value->isValueList()) {
+ for (CSSValueListIterator i = value; i.hasMore(); i.advance()) {
+ CSSValue* currValue = i.value();
+ if (!currValue->isPrimitiveValue())
+ return false;
+
+ Length length;
+ if (!createGridTrackBreadth(static_cast<CSSPrimitiveValue*>(currValue), selector, length))
+ return false;
+
+ lengths.append(length);
+ }
+ return true;
+ }
+
+ return false;
+}
+#endif
+
void CSSStyleSelector::applyProperty(int id, CSSValue *value)
{
bool isInherit = m_parentNode && value->isInheritedValue();
@@ -3761,6 +3816,22 @@
return;
}
#endif
+#if ENABLE(CSS_GRID_LAYOUT)
+ case CSSPropertyWebkitGridColumns: {
+ Vector<Length> lengths;
+ if (!createGridTrackList(value, lengths, this))
+ return;
+ m_style->setGridColumns(lengths);
+ return;
+ }
+ case CSSPropertyWebkitGridRows: {
+ Vector<Length> lengths;
+ if (!createGridTrackList(value, lengths, this))
+ return;
+ m_style->setGridRows(lengths);
+ return;
+ }
+#endif
// These properties are implemented in the CSSStyleApplyProperty lookup table.
case CSSPropertyColor:
@@ -3824,10 +3895,6 @@
case CSSPropertyWebkitFlexFlow:
case CSSPropertyFontStyle:
case CSSPropertyFontVariant:
-#if ENABLE(CSS_GRID_LAYOUT)
- case CSSPropertyWebkitGridColumns:
- case CSSPropertyWebkitGridRows:
-#endif
case CSSPropertyTextRendering:
case CSSPropertyWebkitTextOrientation:
case CSSPropertyWebkitFontSmoothing:
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (102182 => 102183)
--- trunk/Source/WebCore/rendering/style/RenderStyle.h 2011-12-06 22:41:56 UTC (rev 102182)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h 2011-12-06 23:11:05 UTC (rev 102183)
@@ -729,8 +729,8 @@
bool isColumnFlexFlow() const { return flexFlow() == FlowColumn || flexFlow() == FlowColumnReverse; }
#if ENABLE(CSS_GRID_LAYOUT)
- Length gridColumns() const { return rareNonInheritedData->m_grid->m_gridColumns; }
- Length gridRows() const { return rareNonInheritedData->m_grid->m_gridRows; }
+ const Vector<Length>& gridColumns() const { return rareNonInheritedData->m_grid->m_gridColumns; }
+ const Vector<Length>& gridRows() const { return rareNonInheritedData->m_grid->m_gridRows; }
#endif
const ShadowData* boxShadow() const { return rareNonInheritedData->m_boxShadow.get(); }
@@ -1146,8 +1146,8 @@
void setFlexAlign(EFlexAlign a) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_flexAlign, a); }
void setFlexFlow(EFlexFlow flow) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_flexFlow, flow); }
#if ENABLE(CSS_GRID_LAYOUT)
- void setGridColumns(Length length) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridColumns, length); }
- void setGridRows(Length length) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridRows, length); }
+ void setGridColumns(const Vector<Length>& lengths) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridColumns, lengths); }
+ void setGridRows(const Vector<Length>& lengths) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridRows, lengths); }
#endif
void setMarqueeIncrement(const Length& f) { SET_VAR(rareNonInheritedData.access()->m_marquee, increment, f); }
@@ -1525,8 +1525,17 @@
static PrintColorAdjust initialPrintColorAdjust() { return PrintColorAdjustEconomy; }
#if ENABLE(CSS_GRID_LAYOUT)
- static Length initialGridColumns() { return Length(Undefined); }
- static Length initialGridRows() { return Length(Undefined); }
+ // The initial value is 'none' for grid tracks.
+ static Vector<Length> initialGridTrackValue()
+ {
+ static Vector<Length> defaultLength;
+ // We need to manually add the Length here as the Length(0) is 'auto'.
+ if (!defaultLength.size())
+ defaultLength.append(Length(Undefined));
+ return defaultLength;
+ }
+ static Vector<Length> initialGridColumns() { return initialGridTrackValue(); }
+ static Vector<Length> initialGridRows() { return initialGridTrackValue(); }
#endif
static const AtomicString& initialLineGrid() { return nullAtom; }
Modified: trunk/Source/WebCore/rendering/style/StyleGridData.h (102182 => 102183)
--- trunk/Source/WebCore/rendering/style/StyleGridData.h 2011-12-06 22:41:56 UTC (rev 102182)
+++ trunk/Source/WebCore/rendering/style/StyleGridData.h 2011-12-06 23:11:05 UTC (rev 102183)
@@ -31,6 +31,7 @@
#include "Length.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
namespace WebCore {
@@ -51,8 +52,8 @@
// FIXME: For the moment, we only support a subset of the grammar which correspond to:
// 'auto' | <length> | <percentage> | 'none'
- Length m_gridColumns;
- Length m_gridRows;
+ Vector<Length> m_gridColumns;
+ Vector<Length> m_gridRows;
private:
StyleGridData();