Title: [144681] trunk
Revision
144681
Author
[email protected]
Date
2013-03-04 15:07:45 -0800 (Mon, 04 Mar 2013)

Log Message

[CSS Grid Layout] Add parsing for grid-{start|before}
https://bugs.webkit.org/show_bug.cgi?id=110988

Reviewed by Tony Chang.

Source/WebCore:

Test: fast/css-grid-layout/grid-item-start-before-get-set.html

Refactored how we store internally grid-{row|column} to be based on grid-{before|start}.
This is required as grid-{row|column} are shorthands for resp. grid-{before|after} and grid-{start|end}
in the specification and will also be in the code. That means a lot of methods were renamed to be more
aligned with the new design.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
* css/CSSProperty.cpp:
(WebCore::CSSProperty::isInheritedProperty):
* css/CSSPropertyNames.in:
* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyProperty):
Added the code to parse, apply and get back the new properties. Also
some renaming after the internal naming change below.

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::maximumIndexInDirection):
(WebCore::RenderGrid::placeItemsOnGrid):
(WebCore::RenderGrid::autoPlacementMajorAxisPositionForChild):
(WebCore::RenderGrid::autoPlacementMinorAxisPositionForChild):
* rendering/style/RenderStyle.h:
* rendering/style/StyleGridItemData.cpp:
(WebCore::StyleGridItemData::StyleGridItemData):
* rendering/style/StyleGridItemData.h:
(WebCore::StyleGridItemData::operator==):
Updated the naming now that we manipulate grid-{before|start} instead of grid-{row|column}.

LayoutTests:

* fast/css-grid-layout/grid-item-column-row-get-set-expected.txt:
* fast/css-grid-layout/grid-item-column-row-get-set.html:
Extended the test to make sure that both grid-column (resp. grid-row) and grid-start (resp. grid-before) are
in sync.

* fast/css-grid-layout/grid-item-start-before-get-set-expected.txt: Added.
* fast/css-grid-layout/grid-item-start-before-get-set.html: Added
Add this test for grid-{start|before}, similar to LayoutTests/fast/css-grid-layout/grid-item-column-row-get-set.html.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (144680 => 144681)


--- trunk/LayoutTests/ChangeLog	2013-03-04 22:44:20 UTC (rev 144680)
+++ trunk/LayoutTests/ChangeLog	2013-03-04 23:07:45 UTC (rev 144681)
@@ -1,3 +1,19 @@
+2013-03-04  Julien Chaffraix  <[email protected]>
+
+        [CSS Grid Layout] Add parsing for grid-{start|before}
+        https://bugs.webkit.org/show_bug.cgi?id=110988
+
+        Reviewed by Tony Chang.
+
+        * fast/css-grid-layout/grid-item-column-row-get-set-expected.txt:
+        * fast/css-grid-layout/grid-item-column-row-get-set.html:
+        Extended the test to make sure that both grid-column (resp. grid-row) and grid-start (resp. grid-before) are
+        in sync.
+
+        * fast/css-grid-layout/grid-item-start-before-get-set-expected.txt: Added.
+        * fast/css-grid-layout/grid-item-start-before-get-set.html: Added
+        Add this test for grid-{start|before}, similar to LayoutTests/fast/css-grid-layout/grid-item-column-row-get-set.html.
+
 2013-03-04  Chris Fleizach  <[email protected]>
 
         WebSpeech: change voiceURI to voice

Modified: trunk/LayoutTests/fast/css-grid-layout/grid-item-column-row-get-set-expected.txt (144680 => 144681)


--- trunk/LayoutTests/fast/css-grid-layout/grid-item-column-row-get-set-expected.txt	2013-03-04 22:44:20 UTC (rev 144680)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-item-column-row-get-set-expected.txt	2013-03-04 23:07:45 UTC (rev 144681)
@@ -5,31 +5,51 @@
 
 Test getting -webkit-grid-column and -webkit-grid-row set through CSS
 PASS getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-column') is 'auto'
+PASS getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-start') is 'auto'
 PASS getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-row') is 'auto'
+PASS getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-before') is 'auto'
 PASS getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-column') is '10'
+PASS getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-start') is '10'
 PASS getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-row') is '15'
