Title: [185492] trunk
- Revision
- 185492
- Author
- [email protected]
- Date
- 2015-06-12 01:19:36 -0700 (Fri, 12 Jun 2015)
Log Message
[CSS Grid Layout] Fix grid-template-areas parsing to avoid spaces
https://bugs.webkit.org/show_bug.cgi?id=145860
Reviewed by Sergio Villar Senin.
Source/WebCore:
The spec doesn't require to have spaces between unnamed and named areas
in grid-template-areas syntax. But spaces are currently required in our
code.
This was confirmed in the CSS WG mailing list:
https://lists.w3.org/Archives/Public/www-style/2015May/0239.html
This patch updates grid-template-areas parsing to allow the possibility
of removing spaces between unnamed and named areas.
Added new cases to fast/css-grid-layout/grid-template-areas-get-set.html.
* css/CSSParser.cpp:
(WebCore::parseGridTemplateAreasColumnNames): New helper method to
determine the column names split by white spaces or dots.
(WebCore::CSSParser::parseGridTemplateAreasRow): Use the new helper
method to get the column names.
(WebCore::containsOnlyDots): Deleted. Not needed anymore as
parseGridTemplateAreasColumnNames() is using a single dot for unnamed
grid areas (despite of being defined with 1 or more dots).
LayoutTests:
* fast/css-grid-layout/grid-template-areas-get-set-expected.txt:
* fast/css-grid-layout/grid-template-areas-get-set.html: Add new test
cases.
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (185491 => 185492)
--- trunk/LayoutTests/ChangeLog 2015-06-12 07:37:13 UTC (rev 185491)
+++ trunk/LayoutTests/ChangeLog 2015-06-12 08:19:36 UTC (rev 185492)
@@ -1,3 +1,14 @@
+2015-06-12 Manuel Rego Casasnovas <[email protected]>
+
+ [CSS Grid Layout] Fix grid-template-areas parsing to avoid spaces
+ https://bugs.webkit.org/show_bug.cgi?id=145860
+
+ Reviewed by Sergio Villar Senin.
+
+ * fast/css-grid-layout/grid-template-areas-get-set-expected.txt:
+ * fast/css-grid-layout/grid-template-areas-get-set.html: Add new test
+ cases.
+
2015-06-11 Zalan Bujtas <[email protected]>
Do not crash when the descendant frame tree is destroyed during layout.
Modified: trunk/LayoutTests/fast/css-grid-layout/grid-template-areas-get-set-expected.txt (185491 => 185492)
--- trunk/LayoutTests/fast/css-grid-layout/grid-template-areas-get-set-expected.txt 2015-06-12 07:37:13 UTC (rev 185491)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-template-areas-get-set-expected.txt 2015-06-12 08:19:36 UTC (rev 185492)
@@ -18,6 +18,10 @@
PASS getComputedStyle(gridWithComplexDotAreas).getPropertyValue('-webkit-grid-template-areas') is "\". header header .\" \". . . .\" \"nav main main aside\" \"nav main main aside\" \". . . aside\" \". footer footer aside\""
PASS getComputedStyle(gridWithComplexDotsAreas).getPropertyValue('-webkit-grid-template-areas') is "\". header header .\" \". . . .\" \"nav main main aside\" \"nav main main aside\" \". . . aside\" \". footer footer aside\""
PASS getComputedStyle(gridWithMixedDotAndDotsAreas).getPropertyValue('-webkit-grid-template-areas') is "\". title .\" \". main main\" \"nav . aside\" \". footer .\""
+PASS getComputedStyle(gridWithDotsNoSpaceTwoColumns).getPropertyValue('-webkit-grid-template-areas') is "\". A\" \". A\" \"B .\" \"B .\""
+PASS getComputedStyle(gridWithDotsNoSpaceThreeColumns).getPropertyValue('-webkit-grid-template-areas') is "\". A .\" \". A .\" \"B . C\" \"B . C\""
+PASS getComputedStyle(gridWithDotsNoSpaceFourColumns).getPropertyValue('-webkit-grid-template-areas') is "\". A . B\" \". A . B\" \". A . B\" \". A . B\" \"C . D .\" \"C . D .\" \"C . D .\" \"C . D .\""
+PASS getComputedStyle(gridWithDotsNoSpaceComplex).getPropertyValue('-webkit-grid-template-areas') is "\". title . nav . . main test\" \". title . nav . . main test\" \". title . nav . . main test\" \". title . nav . . main test\""
PASS getComputedStyle(gridWithHorizontalRectangle).getPropertyValue('-webkit-grid-template-areas') is "\"a a a\" \"a a a\""
PASS getComputedStyle(gridWithVerticalRectangle).getPropertyValue('-webkit-grid-template-areas') is "\"a a\" \"a a\" \"a a\""
Test grid-template-areas: initial
Modified: trunk/LayoutTests/fast/css-grid-layout/grid-template-areas-get-set.html (185491 => 185492)
--- trunk/LayoutTests/fast/css-grid-layout/grid-template-areas-get-set.html 2015-06-12 07:37:13 UTC (rev 185491)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-template-areas-get-set.html 2015-06-12 08:19:36 UTC (rev 185492)
@@ -75,6 +75,39 @@
". footer ......";
}
+#gridWithDotsNoSpaceTwoColumns {
+ -webkit-grid-template-areas: "...A"
+ ".A"
+ "B.."
+ "B.";
+}
+
+#gridWithDotsNoSpaceThreeColumns {
+ -webkit-grid-template-areas: "...A.."
+ ".A."
+ "B..C"
+ "B.C";
+}
+
+#gridWithDotsNoSpaceFourColumns {
+ -webkit-grid-template-areas: "...A..B"
+ ".A.B"
+ "..A.B"
+ ".A...B"
+ "C....D....."
+ "C.D."
+ "C...D."
+ "C.D....";
+}
+
+#gridWithDotsNoSpaceComplex {
+ -webkit-grid-template-areas: ".title...nav. ..main test"
+ "... title.nav... .main test"
+ "..title .. nav . .. main test"
+ ". title .nav... . main test";
+ ".... title ...nav ... ...main test";
+}
+
#gridWithHorizontalRectangle {
-webkit-grid-template-areas: "a a a"
"a a a";
@@ -104,6 +137,10 @@
<div class="grid" id="gridWithComplexDotAreas"></div>
<div class="grid" id="gridWithComplexDotsAreas"></div>
<div class="grid" id="gridWithMixedDotAndDotsAreas"></div>
+<div class="grid" id="gridWithDotsNoSpaceTwoColumns"></div>
+<div class="grid" id="gridWithDotsNoSpaceThreeColumns"></div>
+<div class="grid" id="gridWithDotsNoSpaceFourColumns"></div>
+<div class="grid" id="gridWithDotsNoSpaceComplex"></div>
<div class="grid" id="gridWithHorizontalRectangle"></div>
<div class="grid" id="gridWithVerticalRectangle"></div>
<script>
@@ -133,6 +170,10 @@
testGridTemplateAreas("gridWithComplexDotAreas", '". header header ." ". . . ." "nav main main aside" "nav main main aside" ". . . aside" ". footer footer aside"');
testGridTemplateAreas("gridWithComplexDotsAreas", '". header header ." ". . . ." "nav main main aside" "nav main main aside" ". . . aside" ". footer footer aside"');
testGridTemplateAreas("gridWithMixedDotAndDotsAreas", '". title ." ". main main" "nav . aside" ". footer ."');
+ testGridTemplateAreas("gridWithDotsNoSpaceTwoColumns", '". A" ". A" "B ." "B ."');
+ testGridTemplateAreas("gridWithDotsNoSpaceThreeColumns", '". A ." ". A ." "B . C" "B . C"');
+ testGridTemplateAreas("gridWithDotsNoSpaceFourColumns", '". A . B" ". A . B" ". A . B" ". A . B" "C . D ." "C . D ." "C . D ." "C . D ."');
+ testGridTemplateAreas("gridWithDotsNoSpaceComplex", '". title . nav . . main test" ". title . nav . . main test" ". title . nav . . main test" ". title . nav . . main test"');
testGridTemplateAreas("gridWithHorizontalRectangle", '"a a a" "a a a"');
testGridTemplateAreas("gridWithVerticalRectangle", '"a a" "a a" "a a"');
Modified: trunk/Source/WebCore/ChangeLog (185491 => 185492)
--- trunk/Source/WebCore/ChangeLog 2015-06-12 07:37:13 UTC (rev 185491)
+++ trunk/Source/WebCore/ChangeLog 2015-06-12 08:19:36 UTC (rev 185492)
@@ -1,3 +1,31 @@
+2015-06-12 Manuel Rego Casasnovas <[email protected]>
+
+ [CSS Grid Layout] Fix grid-template-areas parsing to avoid spaces
+ https://bugs.webkit.org/show_bug.cgi?id=145860
+
+ Reviewed by Sergio Villar Senin.
+
+ The spec doesn't require to have spaces between unnamed and named areas
+ in grid-template-areas syntax. But spaces are currently required in our
+ code.
+
+ This was confirmed in the CSS WG mailing list:
+ https://lists.w3.org/Archives/Public/www-style/2015May/0239.html
+
+ This patch updates grid-template-areas parsing to allow the possibility
+ of removing spaces between unnamed and named areas.
+
+ Added new cases to fast/css-grid-layout/grid-template-areas-get-set.html.
+
+ * css/CSSParser.cpp:
+ (WebCore::parseGridTemplateAreasColumnNames): New helper method to
+ determine the column names split by white spaces or dots.
+ (WebCore::CSSParser::parseGridTemplateAreasRow): Use the new helper
+ method to get the column names.
+ (WebCore::containsOnlyDots): Deleted. Not needed anymore as
+ parseGridTemplateAreasColumnNames() is using a single dot for unnamed
+ grid areas (despite of being defined with 1 or more dots).
+
2015-06-11 Mark Lam <[email protected]>
WebCore::reportException() needs to be able to accept a raw thrown value in addition to Exception objects.
Modified: trunk/Source/WebCore/css/CSSParser.cpp (185491 => 185492)
--- trunk/Source/WebCore/css/CSSParser.cpp 2015-06-12 07:37:13 UTC (rev 185491)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2015-06-12 08:19:36 UTC (rev 185492)
@@ -5961,15 +5961,34 @@
#endif /* ENABLE(DASHBOARD_SUPPORT) */
#if ENABLE(CSS_GRID_LAYOUT)
-static bool containsOnlyDots(const String& string)
+static Vector<String> parseGridTemplateAreasColumnNames(const String& gridRowNames)
{
- ASSERT(!string.isEmpty());
- StringImpl& text = *string.impl();
- for (unsigned i = 0; i < text.length(); ++i) {
- if (text[i] != '.')
- return false;
+ ASSERT(!gridRowNames.isEmpty());
+ Vector<String> columnNames;
+ // Using StringImpl to avoid checks and indirection in every call to String::operator[].
+ StringImpl& text = *gridRowNames.impl();
+ unsigned length = text.length();
+ unsigned index = 0;
+ while (index < length) {
+ if (text[index] != ' ' && text[index] != '.') {
+ unsigned gridAreaStart = index;
+ while (text[index] != ' ' && text[index] != '.' && index < length)
+ index++;
+ columnNames.append(text.substring(gridAreaStart, index - gridAreaStart));
+ continue;
+ }
+
+ if (text[index] == '.') {
+ while (text[index] == '.' && index < length)
+ index++;
+ columnNames.append(".");
+ continue;
+ }
+
+ index++;
}
- return true;
+
+ return columnNames;
}
bool CSSParser::parseGridTemplateAreasRow(NamedGridAreaMap& gridAreaMap, const unsigned rowCount, unsigned& columnCount)
@@ -5982,9 +6001,7 @@
if (gridRowNames.containsOnlyWhitespace())
return false;
- Vector<String> columnNames;
- gridRowNames.split(' ', columnNames);
-
+ Vector<String> columnNames = parseGridTemplateAreasColumnNames(gridRowNames);
if (!columnCount) {
columnCount = columnNames.size();
ASSERT(columnCount);
@@ -5997,7 +6014,7 @@
const String& gridAreaName = columnNames[currentColumn];
// Unamed areas are always valid (we consider them to be 1x1).
- if (containsOnlyDots(gridAreaName))
+ if (gridAreaName == ".")
continue;
// We handle several grid areas with the same name at once to simplify the validation code.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes