Index: Source/core/css/parser/CSSPropertyParser.cpp |
diff --git a/Source/core/css/parser/CSSPropertyParser.cpp b/Source/core/css/parser/CSSPropertyParser.cpp |
index c0d17bd4ad78bab38671880c93af5ec3819fdbea..85015b2e9275e88e4f76746ee1f1948795c219b3 100644 |
--- a/Source/core/css/parser/CSSPropertyParser.cpp |
+++ b/Source/core/css/parser/CSSPropertyParser.cpp |
@@ -1277,6 +1277,11 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important) |
return false; |
return parseGridTemplateShorthand(important); |
+ case CSSPropertyGrid: |
+ if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) |
+ return false; |
+ return parseGridShorthand(important); |
+ |
case CSSPropertyWebkitMarginCollapse: { |
if (num == 1) { |
ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); |
@@ -3599,6 +3604,62 @@ bool CSSPropertyParser::parseGridTemplateShorthand(bool important) |
return parseGridTemplateRowsAndAreas(columnsValue, important); |
} |
+bool CSSPropertyParser::parseGridShorthand(bool important) |
+{ |
+ ShorthandScope scope(this, CSSPropertyGrid); |
+ const StylePropertyShorthand& shorthand = shorthandForProperty(CSSPropertyGrid); |
+ ASSERT_UNUSED(shorthand, shorthand.length() == 4); |
Julien - ping for review
2014/04/03 21:14:30
Can't we just do:
ASSERT(shorthandForProperty(CSS
jfernandez
2014/04/04 15:09:35
Done.
|
+ |
+ // 1- <grid-template> |
+ if (parseGridTemplateShorthand(important)) { |
+ // Default values for the implicit grid properties. |
+ addProperty(CSSPropertyGridAutoFlow, cssValuePool().createIdentifierValue(CSSValueNone), important); |
+ addProperty(CSSPropertyGridAutoColumns, cssValuePool().createIdentifierValue(CSSValueAuto), important); |
+ addProperty(CSSPropertyGridAutoRows, cssValuePool().createIdentifierValue(CSSValueAuto), important); |
+ return true; |
+ } |
+ |
+ // Need to rewind parsing to explore the alternative syntax of this shorthand. |
+ m_valueList->setCurrentIndex(0); |
+ |
+ // 2- <grid-auto-flow> [ <grid-auto-columns> [ / <grid-auto-rows> ]? ] |
+ CSSValueID id = m_valueList->current()->id; |
+ if (id != CSSValueRow && id != CSSValueColumn && id != CSSValueNone) |
+ return false; |
+ |
+ RefPtrWillBeRawPtr<CSSValue> autoFlowValue = cssValuePool().createIdentifierValue(id); |
+ RefPtrWillBeRawPtr<CSSValue> autoColumnsValue = cssValuePool().createIdentifierValue(CSSValueAuto); |
Julien - ping for review
2014/04/03 21:14:30
I would rather leave both auto*Value to nullptr an
jfernandez
2014/04/04 15:09:35
Done.
|
+ RefPtrWillBeRawPtr<CSSValue> autoRowsValue = nullptr; |
+ |
+ if (m_valueList->next()) { |
+ autoColumnsValue = parseGridTrackSize(*m_valueList); |
+ if (!autoColumnsValue) |
+ return false; |
+ if (m_valueList->current()) { |
+ if (!(isForwardSlashOperator(m_valueList->current()) && m_valueList->next())) |
Julien - ping for review
2014/04/03 21:14:30
Let's avoid !(... && ...) by expanding it.
jfernandez
2014/04/04 15:09:35
Done.
|
+ return false; |
+ autoRowsValue = parseGridTrackSize(*m_valueList); |
+ if (!autoRowsValue) |
+ return false; |
+ } |
+ if (m_valueList->current()) |
+ return false; |
+ } |
+ addProperty(CSSPropertyGridAutoFlow, autoFlowValue, important); |
+ addProperty(CSSPropertyGridAutoColumns, autoColumnsValue, important); |
+ if (autoRowsValue) |
+ addProperty(CSSPropertyGridAutoRows, autoRowsValue, important); |
+ else |
+ addProperty(CSSPropertyGridAutoRows, autoColumnsValue, important); |
+ |
+ // Default values for the explicit grid properties. |
Julien - ping for review
2014/04/03 21:14:30
You should quote the specification here or give a
jfernandez
2014/04/04 15:09:35
Done.
|
+ addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdentifierValue(CSSValueNone), important); |
+ addProperty(CSSPropertyGridTemplateRows, cssValuePool().createIdentifierValue(CSSValueNone), important); |
+ addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifierValue(CSSValueNone), important); |
+ |
+ return true; |
+} |
+ |
bool CSSPropertyParser::parseGridAreaShorthand(bool important) |
{ |
ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |