Title: [291955] trunk
Revision
291955
Author
[email protected]
Date
2022-03-27 20:03:36 -0700 (Sun, 27 Mar 2022)

Log Message

Fix serialization of grid-template
https://bugs.webkit.org/show_bug.cgi?id=237868

Reviewed by Dean Jackson.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-grid/parsing/grid-shorthand-valid-expected.txt:
* web-platform-tests/css/css-grid/parsing/grid-template-shorthand-valid-expected.txt:

Update expectation files for newly passing tests.

Source/WebCore:

Existing WPT tests marked as passing.

* css/CSSGridTemplateAreasValue.cpp:
(WebCore::CSSGridTemplateAreasValue::stringForRow):
* css/CSSGridTemplateAreasValue.h:
* css/StyleProperties.cpp:
(WebCore::StyleProperties::getPropertyValue const):
(WebCore::isNoneValue):
(WebCore::isValueID):
(WebCore::StyleProperties::getGridTemplateValue const):
(WebCore::StyleProperties::getGridValue const):
* css/StyleProperties.h:

Creates custom serialization for grid-template that handles the case
where no areas were specified (and omits trailing 'none' value), as well as handling
the case where areas are interleaved within the tracks definitions.

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (291954 => 291955)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-03-28 02:35:11 UTC (rev 291954)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-03-28 03:03:36 UTC (rev 291955)
@@ -1,5 +1,17 @@
 2022-03-27  Matt Woodrow  <[email protected]>
 
+        Fix serialization of grid-template
+        https://bugs.webkit.org/show_bug.cgi?id=237868
+
+        Reviewed by Dean Jackson.
+
+        * web-platform-tests/css/css-grid/parsing/grid-shorthand-valid-expected.txt:
+        * web-platform-tests/css/css-grid/parsing/grid-template-shorthand-valid-expected.txt:
+
+        Update expectation files for newly passing tests.
+
+2022-03-27  Matt Woodrow  <[email protected]>
+
         Lazily allocate backing store for grid columns.
         https://bugs.webkit.org/show_bug.cgi?id=212201
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-layout-properties-expected.txt (291954 => 291955)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-layout-properties-expected.txt	2022-03-28 02:35:11 UTC (rev 291954)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-layout-properties-expected.txt	2022-03-28 03:03:36 UTC (rev 291955)
@@ -34,9 +34,9 @@
 FAIL grid-template.initial assert_equals: initial value of grid-template should be 50px 50px 50px / 150px expected "50px 50px 50px / 150px" but got "50px 50px 50px / 150px / none"
 FAIL grid-template.none assert_equals: none expected "50px 50px 50px / 150px" but got "50px 50px 50px / 150px / none"
 FAIL grid-template.<grid-template-rows> / <grid-template-columns> assert_equals: <grid-template-rows> / <grid-template-columns> expected "100px 100px / 200px 200px" but got "100px 100px / 200px 200px / none"
-FAIL grid-template.<line-names> assert_equals: <line-names> expected "[a] auto [b] auto [c] / [d] auto [e] auto [f]" but got "[a] auto [b] auto [c] / [d] auto [e] auto [f] / none"
-FAIL grid-template.<string>+ assert_equals: <string>+ expected "\"a b\" \"a b\"" but got "auto auto / none / \"a b\" \"a b\""
-FAIL grid-template.<string><track-size>+ assert_equals: <string><track-size>+ expected "100px / \"a b\" 50px" but got "auto auto / none / \"a b\" \"a b\""
+FAIL grid-template.<line-names> assert_equals: <line-names> expected "[a] auto [b] auto [c] / [d] auto [e] auto [f]" but got "[a] 50px [b] 50px [c] / [d] 150px [e] 100px [f] / none"
+FAIL grid-template.<string>+ assert_equals: <string>+ expected "\"a b\" \"a b\"" but got "50px 50px / 150px 100px / \"a b\" \"a b\""
+FAIL grid-template.<string><track-size>+ assert_equals: <string><track-size>+ expected "100px / \"a b\" 50px" but got "\"a b\" \"a b\""
 FAIL grid-template.reset assert_equals: reset expected "50px 50px 50px / 150px" but got "50px 50px 50px / 150px / none"
 PASS grid-auto-columns
 PASS grid-auto-columns.initial

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-shorthand-valid-expected.txt (291954 => 291955)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-shorthand-valid-expected.txt	2022-03-28 02:35:11 UTC (rev 291954)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-shorthand-valid-expected.txt	2022-03-28 03:03:36 UTC (rev 291955)
@@ -1,39 +1,39 @@
 