+PASS getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-before') is '15'
 PASS getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-column') is '-10'
+PASS getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-start') is '-10'
 PASS getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-row') is '-15'
+PASS getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-before') is '-15'
 PASS getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-column') is 'auto'
+PASS getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-start') is 'auto'
 PASS getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-row') is 'auto'
+PASS getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-before') is 'auto'
 
 Test the initial value
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-column') is 'auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-start') is 'auto'
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-row') is 'auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-before') is 'auto'
 
 Test getting and setting grid-column and grid-row through JS
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-column') is '18'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-start') is '18'
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-row') is '66'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-before') is '66'
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-column') is '-55'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-start') is '-55'
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-row') is '-40'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-before') is '-40'
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-column') is 'auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-start') is 'auto'
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-row') is 'auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-before') is 'auto'
 
 Test setting grid-column and grid-row back to 'auto' through JS
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-column') is '18'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-start') is '18'
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-row') is '66'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-before') is '66'
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-column') is 'auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-start') is 'auto'
 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-row') is 'auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-before') is 'auto'
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/css-grid-layout/grid-item-column-row-get-set.html (144680 => 144681)


--- trunk/LayoutTests/fast/css-grid-layout/grid-item-column-row-get-set.html	2013-03-04 22:44:20 UTC (rev 144680)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-item-column-row-get-set.html	2013-03-04 23:07:45 UTC (rev 144681)
@@ -33,58 +33,78 @@
     debug("Test getting -webkit-grid-column and -webkit-grid-row set through CSS");
     var gridElement = document.getElementById("gridElement");
     shouldBe("getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-column')", "'auto'");
+    shouldBe("getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-start')", "'auto'");
     shouldBe("getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-row')", "'auto'");
+    shouldBe("getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-before')", "'auto'");
 
     var gridItemWithPositiveInteger = document.getElementById("gridItemWithPositiveInteger");
     shouldBe("getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-column')", "'10'");
+    shouldBe("getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-start')", "'10'");
     shouldBe("getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-row')", "'15'");
+    shouldBe("getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-before')", "'15'");
 
     var gridItemWithNegativeInteger = document.getElementById("gridItemWithNegativeInteger");
     shouldBe("getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-column')", "'-10'");
+    shouldBe("getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-start')", "'-10'");
     shouldBe("getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-row')", "'-15'");
+    shouldBe("getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-before')", "'-15'");
 
     var gridItemWithAutoElement = document.getElementById("gridItemWithAutoElement");
     shouldBe("getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-column')", "'auto'");
+    shouldBe("getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-start')", "'auto'");
     shouldBe("getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-row')", "'auto'");
+    shouldBe("getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-before')", "'auto'");
 
     debug("");
     debug("Test the initial value");
     var element = document.createElement("div");
     document.body.appendChild(element);
     shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-column')", "'auto'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-start')", "'auto'");
     shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-row')", "'auto'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-before')", "'auto'");
 
     debug("");
     debug("Test getting and setting grid-column and grid-row through JS");
     element.style.webkitGridColumn = "18";
     element.style.webkitGridRow = "66";
     shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-column')", "'18'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-start')", "'18'");
     shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-row')", "'66'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-before')", "'66'");
 
     element = document.createElement("div");
     document.body.appendChild(element);
     element.style.webkitGridColumn = "-55";
     element.style.webkitGridRow = "-40";
     shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-column')", "'-55'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-start')", "'-55'");
     shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-row')", "'-40'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-before')", "'-40'");
 
     element = document.createElement("div");
     document.body.appendChild(element);
     element.style.webkitGridColumn = "auto";
     element.style.webkitGridRow = "auto";
     shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-column')", "'auto'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-start')", "'auto'");
     shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-row')", "'auto'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-before')", "'auto'");
 
     debug("");
     debug("Test setting grid-column and grid-row back to 'auto' through JS");
     element.style.webkitGridColumn = "18";
     element.style.webkitGridRow = "66";
     shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-column')", "'18'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-start')", "'18'");
     shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-row')", "'66'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-before')", "'66'");
     element.style.webkitGridColumn = "auto";
     element.style.webkitGridRow = "auto";
     shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-column')", "'auto'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-start')", "'auto'");
     shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-row')", "'auto'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-before')", "'auto'");
 </script>
 <script src=""
 </body>

