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

Unified Diff: Source/core/css/CSSParser.cpp

Issue 14715014: Add parsing for named grid lines (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Patch for landing (fixed Elliott's comments) Created 7 years, 7 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 | « Source/core/css/CSSComputedStyleDeclaration.cpp ('k') | Source/core/css/resolver/StyleResolver.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSParser.cpp
diff --git a/Source/core/css/CSSParser.cpp b/Source/core/css/CSSParser.cpp
index ee0e6271bd3f974992dbb809dc02a139dfc1cf83..164f0706289fa4aec9addcce7a6decd897f49a49 100644
--- a/Source/core/css/CSSParser.cpp
+++ b/Source/core/css/CSSParser.cpp
@@ -4543,14 +4543,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;
@@ -4561,20 +4574,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());
return values.release();
}
« no previous file with comments | « Source/core/css/CSSComputedStyleDeclaration.cpp ('k') | Source/core/css/resolver/StyleResolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698