Implement limited parsing of -webkit-grid-column and -webkit-grid-row
authorjchaffraix@webkit.org <jchaffraix@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Feb 2012 23:24:46 +0000 (23:24 +0000)
committerjchaffraix@webkit.org <jchaffraix@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Feb 2012 23:24:46 +0000 (23:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=79151

Reviewed by Ojan Vafai.

Source/WebCore:

Test: fast/css-grid-layout/grid-item-column-row-get-set.html

This change implements a subset of the grammar:

-webkit-grid-{row|column} := <integer> | 'auto'

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
Added the new files to our build systems.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::valueForGridPosition): Check that we have the right translated grammar
(this function will be more useful once we implement more of the grammar).
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):
Added handling for the new properties.

* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
Allow only 'auto' or <integer>.

* css/CSSProperty.cpp:
(WebCore::CSSProperty::isInheritedProperty):
grid-colum and grid-row are not inherited.

* css/CSSPropertyNames.in:
Added the 2 new properties.

* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::RenderStyle):
(WebCore::RenderStyle::diff):
* rendering/style/RenderStyle.h:
* rendering/style/StyleGridItemData.cpp: Added.
(WebCore::StyleGridItemData::StyleGridItemData):
* rendering/style/StyleGridItemData.h: Added.
(StyleGridItemData):
(WebCore::StyleGridItemData::create):
(WebCore::StyleGridItemData::copy):
(WebCore::StyleGridItemData::operator==):
(WebCore::StyleGridItemData::operator!=):
Implemented the minimum working class.

* rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
(WebCore::StyleRareNonInheritedData::operator==):
* rendering/style/StyleRareNonInheritedData.h:
(StyleRareNonInheritedData):
Added StyleGridItemData to the class StyleRareNonInheritedData.

LayoutTests:

* fast/css-grid-layout/grid-item-column-row-get-set-expected.txt: Added.
* fast/css-grid-layout/grid-item-column-row-get-set.html: Added.

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

21 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css-grid-layout/grid-item-column-row-get-set-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-item-column-row-get-set.html [new file with mode: 0755]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSProperty.cpp
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/StyleGridItemData.cpp [new file with mode: 0644]
Source/WebCore/rendering/style/StyleGridItemData.h [new file with mode: 0644]
Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp
Source/WebCore/rendering/style/StyleRareNonInheritedData.h

index ad1ef0c..0f516bb 100644 (file)
@@ -1,3 +1,13 @@
+2012-02-24  Julien Chaffraix  <jchaffraix@webkit.org>
+
+        Implement limited parsing of -webkit-grid-column and -webkit-grid-row
+        https://bugs.webkit.org/show_bug.cgi?id=79151
+
+        Reviewed by Ojan Vafai.
+
+        * fast/css-grid-layout/grid-item-column-row-get-set-expected.txt: Added.
+        * fast/css-grid-layout/grid-item-column-row-get-set.html: Added.
+
 2012-02-24  Adrienne Walker  <enne@google.com>
 
         [chromium] Unreviewed gardening. Remove expectations for nonexistent tests.