Added: trunk/LayoutTests/fast/css-grid-layout/grid-item-start-before-get-set-expected.txt (0 => 144681)


--- trunk/LayoutTests/fast/css-grid-layout/grid-item-start-before-get-set-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-item-start-before-get-set-expected.txt	2013-03-04 23:07:45 UTC (rev 144681)
@@ -0,0 +1,56 @@
+Test that setting and getting grid-start and grid-before works as expected
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Test getting -webkit-grid-start and -webkit-grid-before set through CSS
+PASS getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-start') is 'auto'
+PASS getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-column') is 'auto'
+PASS getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-before') is 'auto'
+PASS getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-row') is 'auto'
+PASS getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-start') is '10'
+PASS getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-column') is '10'
+PASS getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-before') is '15'
+PASS getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-row') is '15'
+PASS getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-start') is '-10'
+PASS getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-column') is '-10'
+PASS getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-before') is '-15'
+PASS getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-row') is '-15'
+PASS getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-start') is 'auto'
+PASS getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-column') is 'auto'
+PASS getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-before') is 'auto'
+PASS getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-row') is 'auto'
+
+Test the initial value
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-start') is 'auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-column') is 'auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-before') is 'auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-row') is 'auto'
+
+Test getting and setting grid-start and grid-before through JS
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-start') is '18'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-column') is '18'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-before') is '66'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-row') is '66'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-start') is '-55'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-column') is '-55'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-before') is '-40'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-row') is '-40'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-start') is 'auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-column') is 'auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-before') is 'auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-row') is 'auto'
+
+Test setting grid-start and grid-before back to 'auto' through JS
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-start') is '18'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-column') is '18'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-before') is '66'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-row') is '66'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-start') is 'auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-column') is 'auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-before') is 'auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-row') is 'auto'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Copied: trunk/LayoutTests/fast/css-grid-layout/grid-item-start-before-get-set.html (from rev 144680, trunk/LayoutTests/fast/css-grid-layout/grid-item-column-row-get-set.html) (0 => 144681)


--- trunk/LayoutTests/fast/css-grid-layout/grid-item-start-before-get-set.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-item-start-before-get-set.html	2013-03-04 23:07:45 UTC (rev 144681)
@@ -0,0 +1,111 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.testRunner)
+    testRunner.overridePreference("WebKitCSSGridLayoutEnabled", 1);
+</script>
+<style>
+.gridItemWithPositiveInteger {
+    -webkit-grid-start: 10;
+    -webkit-grid-before: 15;
+}
+.gridItemWithNegativeInteger {
+    -webkit-grid-start: -10;
+    -webkit-grid-before: -15;
+}
+.gridItemWithAuto {
+    -webkit-grid-start: auto;
+    -webkit-grid-before: auto;
+}
+</style>
+<script src=""
+</head>
+<body>
+<!-- The first has no properties set on it. -->
+<div id="gridElement"></div>
+<div class="gridItemWithPositiveInteger" id="gridItemWithPositiveInteger"></div>
+<div class="gridItemWithNegativeInteger" id="gridItemWithNegativeInteger"></div>
+<div class="gridItemWithAuto" id="gridItemWithAutoElement"></div>
+<script>
+    description('Test that setting and getting grid-start and grid-before works as expected');
+
+    debug("Test getting -webkit-grid-start and -webkit-grid-before set through CSS");
+    var gridElement = document.getElementById("gridElement");
+    shouldBe("getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-start')", "'auto'");
+    shouldBe("getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-column')", "'auto'");
+    shouldBe("getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-before')", "'auto'");
+    shouldBe("getComputedStyle(gridElement, '').getPropertyValue('-webkit-grid-row')", "'auto'");
+
+    var gridItemWithPositiveInteger = document.getElementById("gridItemWithPositiveInteger");
+    shouldBe("getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-start')", "'10'");
+    shouldBe("getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-column')", "'10'");
+    shouldBe("getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-before')", "'15'");
+    shouldBe("getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-row')", "'15'");
+
+    var gridItemWithNegativeInteger = document.getElementById("gridItemWithNegativeInteger");
+    shouldBe("getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-start')", "'-10'");
+    shouldBe("getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-column')", "'-10'");
+    shouldBe("getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-before')", "'-15'");
+    shouldBe("getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-row')", "'-15'");
+
+    var gridItemWithAutoElement = document.getElementById("gridItemWithAutoElement");
+    shouldBe("getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-start')", "'auto'");
+    shouldBe("getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-column')", "'auto'");
+    shouldBe("getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-before')", "'auto'");
+    shouldBe("getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-row')", "'auto'");
+
+    debug("");
+    debug("Test the initial value");
+    var element = document.createElement("div");
+    document.body.appendChild(element);
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-start')", "'auto'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-column')", "'auto'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-before')", "'auto'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-row')", "'auto'");
+
+    debug("");
+    debug("Test getting and setting grid-start and grid-before through JS");
+    element.style.webkitGridStart = "18";
+    element.style.webkitGridBefore = "66";
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-start')", "'18'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-column')", "'18'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-before')", "'66'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-row')", "'66'");
+
+    element = document.createElement("div");
+    document.body.appendChild(element);
+    element.style.webkitGridStart = "-55";
+    element.style.webkitGridBefore = "-40";
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-start')", "'-55'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-column')", "'-55'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-before')", "'-40'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-row')", "'-40'");
+
+    element = document.createElement("div");
+    document.body.appendChild(element);
+    element.style.webkitGridStart = "auto";
+    element.style.webkitGridBefore = "auto";
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-start')", "'auto'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-column')", "'auto'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-before')", "'auto'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-row')", "'auto'");
+
+    debug("");
+    debug("Test setting grid-start and grid-before back to 'auto' through JS");
+    element.style.webkitGridStart = "18";
+    element.style.webkitGridBefore = "66";
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-start')", "'18'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-column')", "'18'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-before')", "'66'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-row')", "'66'");
+    element.style.webkitGridStart = "auto";
+    element.style.webkitGridBefore = "auto";
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-start')", "'auto'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-column')", "'auto'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-before')", "'auto'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-row')", "'auto'");
+</script>
+<script src=""
+</body>
+</html>