-FAIL e.style['grid'] = "none" should set the property value assert_equals: serialization should be canonical expected "none" but got "none / none / none / row / auto / auto"
-FAIL e.style['grid'] = "none / none" should set the property value assert_equals: serialization should be canonical expected "none" but got "none / none / none / row / auto / auto"
-FAIL e.style['grid'] = "auto / auto" should set the property value assert_equals: serialization should be canonical expected "auto / auto" but got "auto / auto / none / row / auto / auto"
-FAIL e.style['grid'] = "none / [a] 0px" should set the property value assert_equals: serialization should be canonical expected "none / [a] 0px" but got "none / [a] 0px / none / row / auto / auto"
-FAIL e.style['grid'] = "none / [] 0px" should set the property value assert_equals: serialization should be canonical expected "none / 0px" but got "none / 0px / none / row / auto / auto"
-FAIL e.style['grid'] = "[a] 10px / auto" should set the property value assert_equals: serialization should be canonical expected "[a] 10px / auto" but got "[a] 10px / auto / none / row / auto / auto"
-FAIL e.style['grid'] = "[a] 10px / none" should set the property value assert_equals: serialization should be canonical expected "[a] 10px / none" but got "[a] 10px / none / none / row / auto / auto"
-FAIL e.style['grid'] = "[] 10px [] / [] auto []" should set the property value assert_equals: serialization should be canonical expected "10px / auto" but got "10px / auto / none / row / auto / auto"
-FAIL e.style['grid'] = "[a] \"a\" 10px" should set the property value assert_equals: serialization should be canonical expected "[a] \"a\" 10px" but got "[a] 10px / none / \"a\" / row / auto / auto"
-FAIL e.style['grid'] = "[a] \"a\" 10px []" should set the property value assert_equals: serialization should be canonical expected "[a] \"a\" 10px" but got "[a] 10px / none / \"a\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" 10px" should set the property value assert_equals: serialization should be canonical expected "\"a\" 10px" but got "10px / none / \"a\" / row / auto / auto"
-FAIL e.style['grid'] = "[] \"a\" 10px" should set the property value assert_equals: serialization should be canonical expected "\"a\" 10px" but got "10px / none / \"a\" / row / auto / auto"
-FAIL e.style['grid'] = "[a] \"a\" 10px [a]" should set the property value assert_equals: serialization should be canonical expected "[a] \"a\" 10px [a]" but got "[a] 10px [a] / none / \"a\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\"" should set the property value assert_equals: serialization should be canonical expected "\"a\"" but got "auto / none / \"a\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" auto" should set the property value assert_equals: serialization should be canonical expected "\"a\"" but got "auto / none / \"a\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" / 10px" should set the property value assert_equals: serialization should be canonical expected "\"a\" / 10px" but got "auto / 10px / \"a\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" / 20%" should set the property value assert_equals: serialization should be canonical expected "\"a\" / 20%" but got "auto / 20% / \"a\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" / 5fr" should set the property value assert_equals: serialization should be canonical expected "\"a\" / 5fr" but got "auto / 5fr / \"a\" / row / auto / auto"
-FAIL e.style['grid'] = "[a] \"a\"" should set the property value assert_equals: serialization should be canonical expected "[a] \"a\"" but got "[a] auto / none / \"a\" / row / auto / auto"
-FAIL e.style['grid'] = "[a] \"a\" [a]" should set the property value assert_equals: serialization should be canonical expected "[a] \"a\" [a]" but got "[a] auto [a] / none / \"a\" / row / auto / auto"
-FAIL e.style['grid'] = "[] \"a\"" should set the property value assert_equals: serialization should be canonical expected "\"a\"" but got "auto / none / \"a\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" [] [] \"b\"" should set the property value assert_equals: serialization should be canonical expected "\"a\" \"b\"" but got "auto auto / none / \"a\" \"b\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" [] \"b\"" should set the property value assert_equals: serialization should be canonical expected "\"a\" \"b\"" but got "auto auto / none / \"a\" \"b\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" [a] [b] \"b\"" should set the property value assert_equals: serialization should be canonical expected "\"a\" [a b] \"b\"" but got "auto [a b] auto / none / \"a\" \"b\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" [a] \"b\"" should set the property value assert_equals: serialization should be canonical expected "\"a\" [a] \"b\"" but got "auto [a] auto / none / \"a\" \"b\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" / 0" should set the property value assert_equals: serialization should be canonical expected "\"a\" / 0px" but got "auto / 0px / \"a\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" 10px / 10px" should set the property value assert_equals: serialization should be canonical expected "\"a\" 10px / 10px" but got "10px / 10px / \"a\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" [a] \"b\" 10px" should set the property value assert_equals: serialization should be canonical expected "\"a\" [a] \"b\" 10px" but got "auto [a] 10px / none / \"a\" \"b\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" [a] \"b\" 10px [a]" should set the property value assert_equals: serialization should be canonical expected "\"a\" [a] \"b\" 10px [a]" but got "auto [a] 10px [a] / none / \"a\" \"b\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" [a] [a] \"b\" 10px" should set the property value assert_equals: serialization should be canonical expected "\"a\" [a a] \"b\" 10px" but got "auto [a a] 10px / none / \"a\" \"b\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" [a] [] \"b\" 10px" should set the property value assert_equals: serialization should be canonical expected "\"a\" [a] \"b\" 10px" but got "auto [a] 10px / none / \"a\" \"b\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" 10px [a] \"b\" [a]" should set the property value assert_equals: serialization should be canonical expected "\"a\" 10px [a] \"b\" [a]" but got "10px [a] auto [a] / none / \"a\" \"b\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" [a] \"b\" [a]" should set the property value assert_equals: serialization should be canonical expected "\"a\" [a] \"b\" [a]" but got "auto [a] auto [a] / none / \"a\" \"b\" / row / auto / auto"
-FAIL e.style['grid'] = "[a] \"a\" [a] \"b\" [a]" should set the property value assert_equals: serialization should be canonical expected "[a] \"a\" [a] \"b\" [a]" but got "[a] auto [a] auto [a] / none / \"a\" \"b\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" \"a\" [a] \"b\" [a]" should set the property value assert_equals: serialization should be canonical expected "\"a\" \"a\" [a] \"b\" [a]" but got "auto auto [a] auto [a] / none / \"a\" \"a\" \"b\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" [a] \"b\" [a] / 0" should set the property value assert_equals: serialization should be canonical expected "\"a\" [a] \"b\" [a] / 0px" but got "auto [a] auto [a] / 0px / \"a\" \"b\" / row / auto / auto"
-FAIL e.style['grid'] = "\"a\" \"a\" [a] [a] \"b\" / auto" should set the property value assert_equals: serialization should be canonical expected "\"a\" \"a\" [a a] \"b\" / auto" but got "auto auto [a a] auto / auto / \"a\" \"a\" \"b\" / row / auto / auto"
+PASS e.style['grid'] = "none" should set the property value
+PASS e.style['grid'] = "none / none" should set the property value
+PASS e.style['grid'] = "auto / auto" should set the property value
+PASS e.style['grid'] = "none / [a] 0px" should set the property value
+PASS e.style['grid'] = "none / [] 0px" should set the property value
+PASS e.style['grid'] = "[a] 10px / auto" should set the property value
+PASS e.style['grid'] = "[a] 10px / none" should set the property value
+PASS e.style['grid'] = "[] 10px [] / [] auto []" should set the property value
+PASS e.style['grid'] = "[a] \"a\" 10px" should set the property value
+PASS e.style['grid'] = "[a] \"a\" 10px []" should set the property value
+PASS e.style['grid'] = "\"a\" 10px" should set the property value
+PASS e.style['grid'] = "[] \"a\" 10px" should set the property value
+PASS e.style['grid'] = "[a] \"a\" 10px [a]" should set the property value
+PASS e.style['grid'] = "\"a\"" should set the property value
+PASS e.style['grid'] = "\"a\" auto" should set the property value
+PASS e.style['grid'] = "\"a\" / 10px" should set the property value
+PASS e.style['grid'] = "\"a\" / 20%" should set the property value
+PASS e.style['grid'] = "\"a\" / 5fr" should set the property value
+PASS e.style['grid'] = "[a] \"a\"" should set the property value
+PASS e.style['grid'] = "[a] \"a\" [a]" should set the property value
+PASS e.style['grid'] = "[] \"a\"" should set the property value
+PASS e.style['grid'] = "\"a\" [] [] \"b\"" should set the property value
+PASS e.style['grid'] = "\"a\" [] \"b\"" should set the property value
+PASS e.style['grid'] = "\"a\" [a] [b] \"b\"" should set the property value
+PASS e.style['grid'] = "\"a\" [a] \"b\"" should set the property value
+PASS e.style['grid'] = "\"a\" / 0" should set the property value
+PASS e.style['grid'] = "\"a\" 10px / 10px" should set the property value
+PASS e.style['grid'] = "\"a\" [a] \"b\" 10px" should set the property value
+PASS e.style['grid'] = "\"a\" [a] \"b\" 10px [a]" should set the property value
+PASS e.style['grid'] = "\"a\" [a] [a] \"b\" 10px" should set the property value
+PASS e.style['grid'] = "\"a\" [a] [] \"b\" 10px" should set the property value
+PASS e.style['grid'] = "\"a\" 10px [a] \"b\" [a]" should set the property value
+PASS e.style['grid'] = "\"a\" [a] \"b\" [a]" should set the property value
+PASS e.style['grid'] = "[a] \"a\" [a] \"b\" [a]" should set the property value
+PASS e.style['grid'] = "\"a\" \"a\" [a] \"b\" [a]" should set the property value
+PASS e.style['grid'] = "\"a\" [a] \"b\" [a] / 0" should set the property value
+PASS e.style['grid'] = "\"a\" \"a\" [a] [a] \"b\" / auto" should set the property value
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-shorthand-valid-expected.txt (291954 => 291955)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-shorthand-valid-expected.txt	2022-03-28 02:35:11 UTC (rev 291954)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-shorthand-valid-expected.txt	2022-03-28 03:03:36 UTC (rev 291955)
@@ -1,39 +1,39 @@
 
