LayoutTests/imported/w3c:
[css-grid] Avoid serializing [] in grid-template* specified values
https://bugs.webkit.org/show_bug.cgi?id=204501
Reviewed by Javier Fernandez.
Update tests results, several tests are now passing.
Other are still failing due to different bugs like webkit.org/b/204508.
* web-platform-tests/css/css-grid/parsing/grid-shorthand-expected.txt:
* web-platform-tests/css/css-grid/parsing/grid-shorthand-valid-expected.txt:
* web-platform-tests/css/css-grid/parsing/grid-template-columns-valid-expected.txt:
* web-platform-tests/css/css-grid/parsing/grid-template-rows-valid-expected.txt:
* web-platform-tests/css/css-grid/parsing/grid-template-shorthand-expected.txt:
* web-platform-tests/css/css-grid/parsing/grid-template-shorthand-valid-expected.txt:
Source/WebCore:
[css-grid] Avoid serializing [] in grid-template-* specified values
https://bugs.webkit.org/show_bug.cgi?id=204501
Reviewed by Javier Fernandez.
Based on Blink r699101 by <ericwilligers@chromium.org>.
This patch discards empty list of line names when parsing grid-template-* properties.
That way we avoid these empty lists "[]" during serialization.
This was discussed at: https://github.com/w3c/csswg-drafts/issues/4173.
Several WPT tests are passing thanks to this change.
* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeGridLineNames):
(WebCore::consumeGridTrackList):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@252883 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog
index 83d0b3f..9f2d7ce 100644
--- a/LayoutTests/imported/w3c/ChangeLog
+++ b/LayoutTests/imported/w3c/ChangeLog
@@ -1,3 +1,20 @@
+2019-11-26 Manuel Rego Casasnovas <rego@igalia.com>
+
+ [css-grid] Avoid serializing [] in grid-template* specified values
+ https://bugs.webkit.org/show_bug.cgi?id=204501
+
+ Reviewed by Javier Fernandez.
+
+ Update tests results, several tests are now passing.
+ Other are still failing due to different bugs like webkit.org/b/204508.
+
+ * web-platform-tests/css/css-grid/parsing/grid-shorthand-expected.txt:
+ * web-platform-tests/css/css-grid/parsing/grid-shorthand-valid-expected.txt:
+ * web-platform-tests/css/css-grid/parsing/grid-template-columns-valid-expected.txt:
+ * web-platform-tests/css/css-grid/parsing/grid-template-rows-valid-expected.txt:
+ * web-platform-tests/css/css-grid/parsing/grid-template-shorthand-expected.txt:
+ * web-platform-tests/css/css-grid/parsing/grid-template-shorthand-valid-expected.txt:
+
2019-11-25 Manuel Rego Casasnovas <rego@igalia.com>
[css-grid] Updating WPT parsing tests
diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-shorthand-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-shorthand-expected.txt
index 90d6de0..2384b04a2 100644
--- a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-shorthand-expected.txt
+++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-shorthand-expected.txt
@@ -38,8 +38,8 @@
FAIL e.style['grid'] = " [] \"a a a\" [] [] \"b b b\" 1fr [] / [] auto 1fr [] auto []" should set grid-auto-flow assert_equals: grid-auto-flow should be canonical expected "row" but got "initial"
FAIL e.style['grid'] = " [] \"a a a\" [] [] \"b b b\" 1fr [] / [] auto 1fr [] auto []" should set grid-auto-rows assert_equals: grid-auto-rows should be canonical expected "auto" but got "initial"
PASS e.style['grid'] = " [] \"a a a\" [] [] \"b b b\" 1fr [] / [] auto 1fr [] auto []" should set grid-template-areas
-FAIL e.style['grid'] = " [] \"a a a\" [] [] \"b b b\" 1fr [] / [] auto 1fr [] auto []" should set grid-template-columns assert_equals: grid-template-columns should be canonical expected "auto 1fr auto" but got "[] auto 1fr [] auto []"
-FAIL e.style['grid'] = " [] \"a a a\" [] [] \"b b b\" 1fr [] / [] auto 1fr [] auto []" should set grid-template-rows assert_equals: grid-template-rows should be canonical expected "auto 1fr" but got "[] auto [] [] 1fr []"
+PASS e.style['grid'] = " [] \"a a a\" [] [] \"b b b\" 1fr [] / [] auto 1fr [] auto []" should set grid-template-columns
+PASS e.style['grid'] = " [] \"a a a\" [] [] \"b b b\" 1fr [] / [] auto 1fr [] auto []" should set grid-template-rows
PASS e.style['grid'] = " [] \"a a a\" [] [] \"b b b\" 1fr [] / [] auto 1fr [] auto []" should not set unrelated longhands
PASS e.style['grid'] = "10px / auto-flow dense 20px" should set grid-auto-columns
PASS e.style['grid'] = "10px / auto-flow dense 20px" should set grid-auto-flow
diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-shorthand-valid-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-shorthand-valid-expected.txt
index dcf60f9..2c7dda8 100644
--- a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-shorthand-valid-expected.txt
+++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-shorthand-valid-expected.txt
@@ -1,13 +1,13 @@
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"
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"
-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"
+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"
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"
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"
-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"
+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"
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\""
-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\""
+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\""
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\""
-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\""
+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\""
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\""
diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-columns-valid-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-columns-valid-expected.txt
index fdfc411..f0dedf9 100644
--- a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-columns-valid-expected.txt
+++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-columns-valid-expected.txt
@@ -22,12 +22,12 @@
PASS e.style['grid-template-columns'] = "fit-content(calc(-0.5em + 10px))" should set the property value
PASS e.style['grid-template-columns'] = "fit-content(calc(0.5em + 10px))" should set the property value
PASS e.style['grid-template-columns'] = "fit-content(calc(30% + 40vw))" should set the property value
-FAIL e.style['grid-template-columns'] = "repeat(1, [] 10px [])" should set the property value assert_equals: serialization should be canonical expected "repeat(1, 10px)" but got "repeat(1, [] 10px [])"
+PASS e.style['grid-template-columns'] = "repeat(1, [] 10px [])" should set the property value
PASS e.style['grid-template-columns'] = "repeat(1, [one two] 20%)" should set the property value
PASS e.style['grid-template-columns'] = "repeat(2, minmax(10px, auto))" should set the property value
PASS e.style['grid-template-columns'] = "repeat(2, fit-content(20%) [three four] 30px 40px [five six])" should set the property value
PASS e.style['grid-template-columns'] = "min-content repeat(5, minmax(10px, auto))" should set the property value
-FAIL e.style['grid-template-columns'] = "[] 150px [] 1fr []" should set the property value assert_equals: serialization should be canonical expected "150px 1fr" but got "[] 150px [] 1fr []"
+PASS e.style['grid-template-columns'] = "[] 150px [] 1fr []" should set the property value
PASS e.style['grid-template-columns'] = "repeat(auto-fill, 10px)" should set the property value
PASS e.style['grid-template-columns'] = "repeat(auto-fit, [one] 20%)" should set the property value
PASS e.style['grid-template-columns'] = "repeat(auto-fill, minmax(30px, 5fr) [two])" should set the property value
diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-rows-valid-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-rows-valid-expected.txt
index 37286f3..8a9cc57 100644
--- a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-rows-valid-expected.txt
+++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-rows-valid-expected.txt
@@ -22,12 +22,12 @@
PASS e.style['grid-template-rows'] = "fit-content(calc(-0.5em + 10px))" should set the property value
PASS e.style['grid-template-rows'] = "fit-content(calc(0.5em + 10px))" should set the property value
PASS e.style['grid-template-rows'] = "fit-content(calc(30% + 40vw))" should set the property value
-FAIL e.style['grid-template-rows'] = "repeat(1, [] 10px [])" should set the property value assert_equals: serialization should be canonical expected "repeat(1, 10px)" but got "repeat(1, [] 10px [])"
+PASS e.style['grid-template-rows'] = "repeat(1, [] 10px [])" should set the property value
PASS e.style['grid-template-rows'] = "repeat(1, [one two] 20%)" should set the property value
PASS e.style['grid-template-rows'] = "repeat(2, minmax(10px, auto))" should set the property value
PASS e.style['grid-template-rows'] = "repeat(2, fit-content(20%) [three four] 30px 40px [five six])" should set the property value
PASS e.style['grid-template-rows'] = "min-content repeat(5, minmax(10px, auto))" should set the property value
-FAIL e.style['grid-template-rows'] = "[] 150px [] 1fr []" should set the property value assert_equals: serialization should be canonical expected "150px 1fr" but got "[] 150px [] 1fr []"
+PASS e.style['grid-template-rows'] = "[] 150px [] 1fr []" should set the property value
PASS e.style['grid-template-rows'] = "repeat(auto-fill, 10px)" should set the property value
PASS e.style['grid-template-rows'] = "repeat(auto-fit, [one] 20%)" should set the property value
PASS e.style['grid-template-rows'] = "repeat(auto-fill, minmax(30px, 5fr) [two])" should set the property value
diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-shorthand-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-shorthand-expected.txt
index 2e368e0..dd61e69 100644
--- a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-shorthand-expected.txt
+++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-shorthand-expected.txt
@@ -20,7 +20,7 @@
PASS e.style['grid-template'] = " \"a a a\" \"b b b\" 1fr/ auto 1fr auto" should set grid-template-rows
PASS e.style['grid-template'] = " \"a a a\" \"b b b\" 1fr/ auto 1fr auto" should not set unrelated longhands
PASS e.style['grid-template'] = " [] \"a a a\" [] [] \"b b b\" 1fr [] / [] auto 1fr [] auto []" should set grid-template-areas
-FAIL e.style['grid-template'] = " [] \"a a a\" [] [] \"b b b\" 1fr [] / [] auto 1fr [] auto []" should set grid-template-columns assert_equals: grid-template-columns should be canonical expected "auto 1fr auto" but got "[] auto 1fr [] auto []"
-FAIL e.style['grid-template'] = " [] \"a a a\" [] [] \"b b b\" 1fr [] / [] auto 1fr [] auto []" should set grid-template-rows assert_equals: grid-template-rows should be canonical expected "auto 1fr" but got "[] auto [] [] 1fr []"
+PASS e.style['grid-template'] = " [] \"a a a\" [] [] \"b b b\" 1fr [] / [] auto 1fr [] auto []" should set grid-template-columns
+PASS e.style['grid-template'] = " [] \"a a a\" [] [] \"b b b\" 1fr [] / [] auto 1fr [] auto []" should set grid-template-rows
PASS e.style['grid-template'] = " [] \"a a a\" [] [] \"b b b\" 1fr [] / [] auto 1fr [] auto []" should not set unrelated longhands
diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-shorthand-valid-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-shorthand-valid-expected.txt
index 113b1f8..d002f51 100644
--- a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-shorthand-valid-expected.txt
+++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-shorthand-valid-expected.txt
@@ -1,13 +1,13 @@
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'] = "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'] = "[] 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] \"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\" 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\""
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 424b8af..8838d3e 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,23 @@
+2019-11-26 Manuel Rego Casasnovas <rego@igalia.com>
+
+ [css-grid] Avoid serializing [] in grid-template-* specified values
+ https://bugs.webkit.org/show_bug.cgi?id=204501
+
+ Reviewed by Javier Fernandez.
+
+ Based on Blink r699101 by <ericwilligers@chromium.org>.
+
+ This patch discards empty list of line names when parsing grid-template-* properties.
+ That way we avoid these empty lists "[]" during serialization.
+
+ This was discussed at: https://github.com/w3c/csswg-drafts/issues/4173.
+
+ Several WPT tests are passing thanks to this change.
+
+ * css/parser/CSSPropertyParser.cpp:
+ (WebCore::consumeGridLineNames):
+ (WebCore::consumeGridTrackList):
+
2019-11-26 Carlos Garcia Campos <cgarcia@igalia.com>
[GStreamer] Cache the CString returned by String::utf8()
diff --git a/Source/WebCore/css/parser/CSSPropertyParser.cpp b/Source/WebCore/css/parser/CSSPropertyParser.cpp
index f91cd78de..e7a2b44 100644
--- a/Source/WebCore/css/parser/CSSPropertyParser.cpp
+++ b/Source/WebCore/css/parser/CSSPropertyParser.cpp
@@ -3341,7 +3341,7 @@
return consumeGridBreadth(range, cssParserMode);
}
-// Appends to the passed in CSSGridLineNamesValue if any, otherwise creates a new one.
+// Appends to the passed in CSSGridLineNamesValue if any, otherwise creates a new one. Returns nullptr if an empty list is consumed.
static RefPtr<CSSGridLineNamesValue> consumeGridLineNames(CSSParserTokenRange& range, CSSGridLineNamesValue* lineNames = nullptr)
{
CSSParserTokenRange rangeCopy = range;
@@ -3356,7 +3356,7 @@
if (rangeCopy.consumeIncludingWhitespace().type() != RightBracketToken)
return nullptr;
range = rangeCopy;
- return result;
+ return result->length() ? result : nullptr;
}
static bool consumeGridTrackRepeatFunction(CSSParserTokenRange& range, CSSParserMode cssParserMode, CSSValueList& list, bool& isAutoRepeat, bool& allTracksAreFixedSized)
@@ -3419,12 +3419,11 @@
{
bool allowGridLineNames = trackListType != GridAuto;
RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated();
+ if (!allowGridLineNames && range.peek().type() == LeftBracketToken)
+ return nullptr;
RefPtr<CSSGridLineNamesValue> lineNames = consumeGridLineNames(range);
- if (lineNames) {
- if (!allowGridLineNames)
- return nullptr;
+ if (lineNames)
values->append(lineNames.releaseNonNull());
- }
bool allowRepeat = trackListType == GridTemplate;
bool seenAutoRepeat = false;
@@ -3448,12 +3447,11 @@
}
if (seenAutoRepeat && !allTracksAreFixedSized)
return nullptr;
+ if (!allowGridLineNames && range.peek().type() == LeftBracketToken)
+ return nullptr;
lineNames = consumeGridLineNames(range);
- if (lineNames) {
- if (!allowGridLineNames)
- return nullptr;
+ if (lineNames)
values->append(lineNames.releaseNonNull());
- }
} while (!range.atEnd() && range.peek().type() != DelimiterToken);
return values;
}