diff --git a/LayoutTests/fast/css-grid-layout/grid-item-column-row-get-set-expected.txt b/LayoutTests/fast/css-grid-layout/grid-item-column-row-get-set-expected.txt
new file mode 100644 (file)
index 0000000..a579466
--- /dev/null
@@ -0,0 +1,36 @@
+Test that setting and getting grid-column and grid-row works as expected
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+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-row') is 'auto'
+PASS getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-column') is '10'
+PASS getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-row') is '15'
+PASS getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-column') is '-10'
+PASS getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-row') is '-15'
+PASS getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-column') is 'auto'
+PASS getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-row') is 'auto'
+
+Test the initial value
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-column') is 'auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-row') 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-row') is '66'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-column') is '-55'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-row') is '-40'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-column') is 'auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-row') 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-row') is '66'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-column') is 'auto'
+PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-row') is 'auto'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/css-grid-layout/grid-item-column-row-get-set.html b/LayoutTests/fast/css-grid-layout/grid-item-column-row-get-set.html
new file mode 100755 (executable)
index 0000000..ca1b6b6
--- /dev/null
@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+.gridItemWithPositiveInteger {
+    -webkit-grid-column: 10;
+    -webkit-grid-row: 15;
+}
+.gridItemWithNegativeInteger {
+    -webkit-grid-column: -10;
+    -webkit-grid-row: -15;
+}
+.gridItemWithAuto {
+    -webkit-grid-column: auto;
+    -webkit-grid-row: auto;
+}
+</style>
+<script src="../js/resources/js-test-pre.js"></script>
+</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-column and grid-row works as expected');
+
+    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-row')", "'auto'");
+
+    var gridItemWithPositiveInteger = document.getElementById("gridItemWithPositiveInteger");
+    shouldBe("getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-column')", "'10'");
+    shouldBe("getComputedStyle(gridItemWithPositiveInteger, '').getPropertyValue('-webkit-grid-row')", "'15'");
+
+    var gridItemWithNegativeInteger = document.getElementById("gridItemWithNegativeInteger");
+    shouldBe("getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-column')", "'-10'");
+    shouldBe("getComputedStyle(gridItemWithNegativeInteger, '').getPropertyValue('-webkit-grid-row')", "'-15'");
+
+    var gridItemWithAutoElement = document.getElementById("gridItemWithAutoElement");
+    shouldBe("getComputedStyle(gridItemWithAutoElement, '').getPropertyValue('-webkit-grid-column')", "'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-column')", "'auto'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-row')", "'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-row')", "'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-row')", "'-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-row')", "'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-row')", "'66'");
+    element.style.webkitGridColumn = "auto";
+    element.style.webkitGridRow = "auto";
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-column')", "'auto'");
+    shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-row')", "'auto'");
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
index 90efc6d..617630b 100644 (file)
@@ -1369,6 +1369,7 @@ SET(WebCore_SOURCES
     rendering/style/StyleFlexibleBoxData.cpp
     rendering/style/StyleGeneratedImage.cpp
     rendering/style/StyleGridData.cpp
+    rendering/style/StyleGridItemData.cpp
     rendering/style/StyleInheritedData.cpp
     rendering/style/StyleMarqueeData.cpp
     rendering/style/StyleMultiColData.cpp
index 55e6a87..4c8b684 100644 (file)
@@ -1,3 +1,64 @@
+2012-02-24  Julien Chaffraix  <jchaffraix@webkit.org>
+
+        Implement limited parsing of -webkit-grid-column and -webkit-grid-row
+        https://bugs.webkit.org/show_bug.cgi?id=79151
+
+        Reviewed by Ojan Vafai.
+
+        Test: fast/css-grid-layout/grid-item-column-row-get-set.html
+
+        This change implements a subset of the grammar:
+
+        -webkit-grid-{row|column} := <integer> | 'auto'
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        Added the new files to our build systems.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::valueForGridPosition): Check that we have the right translated grammar
+        (this function will be more useful once we implement more of the grammar).
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+        Added handling for the new properties.
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        Allow only 'auto' or <integer>.
+
+        * css/CSSProperty.cpp:
+        (WebCore::CSSProperty::isInheritedProperty):
+        grid-colum and grid-row are not inherited.
+
+        * css/CSSPropertyNames.in:
+        Added the 2 new properties.
+
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::RenderStyle):
+        (WebCore::RenderStyle::diff):
+        * rendering/style/RenderStyle.h:
+        * rendering/style/StyleGridItemData.cpp: Added.
+        (WebCore::StyleGridItemData::StyleGridItemData):
+        * rendering/style/StyleGridItemData.h: Added.
+        (StyleGridItemData):
+        (WebCore::StyleGridItemData::create):
+        (WebCore::StyleGridItemData::copy):
+        (WebCore::StyleGridItemData::operator==):
+        (WebCore::StyleGridItemData::operator!=):
+        Implemented the minimum working class.
+
+        * rendering/style/StyleRareNonInheritedData.cpp:
+        (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
+        (WebCore::StyleRareNonInheritedData::operator==):
+        * rendering/style/StyleRareNonInheritedData.h:
+        (StyleRareNonInheritedData):
+        Added StyleGridItemData to the class StyleRareNonInheritedData.
+
 2012-02-24  Joshua Bell  <jsbell@chromium.org>
 
         IndexedDB: IDBObjectStore.count() and IDBIndex.count() should accept key argument
index 6dfb681..cc53a47 100644 (file)
@@ -3688,6 +3688,8 @@ webcore_sources += \
        Source/WebCore/rendering/style/StyleGeneratedImage.h \
        Source/WebCore/rendering/style/StyleGridData.cpp \
        Source/WebCore/rendering/style/StyleGridData.h \
+       Source/WebCore/rendering/style/StyleGridItemData.cpp \
+       Source/WebCore/rendering/style/StyleGridItemData.h \
        Source/WebCore/rendering/style/StyleImage.h \
        Source/WebCore/rendering/style/StyleInheritedData.cpp \
        Source/WebCore/rendering/style/StyleInheritedData.h \
index a69f26a..3826696 100644 (file)
@@ -1290,6 +1290,7 @@ SOURCES += \
     rendering/style/StyleFlexibleBoxData.cpp \
     rendering/style/StyleGeneratedImage.cpp \
     rendering/style/StyleGridData.cpp \
+    rendering/style/StyleGridItemData.cpp \
     rendering/style/StyleInheritedData.cpp \
     rendering/style/StyleMarqueeData.cpp \
     rendering/style/StyleMultiColData.cpp \
index 2262644..59baf91 100644 (file)
             'rendering/style/StyleFlexibleBoxData.h',
             'rendering/style/StyleGeneratedImage.h',
             'rendering/style/StyleGridData.h',
+            'rendering/style/StyleGridItemData.h',
             'rendering/style/StyleImage.h',
             'rendering/style/StyleInheritedData.h',
             'rendering/style/StyleMarqueeData.h',
             'rendering/style/StyleFlexibleBoxData.cpp',
             'rendering/style/StyleGeneratedImage.cpp',
             'rendering/style/StyleGridData.cpp',
+            'rendering/style/StyleGridItemData.cpp',
             'rendering/style/StyleInheritedData.cpp',
             'rendering/style/StyleMarqueeData.cpp',
             'rendering/style/StyleMultiColData.cpp',
index 19106c0..4ed7950 100755 (executable)
                                        >
                                </File>
                                <File
+                                       RelativePath="..\rendering\style\StyleGridItemData.cpp"
+                                       >
+                                       <FileConfiguration
+                                               Name="Debug|Win32"
+                                               ExcludedFromBuild="true"
+                                               >
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                               />
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Release|Win32"
+                                               ExcludedFromBuild="true"
+                                               >
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                               />
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Debug_Cairo_CFLite|Win32"
+                                               ExcludedFromBuild="true"
+                                               >
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                               />
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Release_Cairo_CFLite|Win32"
+                                               ExcludedFromBuild="true"
+                                               >
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                               />
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Debug_All|Win32"
+                                               ExcludedFromBuild="true"
+                                               >
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                               />
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Production|Win32"
+                                               ExcludedFromBuild="true"
+                                               >
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                               />
+                                       </FileConfiguration>
+                               </File>
+                               <File
+                                       RelativePath="..\rendering\style\StyleGridItemData.h"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\rendering\style\StyleImage.h"
                                        >
                                </File>
index 44011fb..ab89450 100644 (file)
                A10BB58B1484E3B300B2E87A /* RenderSVGShape.h in Headers */ = {isa = PBXBuildFile; fileRef = A10BB5891484E3B300B2E87A /* RenderSVGShape.h */; };
                A10DC76A14747BAB005E2471 /* StyleGridData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A10DC76814747BAB005E2471 /* StyleGridData.cpp */; };
                A10DC76B14747BAB005E2471 /* StyleGridData.h in Headers */ = {isa = PBXBuildFile; fileRef = A10DC76914747BAB005E2471 /* StyleGridData.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A110DB9D14F5DF8700A03B93 /* StyleGridItemData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A110DB9C14F5DF8700A03B93 /* StyleGridItemData.cpp */; };