-FAIL e.style['grid-template'] = "none" should set the property value assert_equals: serialization should be canonical expected "none" but got "none / none / none"
-FAIL e.style['grid-template'] = "none / none" should set the property value assert_equals: serialization should be canonical expected "none" but got "none / none / none"
-FAIL e.style['grid-template'] = "auto / auto" should set the property value assert_equals: serialization should be canonical expected "auto / auto" but got "auto / auto / none"
-FAIL e.style['grid-template'] = "none / [a] 0px" should set the property value assert_equals: serialization should be canonical expected "none / [a] 0px" but got "none / [a] 0px / none"
-FAIL e.style['grid-template'] = "none / [] 0px" should set the property value assert_equals: serialization should be canonical expected "none / 0px" but got "none / 0px / none"
-FAIL e.style['grid-template'] = "[a] 10px / auto" should set the property value assert_equals: serialization should be canonical expected "[a] 10px / auto" but got "[a] 10px / auto / none"
-FAIL e.style['grid-template'] = "[a] 10px / none" should set the property value assert_equals: serialization should be canonical expected "[a] 10px / none" but got "[a] 10px / none / none"
-FAIL e.style['grid-template'] = "[] 10px [] / [] auto []" should set the property value assert_equals: serialization should be canonical expected "10px / auto" but got "10px / auto / none"
-FAIL e.style['grid-template'] = "[a] \"a\" 10px" should set the property value assert_equals: serialization should be canonical expected "[a] \"a\" 10px" but got "[a] 10px / none / \"a\""
-FAIL e.style['grid-template'] = "[a] \"a\" 10px []" should set the property value assert_equals: serialization should be canonical expected "[a] \"a\" 10px" but got "[a] 10px / none / \"a\""
-FAIL e.style['grid-template'] = "\"a\" 10px" should set the property value assert_equals: serialization should be canonical expected "\"a\" 10px" but got "10px / none / \"a\""
-FAIL e.style['grid-template'] = "[] \"a\" 10px" should set the property value assert_equals: serialization should be canonical expected "\"a\" 10px" but got "10px / none / \"a\""
-FAIL e.style['grid-template'] = "[a] \"a\" 10px [a]" should set the property value assert_equals: serialization should be canonical expected "[a] \"a\" 10px [a]" but got "[a] 10px [a] / none / \"a\""
-FAIL e.style['grid-template'] = "\"a\"" should set the property value assert_equals: serialization should be canonical expected "\"a\"" but got "auto / none / \"a\""
-FAIL e.style['grid-template'] = "\"a\" auto" should set the property value assert_equals: serialization should be canonical expected "\"a\"" but got "auto / none / \"a\""
-FAIL e.style['grid-template'] = "\"a\" / 10px" should set the property value assert_equals: serialization should be canonical expected "\"a\" / 10px" but got "auto / 10px / \"a\""
-FAIL e.style['grid-template'] = "\"a\" / 20%" should set the property value assert_equals: serialization should be canonical expected "\"a\" / 20%" but got "auto / 20% / \"a\""
-FAIL e.style['grid-template'] = "\"a\" / 5fr" should set the property value assert_equals: serialization should be canonical expected "\"a\" / 5fr" but got "auto / 5fr / \"a\""
-FAIL e.style['grid-template'] = "[a] \"a\"" should set the property value assert_equals: serialization should be canonical expected "[a] \"a\"" but got "[a] auto / none / \"a\""
-FAIL e.style['grid-template'] = "[a] \"a\" [a]" should set the property value assert_equals: serialization should be canonical expected "[a] \"a\" [a]" but got "[a] auto [a] / none / \"a\""
-FAIL e.style['grid-template'] = "[] \"a\"" should set the property value assert_equals: serialization should be canonical expected "\"a\"" but got "auto / none / \"a\""
-FAIL e.style['grid-template'] = "\"a\" [] [] \"b\"" should set the property value assert_equals: serialization should be canonical expected "\"a\" \"b\"" but got "auto auto / none / \"a\" \"b\""
-FAIL e.style['grid-template'] = "\"a\" [] \"b\"" should set the property value assert_equals: serialization should be canonical expected "\"a\" \"b\"" but got "auto auto / none / \"a\" \"b\""
-FAIL e.style['grid-template'] = "\"a\" [a] [b] \"b\"" should set the property value assert_equals: serialization should be canonical expected "\"a\" [a b] \"b\"" but got "auto [a b] auto / none / \"a\" \"b\""
-FAIL e.style['grid-template'] = "\"a\" [a] \"b\"" should set the property value assert_equals: serialization should be canonical expected "\"a\" [a] \"b\"" but got "auto [a] auto / none / \"a\" \"b\""
-FAIL e.style['grid-template'] = "\"a\" / 0" should set the property value assert_equals: serialization should be canonical expected "\"a\" / 0px" but got "auto / 0px / \"a\""
-FAIL e.style['grid-template'] = "\"a\" 10px / 10px" should set the property value assert_equals: serialization should be canonical expected "\"a\" 10px / 10px" but got "10px / 10px / \"a\""
-FAIL e.style['grid-template'] = "\"a\" [a] \"b\" 10px" should set the property value assert_equals: serialization should be canonical expected "\"a\" [a] \"b\" 10px" but got "auto [a] 10px / none / \"a\" \"b\""
-FAIL e.style['grid-template'] = "\"a\" [a] \"b\" 10px [a]" should set the property value assert_equals: serialization should be canonical expected "\"a\" [a] \"b\" 10px [a]" but got "auto [a] 10px [a] / none / \"a\" \"b\""
-FAIL e.style['grid-template'] = "\"a\" [a] [a] \"b\" 10px" should set the property value assert_equals: serialization should be canonical expected "\"a\" [a a] \"b\" 10px" but got "auto [a a] 10px / none / \"a\" \"b\""
-FAIL e.style['grid-template'] = "\"a\" [a] [] \"b\" 10px" should set the property value assert_equals: serialization should be canonical expected "\"a\" [a] \"b\" 10px" but got "auto [a] 10px / none / \"a\" \"b\""
-FAIL e.style['grid-template'] = "\"a\" 10px [a] \"b\" [a]" should set the property value assert_equals: serialization should be canonical expected "\"a\" 10px [a] \"b\" [a]" but got "10px [a] auto [a] / none / \"a\" \"b\""
-FAIL e.style['grid-template'] = "\"a\" [a] \"b\" [a]" should set the property value assert_equals: serialization should be canonical expected "\"a\" [a] \"b\" [a]" but got "auto [a] auto [a] / none / \"a\" \"b\""
-FAIL e.style['grid-template'] = "[a] \"a\" [a] \"b\" [a]" should set the property value assert_equals: serialization should be canonical expected "[a] \"a\" [a] \"b\" [a]" but got "[a] auto [a] auto [a] / none / \"a\" \"b\""
-FAIL e.style['grid-template'] = "\"a\" \"a\" [a] \"b\" [a]" should set the property value assert_equals: serialization should be canonical expected "\"a\" \"a\" [a] \"b\" [a]" but got "auto auto [a] auto [a] / none / \"a\" \"a\" \"b\""
-FAIL e.style['grid-template'] = "\"a\" [a] \"b\" [a] / 0" should set the property value assert_equals: serialization should be canonical expected "\"a\" [a] \"b\" [a] / 0px" but got "auto [a] auto [a] / 0px / \"a\" \"b\""
-FAIL e.style['grid-template'] = "\"a\" \"a\" [a] [a] \"b\" / auto" should set the property value assert_equals: serialization should be canonical expected "\"a\" \"a\" [a a] \"b\" / auto" but got "auto auto [a a] auto / auto / \"a\" \"a\" \"b\""
+PASS e.style['grid-template'] = "none" should set the property value
+PASS e.style['grid-template'] = "none / none" should set the property value
+PASS e.style['grid-template'] = "auto / auto" should set the property value
+PASS e.style['grid-template'] = "none / [a] 0px" should set the property value
+PASS e.style['grid-template'] = "none / [] 0px" should set the property value
+PASS e.style['grid-template'] = "[a] 10px / auto" should set the property value
+PASS e.style['grid-template'] = "[a] 10px / none" should set the property value
+PASS e.style['grid-template'] = "[] 10px [] / [] auto []" should set the property value
+PASS e.style['grid-template'] = "[a] \"a\" 10px" should set the property value
+PASS e.style['grid-template'] = "[a] \"a\" 10px []" should set the property value
+PASS e.style['grid-template'] = "\"a\" 10px" should set the property value
+PASS e.style['grid-template'] = "[] \"a\" 10px" should set the property value
+PASS e.style['grid-template'] = "[a] \"a\" 10px [a]" should set the property value
+PASS e.style['grid-template'] = "\"a\"" should set the property value
+PASS e.style['grid-template'] = "\"a\" auto" should set the property value
+PASS e.style['grid-template'] = "\"a\" / 10px" should set the property value
+PASS e.style['grid-template'] = "\"a\" / 20%" should set the property value
+PASS e.style['grid-template'] = "\"a\" / 5fr" should set the property value
+PASS e.style['grid-template'] = "[a] \"a\"" should set the property value
+PASS e.style['grid-template'] = "[a] \"a\" [a]" should set the property value
+PASS e.style['grid-template'] = "[] \"a\"" should set the property value
+PASS e.style['grid-template'] = "\"a\" [] [] \"b\"" should set the property value
+PASS e.style['grid-template'] = "\"a\" [] \"b\"" should set the property value
+PASS e.style['grid-template'] = "\"a\" [a] [b] \"b\"" should set the property value
+PASS e.style['grid-template'] = "\"a\" [a] \"b\"" should set the property value
+PASS e.style['grid-template'] = "\"a\" / 0" should set the property value
+PASS e.style['grid-template'] = "\"a\" 10px / 10px" should set the property value
+PASS e.style['grid-template'] = "\"a\" [a] \"b\" 10px" should set the property value
+PASS e.style['grid-template'] = "\"a\" [a] \"b\" 10px [a]" should set the property value
+PASS e.style['grid-template'] = "\"a\" [a] [a] \"b\" 10px" should set the property value
+PASS e.style['grid-template'] = "\"a\" [a] [] \"b\" 10px" should set the property value
+PASS e.style['grid-template'] = "\"a\" 10px [a] \"b\" [a]" should set the property value
+PASS e.style['grid-template'] = "\"a\" [a] \"b\" [a]" should set the property value
+PASS e.style['grid-template'] = "[a] \"a\" [a] \"b\" [a]" should set the property value
+PASS e.style['grid-template'] = "\"a\" \"a\" [a] \"b\" [a]" should set the property value
+PASS e.style['grid-template'] = "\"a\" [a] \"b\" [a] / 0" should set the property value
+PASS e.style['grid-template'] = "\"a\" \"a\" [a] [a] \"b\" / auto" should set the property value
 

