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

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

Issue 1776983003: Move some grid related longhands into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 a85fe102ffb1548480b334a6468fd954fd9518a7..3faeeeec1c77c22a2b542c17341dd3c3eb855b3e 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
@@ -3553,6 +3553,49 @@ static PassRefPtrWillBeRawPtr<CSSValue> consumeCommaSeparatedBackgroundComponent
return result.release();
}
+static bool isItemPositionKeyword(CSSValueID id)
+{
+ return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter
+ || id == CSSValueSelfStart || id == CSSValueSelfEnd || id == CSSValueFlexStart
+ || id == CSSValueFlexEnd || id == CSSValueLeft || id == CSSValueRight;
+}
+
+static PassRefPtrWillBeRawPtr<CSSValue> consumeItemPositionOverflowPosition(CSSParserTokenRange& range)
+{
+ if (identMatches<CSSValueAuto, CSSValueStretch, CSSValueBaseline, CSSValueLastBaseline>(range.peek().id()))
+ return consumeIdent(range);
+
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> position = nullptr;
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> overflowAlignmentKeyword = nullptr;
+ if (isItemPositionKeyword(range.peek().id())) {
Timothy Loh 2016/03/10 00:12:14 Isn't this almost the same as the regular pattern
jfernandez 2016/03/10 14:11:02 The only special thing we do here is to take care
+ position = consumeIdent(range);
+ overflowAlignmentKeyword = consumeIdent<CSSValueUnsafe, CSSValueSafe>(range);
+ } else if (identMatches<CSSValueUnsafe, CSSValueSafe>(range.peek().id())) {
+ overflowAlignmentKeyword = consumeIdent(range);
+ if (isItemPositionKeyword(range.peek().id()))
+ position = consumeIdent(range);
+ }
+ if (!position)
+ return nullptr;
+ if (overflowAlignmentKeyword)
+ return CSSValuePair::create(position, overflowAlignmentKeyword, CSSValuePair::DropIdenticalValues);
+ return position.release();
+}
+
+static PassRefPtrWillBeRawPtr<CSSValue> consumeJustifyItems(CSSParserTokenRange& range)
+{
+ CSSParserTokenRange rangeCopy = range;
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> legacy = consumeIdent<CSSValueLegacy>(rangeCopy);
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> positionKeyword = consumeIdent<CSSValueCenter, CSSValueLeft, CSSValueRight>(rangeCopy);
+ if (!legacy)
+ legacy = consumeIdent<CSSValueLegacy>(rangeCopy);
+ if (legacy && positionKeyword) {
+ range = rangeCopy;
+ return CSSValuePair::create(legacy.release(), positionKeyword.release(), CSSValuePair::DropIdenticalValues);
+ }
+ return consumeItemPositionOverflowPosition(range);
+}
+
PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID unresolvedProperty)
{
CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty);
@@ -3907,6 +3950,14 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
case CSSPropertyWebkitMaskRepeatX:
case CSSPropertyWebkitMaskRepeatY:
return nullptr;
+ case CSSPropertyJustifySelf:
+ case CSSPropertyAlignSelf:
+ case CSSPropertyAlignItems:
+ ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
+ return consumeItemPositionOverflowPosition(m_range);
+ case CSSPropertyJustifyItems:
+ ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
+ return consumeJustifyItems(m_range);
default:
CSSParserValueList valueList(m_range);
if (valueList.size()) {

Powered by Google App Engine
This is Rietveld 408576698