+               A110DB9B14F5DF7700A03B93 /* StyleGridItemData.h in Headers */ = {isa = PBXBuildFile; fileRef = A110DB9A14F5DF7700A03B93 /* StyleGridItemData.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A120ACA413F998CA00FE4AC7 /* LayoutRepainter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A120ACA113F9984600FE4AC7 /* LayoutRepainter.cpp */; };
                A12538D413F9B60A00024754 /* LayoutRepainter.h in Headers */ = {isa = PBXBuildFile; fileRef = A120ACA013F9983700FE4AC7 /* LayoutRepainter.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A136A00C1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A136A00A1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp */; };
                A10BB5891484E3B300B2E87A /* RenderSVGShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGShape.h; sourceTree = "<group>"; };
                A10DC76814747BAB005E2471 /* StyleGridData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StyleGridData.cpp; path = style/StyleGridData.cpp; sourceTree = "<group>"; };
                A10DC76914747BAB005E2471 /* StyleGridData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleGridData.h; path = style/StyleGridData.h; sourceTree = "<group>"; };
+               A110DB9A14F5DF7700A03B93 /* StyleGridItemData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleGridItemData.h; path = style/StyleGridItemData.h; sourceTree = "<group>"; };
+               A110DB9C14F5DF8700A03B93 /* StyleGridItemData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StyleGridItemData.cpp; path = style/StyleGridItemData.cpp; sourceTree = "<group>"; };
                A120ACA013F9983700FE4AC7 /* LayoutRepainter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutRepainter.h; sourceTree = "<group>"; };
                A120ACA113F9984600FE4AC7 /* LayoutRepainter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutRepainter.cpp; sourceTree = "<group>"; };
                A136A00A1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLHttpRequestProgressEventThrottle.cpp; sourceTree = "<group>"; };
                                BCEF44490E6745E0001C1287 /* StyleGeneratedImage.h */,
                                A10DC76814747BAB005E2471 /* StyleGridData.cpp */,
                                A10DC76914747BAB005E2471 /* StyleGridData.h */,
