Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: Source/core/css/parser/CSSPropertyParser.cpp

Issue 1178503003: [CSS Grid Layout] Fix grid-template-areas parsing to avoid spaces (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased patch applying suggested changes Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/css-grid-layout/grid-template-areas-get-set-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/parser/CSSPropertyParser.cpp
diff --git a/Source/core/css/parser/CSSPropertyParser.cpp b/Source/core/css/parser/CSSPropertyParser.cpp
index cff57228075f10f03eacfd1a293a91d282d2b6c5..cf78ded52922421d9af909478063085692492611 100644
--- a/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/Source/core/css/parser/CSSPropertyParser.cpp
@@ -3671,15 +3671,43 @@ PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseGridBreadth(CS
return createPrimitiveNumericValue(currentValue);
}
-static bool containsOnlyDots(const String& string)
+static Vector<String> parseGridTemplateAreasColumnNames(const String& gridRowNames)
{
- ASSERT(!string.isEmpty());
- StringImpl& text = *string.impl();
+ ASSERT(!gridRowNames.isEmpty());
+ Vector<String> columnNames;
+ // Using StringImpl to avoid checks and indirection in every call to String::operator[].
+ StringImpl& text = *gridRowNames.impl();
+
+ StringBuilder areaName;
for (unsigned i = 0; i < text.length(); ++i) {
- if (text[i] != '.')
- return false;
+ if (text[i] == ' ') {
+ if (!areaName.isEmpty()) {
+ columnNames.append(areaName.toString());
+ areaName.clear();
+ }
+ continue;
+ }
+ if (text[i] == '.') {
+ if (areaName == ".")
+ continue;
+ if (!areaName.isEmpty()) {
+ columnNames.append(areaName.toString());
+ areaName.clear();
+ }
+ } else {
+ if (areaName == ".") {
+ columnNames.append(areaName.toString());
+ areaName.clear();
+ }
+ }
+
+ areaName.append(text[i]);
}
- return true;
+
+ if (!areaName.isEmpty())
+ columnNames.append(areaName.toString());
+
+ return columnNames;
}
bool CSSPropertyParser::parseGridTemplateAreasRow(NamedGridAreaMap& gridAreaMap, const size_t rowCount, size_t& columnCount)
@@ -3692,9 +3720,7 @@ bool CSSPropertyParser::parseGridTemplateAreasRow(NamedGridAreaMap& gridAreaMap,
if (gridRowNames.isEmpty() || gridRowNames.containsOnlyWhitespace())
return false;
- Vector<String> columnNames;
- gridRowNames.split(' ', columnNames);
-
+ Vector<String> columnNames = parseGridTemplateAreasColumnNames(gridRowNames);
if (!columnCount) {
columnCount = columnNames.size();
ASSERT(columnCount);
@@ -3707,7 +3733,7 @@ bool CSSPropertyParser::parseGridTemplateAreasRow(NamedGridAreaMap& gridAreaMap,
const String& gridAreaName = columnNames[currentCol];
// 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.
« no previous file with comments | « LayoutTests/fast/css-grid-layout/grid-template-areas-get-set-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698