Property changes: trunk/LayoutTests/fast/css-grid-layout/grid-item-start-before-get-set.html


Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (144680 => 144681)


--- trunk/Source/WebCore/ChangeLog	2013-03-04 22:44:20 UTC (rev 144680)
+++ trunk/Source/WebCore/ChangeLog	2013-03-04 23:07:45 UTC (rev 144681)
@@ -1,3 +1,41 @@
+2013-03-04  Julien Chaffraix  <[email protected]>
+
+        [CSS Grid Layout] Add parsing for grid-{start|before}
+        https://bugs.webkit.org/show_bug.cgi?id=110988
+
+        Reviewed by Tony Chang.
+
+        Test: fast/css-grid-layout/grid-item-start-before-get-set.html
+
+        Refactored how we store internally grid-{row|column} to be based on grid-{before|start}.
+        This is required as grid-{row|column} are shorthands for resp. grid-{before|after} and grid-{start|end}
+        in the specification and will also be in the code. That means a lot of methods were renamed to be more
+        aligned with the new design.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        * css/CSSProperty.cpp:
+        (WebCore::CSSProperty::isInheritedProperty):
+        * css/CSSPropertyNames.in:
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::applyProperty):
+        Added the code to parse, apply and get back the new properties. Also
+        some renaming after the internal naming change below.
+
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::maximumIndexInDirection):
+        (WebCore::RenderGrid::placeItemsOnGrid):
+        (WebCore::RenderGrid::autoPlacementMajorAxisPositionForChild):
+        (WebCore::RenderGrid::autoPlacementMinorAxisPositionForChild):
+        * rendering/style/RenderStyle.h:
+        * rendering/style/StyleGridItemData.cpp:
+        (WebCore::StyleGridItemData::StyleGridItemData):
+        * rendering/style/StyleGridItemData.h:
+        (WebCore::StyleGridItemData::operator==):
+        Updated the naming now that we manipulate grid-{before|start} instead of grid-{row|column}.
+
 2013-03-04  Chris Fleizach  <[email protected]>
 
         WebSpeech: change voiceURI to voice

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (144680 => 144681)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2013-03-04 22:44:20 UTC (rev 144680)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2013-03-04 23:07:45 UTC (rev 144681)
@@ -284,6 +284,8 @@
     CSSPropertyWebkitGridAutoFlow,
     CSSPropertyWebkitGridColumns,
     CSSPropertyWebkitGridRows,
+    CSSPropertyWebkitGridStart,
+    CSSPropertyWebkitGridBefore,
     CSSPropertyWebkitGridColumn,
     CSSPropertyWebkitGridRow,
     CSSPropertyWebkitHighlight,
@@ -1928,10 +1930,12 @@
         case CSSPropertyWebkitGridRows:
             return valueForGridTrackList(style->gridRows(), style.get(), m_node->document()->renderView());
 
+        case CSSPropertyWebkitGridStart:
         case CSSPropertyWebkitGridColumn:
-            return valueForGridPosition(style->gridItemColumn());
+            return valueForGridPosition(style->gridItemStart());
+        case CSSPropertyWebkitGridBefore:
         case CSSPropertyWebkitGridRow:
-            return valueForGridPosition(style->gridItemRow());
+            return valueForGridPosition(style->gridItemBefore());
 
         case CSSPropertyHeight:
             if (renderer) {

Modified: trunk/Source/WebCore/css/CSSParser.cpp (144680 => 144681)


--- trunk/Source/WebCore/css/CSSParser.cpp	2013-03-04 22:44:20 UTC (rev 144680)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2013-03-04 23:07:45 UTC (rev 144681)
@@ -2599,6 +2599,8 @@
             return false;
         return parseGridTrackList(propId, important);
 
+    case CSSPropertyWebkitGridStart:
+    case CSSPropertyWebkitGridBefore:
     case CSSPropertyWebkitGridColumn:
     case CSSPropertyWebkitGridRow:
         if (!cssGridLayoutEnabled())

Modified: trunk/Source/WebCore/css/CSSProperty.cpp (144680 => 144681)


--- trunk/Source/WebCore/css/CSSProperty.cpp	2013-03-04 22:44:20 UTC (rev 144680)
+++ trunk/Source/WebCore/css/CSSProperty.cpp	2013-03-04 23:07:45 UTC (rev 144681)
@@ -583,6 +583,8 @@
     case CSSPropertyWebkitGridAutoFlow:
     case CSSPropertyWebkitGridColumns:
     case CSSPropertyWebkitGridRows:
+    case CSSPropertyWebkitGridStart:
+    case CSSPropertyWebkitGridBefore:
     case CSSPropertyWebkitGridColumn:
     case CSSPropertyWebkitGridRow:
     case CSSPropertyWebkitLineClamp:

Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (144680 => 144681)


--- trunk/Source/WebCore/css/CSSPropertyNames.in	2013-03-04 22:44:20 UTC (rev 144680)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in	2013-03-04 23:07:45 UTC (rev 144681)
@@ -292,6 +292,8 @@
 -webkit-font-size-delta
 -webkit-grid-columns
 -webkit-grid-rows
+-webkit-grid-start
+-webkit-grid-before
 -webkit-grid-column
 -webkit-grid-row
 -webkit-grid-auto-flow

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (144680 => 144681)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2013-03-04 22:44:20 UTC (rev 144680)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2013-03-04 23:07:45 UTC (rev 144681)
@@ -3566,18 +3566,20 @@
         return;
     }
 
+    case CSSPropertyWebkitGridStart:
     case CSSPropertyWebkitGridColumn: {
-        GridPosition column;
-        if (!createGridPosition(value, column))
+        GridPosition startPosition;
+        if (!createGridPosition(value, startPosition))
             return;
-        state.style()->setGridItemColumn(column);
+        state.style()->setGridItemStart(startPosition);
         return;
     }
+    case CSSPropertyWebkitGridBefore:
     case CSSPropertyWebkitGridRow: {
-        GridPosition row;
-        if (!createGridPosition(value, row))
+        GridPosition beforePosition;
+        if (!createGridPosition(value, beforePosition))
             return;
-        state.style()->setGridItemRow(row);
+        state.style()->setGridItemBefore(beforePosition);
         return;
     }
     // These properties are aliased and StyleBuilder already applied the property on the prefixed version.

Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (144680 => 144681)


