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

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

Issue 2662573002: [css-align] Implement place-content alignment shorthand (Closed)
Patch Set: Patch rebased. Created 3 years, 9 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
Index: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
index 1e5b59d5b980953f2e0921d528a5f1f094512a83..9f6856f951b452817706a573dade2ab96e77e282 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
@@ -3493,6 +3493,53 @@ bool CSSPropertyParser::consumeGridShorthand(bool important) {
return true;
}
+static CSSValue* consumeSimplifiedContentPosition(CSSParserTokenRange& range) {
+ CSSValueID id = range.peek().id();
+ if (identMatches<CSSValueNormal, CSSValueBaseline, CSSValueLastBaseline>(
+ id)) {
+ return CSSContentDistributionValue::create(
+ CSSValueInvalid, range.consumeIncludingWhitespace().id(),
+ CSSValueInvalid);
+ }
+ if (identMatches<CSSValueSpaceBetween, CSSValueSpaceAround,
+ CSSValueSpaceEvenly, CSSValueStretch>(id)) {
+ return CSSContentDistributionValue::create(
+ range.consumeIncludingWhitespace().id(), CSSValueInvalid,
+ CSSValueInvalid);
+ }
+ if (identMatches<CSSValueStart, CSSValueEnd, CSSValueCenter,
+ CSSValueFlexStart, CSSValueFlexEnd, CSSValueLeft,
+ CSSValueRight>(id)) {
+ return CSSContentDistributionValue::create(
+ CSSValueInvalid, range.consumeIncludingWhitespace().id(),
+ CSSValueInvalid);
+ }
+ return nullptr;
+}
+
+bool CSSPropertyParser::consumePlaceContentShorthand(bool important) {
+ DCHECK(RuntimeEnabledFeatures::cssGridLayoutEnabled());
+ DCHECK_EQ(shorthandForProperty(CSSPropertyPlaceContent).length(),
+ static_cast<unsigned>(2));
+
+ CSSValue* alignContentValue = consumeSimplifiedContentPosition(m_range);
+ if (!alignContentValue)
+ return false;
+ CSSValue* justifyContentValue =
+ m_range.atEnd() ? alignContentValue
+ : consumeSimplifiedContentPosition(m_range);
+ if (!justifyContentValue)
+ return false;
+ if (!m_range.atEnd())
+ return false;
+
+ addProperty(CSSPropertyAlignContent, CSSPropertyPlaceContent,
+ *alignContentValue, important);
+ addProperty(CSSPropertyJustifyContent, CSSPropertyPlaceContent,
+ *justifyContentValue, important);
+ return true;
+}
+
bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty,
bool important) {
CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty);
@@ -3752,6 +3799,8 @@ bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty,
return consumeGridTemplateShorthand(CSSPropertyGridTemplate, important);
case CSSPropertyGrid:
return consumeGridShorthand(important);
+ case CSSPropertyPlaceContent:
+ return consumePlaceContentShorthand(important);
default:
return false;
}
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.h ('k') | third_party/WebKit/Source/core/frame/UseCounter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698