Modified: trunk/Source/WebCore/ChangeLog (291954 => 291955)


--- trunk/Source/WebCore/ChangeLog	2022-03-28 02:35:11 UTC (rev 291954)
+++ trunk/Source/WebCore/ChangeLog	2022-03-28 03:03:36 UTC (rev 291955)
@@ -1,3 +1,27 @@
+2022-03-27  Matt Woodrow  <[email protected]>
+
+        Fix serialization of grid-template
+        https://bugs.webkit.org/show_bug.cgi?id=237868
+
+        Reviewed by Dean Jackson.
+
+        Existing WPT tests marked as passing.
+
+        * css/CSSGridTemplateAreasValue.cpp:
+        (WebCore::CSSGridTemplateAreasValue::stringForRow):
+        * css/CSSGridTemplateAreasValue.h:
+        * css/StyleProperties.cpp:
+        (WebCore::StyleProperties::getPropertyValue const):
+        (WebCore::isNoneValue):
+        (WebCore::isValueID):
+        (WebCore::StyleProperties::getGridTemplateValue const):
+        (WebCore::StyleProperties::getGridValue const):
+        * css/StyleProperties.h:
+
+        Creates custom serialization for grid-template that handles the case
+        where no areas were specified (and omits trailing 'none' value), as well as handling
+        the case where areas are interleaved within the tracks definitions.
+
 2022-03-27  Daniel Adams  <[email protected]>
 
         Sort IDL extended attributes alphabetically

