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

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

Issue 176853007: [CSS Grid Layout] Implementation of the grid shorthand. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed compilation error in debug. Created 6 years, 8 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/parser/CSSPropertyParser.h ('k') | Source/core/css/resolver/StyleBuilderCustom.cpp » ('j') | 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 94d422a18e6f13550844a5e7674d558a295fc74c..df3053a0ad44fc4fa88ac8cd99900110919cc1ad 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);
@@ -3598,6 +3603,69 @@ bool CSSPropertyParser::parseGridTemplateShorthand(bool important)
return parseGridTemplateRowsAndAreas(columnsValue, important);
}
+bool CSSPropertyParser::parseGridShorthand(bool important)
+{
+ ShorthandScope scope(this, CSSPropertyGrid);
+ ASSERT(shorthandForProperty(CSSPropertyGrid).length() == 4);
+
+ // 1- <grid-template>
+ if (parseGridTemplateShorthand(important)) {
+ // It can only be specified the explicit or the implicit grid properties in a single grid declaration.
+ // The sub-properties not specified are set to their initial value, as normal for shorthands.
+ addProperty(CSSPropertyGridAutoFlow, cssValuePool().createImplicitInitialValue(), important);
+ addProperty(CSSPropertyGridAutoColumns, cssValuePool().createImplicitInitialValue(), important);
+ addProperty(CSSPropertyGridAutoRows, cssValuePool().createImplicitInitialValue(), 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 = nullptr;
+ 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())
+ return false;
+ autoRowsValue = parseGridTrackSize(*m_valueList);
+ if (!autoRowsValue)
+ return false;
+ }
+ if (m_valueList->current())
+ return false;
+ } else {
+ // Other omitted values are set to their initial values.
+ autoColumnsValue = cssValuePool().createImplicitInitialValue();
+ autoRowsValue = cssValuePool().createImplicitInitialValue();
+ }
+
+ // if <grid-auto-rows> value is omitted, it is set to the value specified for grid-auto-columns.
+ if (!autoRowsValue)
+ autoRowsValue = autoColumnsValue;
+
+ addProperty(CSSPropertyGridAutoFlow, autoFlowValue, important);
+ addProperty(CSSPropertyGridAutoColumns, autoColumnsValue, important);
+ addProperty(CSSPropertyGridAutoRows, autoRowsValue, important);
+
+ // It can only be specified the explicit or the implicit grid properties in a single grid declaration.
+ // The sub-properties not specified are set to their initial value, as normal for shorthands.
+ addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createImplicitInitialValue(), important);
+ addProperty(CSSPropertyGridTemplateRows, cssValuePool().createImplicitInitialValue(), important);
+ addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createImplicitInitialValue(), important);
+
+ return true;
+}
+
bool CSSPropertyParser::parseGridAreaShorthand(bool important)
{
ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/css/resolver/StyleBuilderCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698