+                               A110DB9C14F5DF8700A03B93 /* StyleGridItemData.cpp */,
+                               A110DB9A14F5DF7700A03B93 /* StyleGridItemData.h */,
                                BCEF43CE0E673DA1001C1287 /* StyleImage.h */,
                                BC2273010E82F1E600E7F975 /* StyleInheritedData.cpp */,
                                BC2273020E82F1E600E7F975 /* StyleInheritedData.h */,
                                5317612313C516690026E454 /* StyleFlexibleBoxData.h in Headers */,
                                BCEF444A0E6745E0001C1287 /* StyleGeneratedImage.h in Headers */,
                                A10DC76B14747BAB005E2471 /* StyleGridData.h in Headers */,
+                               A110DB9B14F5DF7700A03B93 /* StyleGridItemData.h in Headers */,
                                BCEF43CF0E673DA1001C1287 /* StyleImage.h in Headers */,
                                BC2273040E82F1E600E7F975 /* StyleInheritedData.h in Headers */,
                                BC5EB72A0E81DE8100B25965 /* StyleMarqueeData.h in Headers */,
                                5317612213C516690026E454 /* StyleFlexibleBoxData.cpp in Sources */,
                                BCEF447D0E674806001C1287 /* StyleGeneratedImage.cpp in Sources */,
                                A10DC76A14747BAB005E2471 /* StyleGridData.cpp in Sources */,