Modified: trunk/Source/WebCore/css/CSSGridTemplateAreasValue.cpp (291954 => 291955)


--- trunk/Source/WebCore/css/CSSGridTemplateAreasValue.cpp	2022-03-28 02:35:11 UTC (rev 291954)
+++ trunk/Source/WebCore/css/CSSGridTemplateAreasValue.cpp	2022-03-28 03:03:36 UTC (rev 291955)
@@ -66,6 +66,34 @@
     return "."_s;
 }
 
+String CSSGridTemplateAreasValue::stringForRow(size_t row)
+{
+    Vector<String> columns;
+    columns.grow(m_columnCount);
+
+    for (const auto& it : m_gridAreaMap) {
+        const GridArea& area = it.value;
+        if (row >= area.rows.startLine() && row < area.rows.endLine()) {
+            for (unsigned i = area.columns.startLine(); i < area.columns.endLine(); i++)
+                columns[i] = it.key;
+        }
+    }
+
+    StringBuilder builder;
+    bool first = true;
+    for (const auto& name : columns) {
+        if (!first)
+            builder.append(" ");
+        first = false;
+
+        if (name.isNull())
+            builder.append(".");
+        else
+            builder.append(name);
+    }
+    return builder.toString();
+}
+
 String CSSGridTemplateAreasValue::customCSSText() const
 {
     StringBuilder builder;

Modified: trunk/Source/WebCore/css/CSSGridTemplateAreasValue.h (291954 => 291955)


--- trunk/Source/WebCore/css/CSSGridTemplateAreasValue.h	2022-03-28 02:35:11 UTC (rev 291954)
+++ trunk/Source/WebCore/css/CSSGridTemplateAreasValue.h	2022-03-28 03:03:36 UTC (rev 291955)
@@ -53,6 +53,8 @@
 
     bool equals(const CSSGridTemplateAreasValue&) const;
 
+    String stringForRow(size_t row);
+
 private:
     CSSGridTemplateAreasValue(const NamedGridAreaMap&, size_t rowCount, size_t columnCount);
 

Modified: trunk/Source/WebCore/css/StyleProperties.cpp (291954 => 291955)


--- trunk/Source/WebCore/css/StyleProperties.cpp	2022-03-28 02:35:11 UTC (rev 291954)
+++ trunk/Source/WebCore/css/StyleProperties.cpp	2022-03-28 03:03:36 UTC (rev 291955)
@@ -26,6 +26,8 @@
 #include "CSSComputedStyleDeclaration.h"
 #include "CSSCustomPropertyValue.h"
 #include "CSSDeferredParser.h"
+#include "CSSGridLineNamesValue.h"
+#include "CSSGridTemplateAreasValue.h"
 #include "CSSOffsetRotateValue.h"
 #include "CSSParser.h"
 #include "CSSPendingSubstitutionValue.h"
@@ -255,9 +257,9 @@
     case CSSPropertyGridArea:
         return getGridShorthandValue(gridAreaShorthand());
     case CSSPropertyGridTemplate:
-        return getGridShorthandValue(gridTemplateShorthand());
+        return getGridTemplateValue();
     case CSSPropertyGrid:
-        return getGridShorthandValue(gridShorthand());
+        return getGridValue();
     case CSSPropertyGridColumn:
         return getGridShorthandValue(gridColumnShorthand());
     case CSSPropertyGridRow:
@@ -836,6 +838,102 @@
     return result.isEmpty() ? String() : result.toString();
 }
 