--- trunk/Source/WebCore/rendering/RenderGrid.cpp	2013-03-04 22:44:20 UTC (rev 144680)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp	2013-03-04 23:07:45 UTC (rev 144681)
@@ -334,7 +334,7 @@
     size_t maximumIndex = std::max<size_t>(1, trackStyles.size());
 
     for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
-        const GridPosition& position = (direction == ForColumns) ? child->style()->gridItemColumn() : child->style()->gridItemRow();
+        const GridPosition& position = (direction == ForColumns) ? child->style()->gridItemStart() : child->style()->gridItemBefore();
         // 'auto' items will need to be resolved in seperate phases anyway. Note that because maximumIndex is at least 1,
         // the grid-auto-flow == none case is automatically handled.
         if (position.isAuto())
@@ -526,9 +526,9 @@
     Vector<RenderBox*> specifiedMajorAxisAutoGridItems;
     GridAutoFlow autoFlow = style()->gridAutoFlow();
     for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
-        const GridPosition& columnPosition = child->style()->gridItemColumn();
-        const GridPosition& rowPosition = child->style()->gridItemRow();
-        if (autoFlow != AutoFlowNone && (columnPosition.isAuto() || rowPosition.isAuto())) {
+        const GridPosition& startPosition = child->style()->gridItemStart();
+        const GridPosition& beforePosition = child->style()->gridItemBefore();
+        if (autoFlow != AutoFlowNone && (startPosition.isAuto() || beforePosition.isAuto())) {
             const GridPosition& majorAxisPosition = autoPlacementMajorAxisPositionForChild(child);
             if (majorAxisPosition.isAuto())
                 autoMajorAxisAutoGridItems.append(child);
@@ -536,8 +536,8 @@
                 specifiedMajorAxisAutoGridItems.append(child);
             continue;
         }
-        size_t columnTrack = resolveGridPositionFromStyle(columnPosition);
-        size_t rowTrack = resolveGridPositionFromStyle(rowPosition);
+        size_t columnTrack = resolveGridPositionFromStyle(startPosition);
+        size_t rowTrack = resolveGridPositionFromStyle(beforePosition);
         insertItemIntoGrid(child, rowTrack, columnTrack);
     }
 
@@ -615,14 +615,14 @@
 {
     GridAutoFlow flow = style()->gridAutoFlow();
     ASSERT(flow != AutoFlowNone);
-    return (flow == AutoFlowColumn) ? gridItem->style()->gridItemColumn() : gridItem->style()->gridItemRow();
+    return (flow == AutoFlowColumn) ? gridItem->style()->gridItemStart() : gridItem->style()->gridItemBefore();
 }
 
 const GridPosition& RenderGrid::autoPlacementMinorAxisPositionForChild(const RenderBox* gridItem) const
 {
     GridAutoFlow flow = style()->gridAutoFlow();
     ASSERT(flow != AutoFlowNone);
-    return (flow == AutoFlowColumn) ? gridItem->style()->gridItemRow() : gridItem->style()->gridItemColumn();
+    return (flow == AutoFlowColumn) ? gridItem->style()->gridItemBefore() : gridItem->style()->gridItemStart();
 }
 
 RenderGrid::TrackSizingDirection RenderGrid::autoPlacementMajorAxisDirection() const

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (144680 => 144681)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2013-03-04 22:44:20 UTC (rev 144680)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2013-03-04 23:07:45 UTC (rev 144681)
@@ -765,8 +765,8 @@
     const Vector<GridTrackSize>& gridRows() const { return rareNonInheritedData->m_grid->m_gridRows; }
     GridAutoFlow gridAutoFlow() const { return rareNonInheritedData->m_grid->m_gridAutoFlow; }
 
-    const GridPosition& gridItemColumn() const { return rareNonInheritedData->m_gridItem->m_gridColumn; }
-    const GridPosition& gridItemRow() const { return rareNonInheritedData->m_gridItem->m_gridRow; }
+    const GridPosition& gridItemStart() const { return rareNonInheritedData->m_gridItem->m_gridStart; }
+    const GridPosition& gridItemBefore() const { return rareNonInheritedData->m_gridItem->m_gridBefore; }
 
     const ShadowData* boxShadow() const { return rareNonInheritedData->m_boxShadow.get(); }
     void getBoxShadowExtent(LayoutUnit& top, LayoutUnit& right, LayoutUnit& bottom, LayoutUnit& left) const { getShadowExtent(boxShadow(), top, right, bottom, left); }