+                               A110DB9D14F5DF8700A03B93 /* StyleGridItemData.cpp in Sources */,
                                BC2273030E82F1E600E7F975 /* StyleInheritedData.cpp in Sources */,
                                BC5EB7290E81DE8100B25965 /* StyleMarqueeData.cpp in Sources */,
                                0FF50271102BA96A0066F39A /* StyleMedia.cpp in Sources */,
index 04f72c8..428a458 100644 (file)
@@ -232,6 +232,9 @@ static const int computedProperties[] = {
 #if ENABLE(CSS_GRID_LAYOUT)
     CSSPropertyWebkitGridColumns,
     CSSPropertyWebkitGridRows,
+
+    CSSPropertyWebkitGridColumn,
+    CSSPropertyWebkitGridRow,
 #endif
     CSSPropertyWebkitHighlight,
     CSSPropertyWebkitHyphenateCharacter,
@@ -913,6 +916,15 @@ static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<Length>& trackLen
         list->append(valueForGridTrackBreadth(trackLengths[i], style, cssValuePool));
     return list.release();
 }
+
+static PassRefPtr<CSSValue> valueForGridPosition(const Length& position, CSSValuePool* cssValuePool)
+{
+    if (position.isAuto())
+        return cssValuePool->createIdentifierValue(CSSValueAuto);
+
+    ASSERT(position.isFixed());
+    return cssValuePool->createValue(position.value(), CSSPrimitiveValue::CSS_NUMBER);
+}
 #endif
 
 static PassRefPtr<CSSValue> getDelayValue(const AnimationList* animList, CSSValuePool* cssValuePool)
@@ -1648,6 +1660,11 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         case CSSPropertyWebkitGridRows: {
             return valueForGridTrackList(style->gridRows(), style.get(), cssValuePool);
         }
