Chromium Code Reviews| Index: Source/core/css/parser/CSSPropertyParser.cpp |
| diff --git a/Source/core/css/parser/CSSPropertyParser.cpp b/Source/core/css/parser/CSSPropertyParser.cpp |
| index 10b55b207e1a9d87621a2c67b128c0698129f6b1..c2aa8e03c2fb3eb5c2edf41a1c0cd02b9c047790 100644 |
| --- a/Source/core/css/parser/CSSPropertyParser.cpp |
| +++ b/Source/core/css/parser/CSSPropertyParser.cpp |
| @@ -3672,15 +3672,42 @@ 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; |
| + StringImpl& text = *gridRowNames.impl(); |
|
Julien - ping for review
2015/06/10 15:31:18
I would like a comment for this. I assume this is
Manuel Rego
2015/06/10 20:41:45
Yes. Added a comment.
|
| + |
| + String areaName = ""; |
|
Julien - ping for review
2015/06/10 15:31:18
You want to use StringBuilder to avoid unneeded bu
Manuel Rego
2015/06/10 20:41:45
Done.
|
| for (unsigned i = 0; i < text.length(); ++i) { |
| - if (text[i] != '.') |
| - return false; |
| + if (text[i] == ' ') { |
| + if (!areaName.isEmpty()) { |
| + columnNames.append(areaName); |
| + areaName = ""; |
| + } |
| + continue; |
| + } |
| + if (text[i] == '.') { |
| + if (areaName == ".") |
| + continue; |
| + if (!areaName.isEmpty()) { |
| + columnNames.append(areaName); |
| + areaName = ""; |
| + } |
| + } else { |
| + if (areaName == ".") { |
| + columnNames.append(areaName); |
| + areaName = ""; |
| + } |
| + } |
| + |
| + areaName.append(text[i]); |
| } |
| - return true; |
| + |
| + if (!areaName.isEmpty()) |
| + columnNames.append(areaName); |
| + |
| + return columnNames; |
| } |
| bool CSSPropertyParser::parseGridTemplateAreasRow(NamedGridAreaMap& gridAreaMap, const size_t rowCount, size_t& columnCount) |
| @@ -3693,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); |
| @@ -3708,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. |