Chromium Code Reviews| Index: Source/core/css/CSSParser.cpp |
| diff --git a/Source/core/css/CSSParser.cpp b/Source/core/css/CSSParser.cpp |
| index 83af384ce1002c1f1ba2298668e516ae420ccffd..c196869a96ba45f1b106293c8452a663d34c03fe 100644 |
| --- a/Source/core/css/CSSParser.cpp |
| +++ b/Source/core/css/CSSParser.cpp |
| @@ -4552,14 +4552,27 @@ PassRefPtr<CSSValue> CSSParser::parseGridPosition() |
| } |
| RefPtr<CSSPrimitiveValue> numericValue; |
| + RefPtr<CSSPrimitiveValue> gridLineName; |
| bool hasSeenSpanKeyword = false; |
| + // FIXME: Currently there is a lot of duplication when checking [ <string> || <integer> ]. It |
| + // will be factored out into a helper method once we support named grid lines with 'span'. |
| if (validUnit(value, FInteger) && value->fValue) { |
| numericValue = createPrimitiveNumericValue(value); |
| value = m_valueList->next(); |
| if (value && value->id == CSSValueSpan) { |
| hasSeenSpanKeyword = true; |
| m_valueList->next(); |
| + } else if (value && value->unit == CSSPrimitiveValue::CSS_STRING) { |
| + gridLineName = createPrimitiveStringValue(m_valueList->current()); |
| + m_valueList->next(); |
| + } |
| + } else if (value->unit == CSSPrimitiveValue::CSS_STRING) { |
| + gridLineName = createPrimitiveStringValue(m_valueList->current()); |
| + value = m_valueList->next(); |
| + if (value && validUnit(value, FInteger) && value->fValue) { |
| + numericValue = createPrimitiveNumericValue(value); |
| + m_valueList->next(); |
| } |
| } else if (value->id == CSSValueSpan) { |
| hasSeenSpanKeyword = true; |
| @@ -4570,20 +4583,27 @@ PassRefPtr<CSSValue> CSSParser::parseGridPosition() |
| } |
| } |
| - if (!hasSeenSpanKeyword) |
| - return numericValue.release(); |
| + // Check that we have consumed all the value list. For shorthands, the parser will pass |
| + // the whole value list (including the opposite position). |
| + if (m_valueList->current() && !isForwardSlashOperator(m_valueList->current())) |
| + return 0; |
| - if (!numericValue && hasSeenSpanKeyword) |
| - return cssValuePool().createIdentifierValue(CSSValueSpan); |
| + // If we didn't parse anything, this is not a valid grid position. |
| + if (!hasSeenSpanKeyword && !gridLineName && !numericValue) |
| + return 0; |
| // Negative numbers are not allowed for span (but are for <integer>). |
| - if (numericValue && numericValue->getIntValue() < 0) |
| + if (hasSeenSpanKeyword && numericValue && numericValue->getIntValue() < 0) |
| return 0; |
| RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); |
| - values->append(cssValuePool().createIdentifierValue(CSSValueSpan)); |
| + if (hasSeenSpanKeyword) |
| + values->append(cssValuePool().createIdentifierValue(CSSValueSpan)); |
| if (numericValue) |
| values->append(numericValue.release()); |
| + if (gridLineName) |
| + values->append(gridLineName.release()); |
| + ASSERT(values->length() > 0); |
|
esprehn
2013/05/14 21:52:27
Usually we just ASSERT(values->length()), no need
|
| return values.release(); |
| } |