+
+        case CSSPropertyWebkitGridColumn:
+            return valueForGridPosition(style->gridItemColumn(), cssValuePool);
+        case CSSPropertyWebkitGridRow:
+            return valueForGridPosition(style->gridItemRow(), cssValuePool);
 #endif
         case CSSPropertyHeight:
             if (renderer) {
index 52a8041..277a282 100644 (file)
@@ -1882,6 +1882,11 @@ bool CSSParser::parseValue(int propId, bool important)
     case CSSPropertyWebkitGridColumns:
     case CSSPropertyWebkitGridRows:
         return parseGridTrackList(propId, important);
+
+    case CSSPropertyWebkitGridColumn:
+    case CSSPropertyWebkitGridRow:
+        validPrimitive = id == CSSValueAuto || validUnit(value, FInteger, m_strict);
+        break;
 #endif
     case CSSPropertyWebkitMarginCollapse: {
         const int properties[2] = { CSSPropertyWebkitMarginBeforeCollapse,
index fd85e9b..01e7077 100644 (file)
@@ -573,6 +573,9 @@ bool CSSProperty::isInheritedProperty(unsigned propertyID)
 #if ENABLE(CSS_GRID_LAYOUT)
     case CSSPropertyWebkitGridColumns:
     case CSSPropertyWebkitGridRows:
+
+    case CSSPropertyWebkitGridColumn:
+    case CSSPropertyWebkitGridRow:
 #endif
     case CSSPropertyWebkitLineClamp:
     case CSSPropertyWebkitLogicalWidth:
index 9afda37..4139446 100644 (file)
@@ -376,6 +376,8 @@ z-index
 #if defined(ENABLE_CSS_GRID_LAYOUT) && ENABLE_CSS_GRID_LAYOUT
 -webkit-grid-columns
 -webkit-grid-rows
+-webkit-grid-column
+-webkit-grid-row
 #endif
 #if defined(ENABLE_DASHBOARD_SUPPORT) && ENABLE_DASHBOARD_SUPPORT
 -webkit-dashboard-region
index b172c47..819fd49 100644 (file)
@@ -2952,6 +2952,22 @@ static bool createGridTrackList(CSSValue* value, Vector<Length>& lengths, CSSSty
 
     return false;
 }
+
+
+static bool createGridPosition(CSSValue* value, Length& position)
+{
+    // For now, we only accept: <integer> | 'auto'
+    if (!value->isPrimitiveValue())
+        return false;
+
+    CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
+    if (primitiveValue->getIdent() == CSSValueAuto)
+        return true;
+
+    ASSERT(primitiveValue->isNumber());
+    position.setValue(primitiveValue->getIntValue());
+    return true;
+}
 #endif
 
 void CSSStyleSelector::applyProperty(int id, CSSValue *value)
@@ -3804,6 +3820,21 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         m_style->setGridRows(lengths);
         return;
     }
+
+    case CSSPropertyWebkitGridColumn: {
+        Length column;
+        if (!createGridPosition(value, column))
+            return;
+        m_style->setGridItemColumn(column);
+        return;
+    }
+    case CSSPropertyWebkitGridRow: {
+        Length row;
+        if (!createGridPosition(value, row))
+            return;
+        m_style->setGridItemRow(row);
+        return;
+    }
 #endif
 
     // These properties are implemented in the CSSStyleApplyProperty lookup table.
index c62b3b1..145951d 100644 (file)
@@ -135,6 +135,7 @@ ALWAYS_INLINE RenderStyle::RenderStyle(bool)
 #endif
 #if ENABLE(CSS_GRID_LAYOUT)
     rareNonInheritedData.access()->m_grid.init();
+    rareNonInheritedData.access()->m_gridItem.init();
 #endif
     rareInheritedData.init();
     inherited.init();
@@ -424,7 +425,8 @@ StyleDifference RenderStyle::diff(const RenderStyle* other, unsigned& changedCon
         }
 #endif
 #if ENABLE(CSS_GRID_LAYOUT)
-        if (rareNonInheritedData->m_grid.get() != other->rareNonInheritedData->m_grid.get())
+        if (rareNonInheritedData->m_grid.get() != other->rareNonInheritedData->m_grid.get()
+            && rareNonInheritedData->m_gridItem.get() != other->rareNonInheritedData->m_gridItem.get())
             return StyleDifferenceLayout;
 #endif
 
index 647d3e9..4e94730 100644 (file)
@@ -77,6 +77,7 @@
 
 #if ENABLE(CSS_GRID_LAYOUT)
 #include "StyleGridData.h"
+#include "StyleGridItemData.h"
 #endif
 
 #if ENABLE(DASHBOARD_SUPPORT)
@@ -814,6 +815,9 @@ public:
 #if ENABLE(CSS_GRID_LAYOUT)
     const Vector<Length>& gridColumns() const { return rareNonInheritedData->m_grid->m_gridColumns; }
     const Vector<Length>& gridRows() const { return rareNonInheritedData->m_grid->m_gridRows; }
+
+    const Length& gridItemColumn() const { return rareNonInheritedData->m_gridItem->m_gridColumn; }
+    const Length& gridItemRow() const { return rareNonInheritedData->m_gridItem->m_gridRow; }
 #endif
 
     const ShadowData* boxShadow() const { return rareNonInheritedData->m_boxShadow.get(); }
@@ -1240,6 +1244,9 @@ public:
 #if ENABLE(CSS_GRID_LAYOUT)
     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); }
+
+    void setGridItemColumn(const Length& columnPosition) { SET_VAR(rareNonInheritedData.access()->m_gridItem, m_gridColumn, columnPosition); }
+    void setGridItemRow(const Length& rowPosition) { SET_VAR(rareNonInheritedData.access()->m_gridItem, m_gridRow, rowPosition); }
 #endif
 
     void setMarqueeIncrement(const Length& f) { SET_VAR(rareNonInheritedData.access()->m_marquee, increment, f); }
@@ -1636,6 +1643,10 @@ public:
     }
     static Vector<Length> initialGridColumns() { return initialGridTrackValue(); }
     static Vector<Length> initialGridRows() { return initialGridTrackValue(); }