@@ -1253,8 +1253,8 @@
     void setGridColumns(const Vector<GridTrackSize>& lengths) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridColumns, lengths); }
     void setGridRows(const Vector<GridTrackSize>& lengths) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridRows, lengths); }
     void setGridAutoFlow(GridAutoFlow flow) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridAutoFlow, flow); }
-    void setGridItemColumn(const GridPosition& columnPosition) { SET_VAR(rareNonInheritedData.access()->m_gridItem, m_gridColumn, columnPosition); }
-    void setGridItemRow(const GridPosition& rowPosition) { SET_VAR(rareNonInheritedData.access()->m_gridItem, m_gridRow, rowPosition); }
+    void setGridItemStart(const GridPosition& startPosition) { SET_VAR(rareNonInheritedData.access()->m_gridItem, m_gridStart, startPosition); }
+    void setGridItemBefore(const GridPosition& beforePosition) { SET_VAR(rareNonInheritedData.access()->m_gridItem, m_gridBefore, beforePosition); }
 
     void setMarqueeIncrement(const Length& f) { SET_VAR(rareNonInheritedData.access()->m_marquee, increment, f); }
     void setMarqueeSpeed(int f) { SET_VAR(rareNonInheritedData.access()->m_marquee, speed, f); }
@@ -1664,8 +1664,7 @@
     static GridAutoFlow initialGridAutoFlow() { return AutoFlowNone; }
 
     // 'auto' is the default.
-    static GridPosition initialGridItemColumn() { return GridPosition(); }
-    static GridPosition initialGridItemRow() { return GridPosition(); }
+    static GridPosition initialGridPosition() { return GridPosition(); }
 
     static unsigned initialTabSize() { return 8; }
 

Modified: trunk/Source/WebCore/rendering/style/StyleGridItemData.cpp (144680 => 144681)


--- trunk/Source/WebCore/rendering/style/StyleGridItemData.cpp	2013-03-04 22:44:20 UTC (rev 144680)
+++ trunk/Source/WebCore/rendering/style/StyleGridItemData.cpp	2013-03-04 23:07:45 UTC (rev 144681)
@@ -35,15 +35,15 @@
 namespace WebCore {
 
 StyleGridItemData::StyleGridItemData()
-    : m_gridColumn(RenderStyle::initialGridItemColumn())
-    , m_gridRow(RenderStyle::initialGridItemRow())
+    : m_gridStart(RenderStyle::initialGridPosition())
+    , m_gridBefore(RenderStyle::initialGridPosition())
 {
 }
 
 StyleGridItemData::StyleGridItemData(const StyleGridItemData& o)
     : RefCounted<StyleGridItemData>()
-    , m_gridColumn(o.m_gridColumn)
-    , m_gridRow(o.m_gridRow)
+    , m_gridStart(o.m_gridStart)
+    , m_gridBefore(o.m_gridBefore)
 {
 }
 

Modified: trunk/Source/WebCore/rendering/style/StyleGridItemData.h (144680 => 144681)


--- trunk/Source/WebCore/rendering/style/StyleGridItemData.h	2013-03-04 22:44:20 UTC (rev 144680)
+++ trunk/Source/WebCore/rendering/style/StyleGridItemData.h	2013-03-04 23:07:45 UTC (rev 144681)
@@ -46,7 +46,7 @@
 
     bool operator==(const StyleGridItemData& o) const
     {
-        return m_gridColumn == o.m_gridColumn && m_gridRow == o.m_gridRow;
+        return m_gridStart == o.m_gridStart && m_gridBefore == o.m_gridBefore;
     }
 
     bool operator!=(const StyleGridItemData& o) const
@@ -54,8 +54,8 @@
         return !(*this == o);
     }
 
-    GridPosition m_gridColumn;
-    GridPosition m_gridRow;
+    GridPosition m_gridStart;
+    GridPosition m_gridBefore;
 
 private:
     StyleGridItemData();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to