+static bool isNoneValue(const RefPtr<CSSValue>& value)
+{
+    return value && value->isPrimitiveValue() && downcast<CSSPrimitiveValue>(value.get())->isValueID() && downcast<CSSPrimitiveValue>(value.get())->valueID() == CSSValueNone;
+}
+
+static bool isValueID(const Ref<CSSValue>& value, CSSValueID id)
+{
+    return value->isPrimitiveValue() && downcast<CSSPrimitiveValue>(value.get()).isValueID() && downcast<CSSPrimitiveValue>(value.get()).valueID() == id;
+}
+
+static bool isValueID(const RefPtr<CSSValue>& value, CSSValueID id)
+{
+    return value && isValueID(*value, id);
+}
+
+String StyleProperties::getGridTemplateValue() const
+{
+    StringBuilder result;
+    int areasIndex = findPropertyIndex(CSSPropertyGridTemplateAreas);
+    if (areasIndex == -1)
+        return String();
+    auto rows = getPropertyCSSValue(CSSPropertyGridTemplateRows);
+    if (!rows)
+        return String();
+    auto columns = getPropertyCSSValue(CSSPropertyGridTemplateColumns);
+    if (!columns)
+        return String();
+
+    auto areas = propertyAt(areasIndex);
+    if (isValueID(areas.value(), CSSValueNone) || areas.value()->isInitialValue()) {
+        String rowsText = rows->cssText();
+        result.append(rowsText);
+
+        String columnsText = columns->cssText();
+        // If the values are identical, and either a css wide keyword
+        // or 'none', then we can just output it once.
+        if (columnsText != rowsText || (!isCSSWideValueKeyword(columnsText) && !isValueID(columns, CSSValueNone))) {
+            result.append(" / ");
+            result.append(columnsText);
+        }
+        return result.toString();
+    }
+    // We only want to try serializing the interleaved areas/templates
+    // format if it was set from this shorthand, since that automatically
+    // excludes values that can't be represented in this format (subgrid,
+    // and the repeat() function).
+    if (!areas.toCSSProperty().isSetFromShorthand())
+        return String();
+
+    ASSERT(is<CSSValueList>(rows));
+    ASSERT(is<CSSGridTemplateAreasValue>(areas.value()));
+    auto& areasValue = downcast<CSSGridTemplateAreasValue>(*areas.value());
+    bool first = true;
+    unsigned row = 0;
+    for (auto& currentValue : downcast<CSSValueList>(*rows)) {
+        if (!first)
+            result.append(" ");
+        first = false;
+
+        if (is<CSSGridLineNamesValue>(currentValue))
+            result.append(currentValue->cssText());
+        else {
+            result.append("\"");
+            result.append(areasValue.stringForRow(row));
+            result.append("\"");
+
+            if (!isValueID(currentValue, CSSValueAuto)) {
+                result.append(" ");
+                result.append(currentValue->cssText());
+            }
+            row++;
+        }
+    }
+
+    String columnsText = columns->cssText();
+    if (!isNoneValue(columns)) {
+        result.append(" / ");
+        result.append(columnsText);
+    }
+
+    return result.toString();
+}
+
+String StyleProperties::getGridValue() const
+{
+    // If none of the implicit track properties have been set, then
+    // this shorthand can be represented using the grid-template shorthand
+    // format.
+    if (isValueID(getPropertyCSSValue(CSSPropertyGridAutoColumns), CSSValueAuto)
+        && isValueID(getPropertyCSSValue(CSSPropertyGridAutoRows), CSSValueAuto)
+        && isValueID(getPropertyCSSValue(CSSPropertyGridAutoFlow), CSSValueRow)) {
+        return getGridTemplateValue();
+    }
+    return getGridShorthandValue(gridShorthand());
+}
+
 String StyleProperties::getGridShorthandValue(const StylePropertyShorthand& shorthand) const
 {
     return getShorthandValue(shorthand, " / ");

Modified: trunk/Source/WebCore/css/StyleProperties.h (291954 => 291955)


--- trunk/Source/WebCore/css/StyleProperties.h	2022-03-28 02:35:11 UTC (rev 291954)
+++ trunk/Source/WebCore/css/StyleProperties.h	2022-03-28 03:03:36 UTC (rev 291955)
@@ -162,6 +162,8 @@
 
 private:
     String getGridShorthandValue(const StylePropertyShorthand&) const;
+    String getGridTemplateValue() const;
+    String getGridValue() const;
     String getShorthandValue(const StylePropertyShorthand&, const char* separator = " ") const;
     String getCommonValue(const StylePropertyShorthand&) const;
     String getAlignmentShorthandValue(const StylePropertyShorthand&) const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to