+
+    // 'auto' is the default.
+    static Length initialGridItemColumn() { return Length(); }
+    static Length initialGridItemRow() { return Length(); }
 #endif
 
     static const AtomicString& initialLineGrid() { return nullAtom; }
diff --git a/Source/WebCore/rendering/style/StyleGridItemData.cpp b/Source/WebCore/rendering/style/StyleGridItemData.cpp
new file mode 100644 (file)
index 0000000..a633c11
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "config.h"
+#include "StyleGridItemData.h"
+
+#if ENABLE(CSS_GRID_LAYOUT)
+
+#include "RenderStyle.h"
+
+namespace WebCore {
+
+StyleGridItemData::StyleGridItemData()
+    : m_gridColumn(RenderStyle::initialGridItemColumn())
+    , m_gridRow(RenderStyle::initialGridItemRow())
+{
+}
+
+StyleGridItemData::StyleGridItemData(const StyleGridItemData& o)
+    : RefCounted<StyleGridItemData>()
+    , m_gridColumn(o.m_gridColumn)
+    , m_gridRow(o.m_gridRow)
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(CSS_GRID_LAYOUT)
+
diff --git a/Source/WebCore/rendering/style/StyleGridItemData.h b/Source/WebCore/rendering/style/StyleGridItemData.h
new file mode 100644 (file)
index 0000000..76306b4
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef StyleGridItemData_h
+#define StyleGridItemData_h
+
+#if ENABLE(CSS_GRID_LAYOUT)
+
+#include "Length.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class StyleGridItemData : public RefCounted<StyleGridItemData> {
+public:
+    static PassRefPtr<StyleGridItemData> create() { return adoptRef(new StyleGridItemData); }
+    PassRefPtr<StyleGridItemData> copy() const { return adoptRef(new StyleGridItemData(*this)); }
+
+    bool operator==(const StyleGridItemData& o) const
+    {
+        return m_gridColumn == o.m_gridColumn && m_gridRow == o.m_gridRow;
+    }
+
+    bool operator!=(const StyleGridItemData& o) const
+    {
+        return !(*this == o);
+    }
+
+    // FIXME: For the moment, we only support a subset of the grammar which correspond to:
+    // 'auto' | <length>
+    // When we add more of the syntax, we will need a dedicated GridPosition class.
+    Length m_gridColumn;
+    Length m_gridRow;
+
+private:
+    StyleGridItemData();
+    StyleGridItemData(const StyleGridItemData&);
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(CSS_LAYOUT_GRID)
+
+#endif // StyleGridItemData_h
index 3dc34f0..529fc4e 100644 (file)
@@ -98,6 +98,7 @@ StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInherited
 #endif
 #if ENABLE(CSS_GRID_LAYOUT)
     , m_grid(o.m_grid)
+    , m_gridItem(o.m_gridItem)
 #endif
     , m_content(o.m_content ? o.m_content->clone() : nullptr)
     , m_counterDirectives(o.m_counterDirectives ? clone(*o.m_counterDirectives) : nullptr)
@@ -165,6 +166,7 @@ bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) c
 #endif
 #if ENABLE(CSS_GRID_LAYOUT)
         && m_grid == o.m_grid
+        && m_gridItem == o.m_gridItem
 #endif
         && contentDataEquivalent(o)
         && counterDataEquivalent(o)
index 3e2c4a1..e95c55b 100644 (file)
@@ -48,6 +48,7 @@ class StyleFilterData;
 class StyleFlexibleBoxData;
 #if ENABLE(CSS_GRID_LAYOUT)
 class StyleGridData;
+class StyleGridItemData;
 #endif
 class StyleMarqueeData;
 class StyleMultiColData;
@@ -119,6 +120,7 @@ public:
 
 #if ENABLE(CSS_GRID_LAYOUT)
     DataRef<StyleGridData> m_grid;
+    DataRef<StyleGridItemData> m_gridItem;
 #endif
 
     OwnPtr<ContentData> m_content;