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

Unified Diff: third_party/WebKit/Source/core/css/properties/CSSPropertyAlignmentUtils.cpp

Issue 2737843003: [css-align] Implement place-items alignment shorthand (Closed)
Patch Set: More layout tests fixes. Created 3 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
Index: third_party/WebKit/Source/core/css/properties/CSSPropertyAlignmentUtils.cpp
diff --git a/third_party/WebKit/Source/core/css/properties/CSSPropertyAlignmentUtils.cpp b/third_party/WebKit/Source/core/css/properties/CSSPropertyAlignmentUtils.cpp
index f878691f6ddd7c1552855214081e9603c7c520c1..fc1c77c284bad824e42d421f206d12d6fe8b687a 100644
--- a/third_party/WebKit/Source/core/css/properties/CSSPropertyAlignmentUtils.cpp
+++ b/third_party/WebKit/Source/core/css/properties/CSSPropertyAlignmentUtils.cpp
@@ -12,14 +12,22 @@ namespace blink {
namespace {
+bool isSelfPositionKeyword(CSSValueID id) {
+ return CSSPropertyParserHelpers::identMatches<
+ CSSValueStart, CSSValueEnd, CSSValueCenter, CSSValueSelfStart,
+ CSSValueSelfEnd, CSSValueFlexStart, CSSValueFlexEnd, CSSValueLeft,
+ CSSValueRight>(id);
+}
+
CSSIdentifierValue* consumeSelfPositionKeyword(CSSParserTokenRange& range) {
- CSSValueID id = range.peek().id();
- if (id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter ||
- id == CSSValueSelfStart || id == CSSValueSelfEnd ||
- id == CSSValueFlexStart || id == CSSValueFlexEnd || id == CSSValueLeft ||
- id == CSSValueRight)
- return CSSPropertyParserHelpers::consumeIdent(range);
- return nullptr;
+ return isSelfPositionKeyword(range.peek().id())
+ ? CSSPropertyParserHelpers::consumeIdent(range)
+ : nullptr;
+}
+
+bool isAutoOrNormalOrStretch(CSSValueID id) {
+ return CSSPropertyParserHelpers::identMatches<CSSValueAuto, CSSValueNormal,
+ CSSValueStretch>(id);
}
bool isContentDistributionKeyword(CSSValueID id) {
@@ -82,12 +90,11 @@ CSSValue* consumeBaselineKeyword(CSSParserTokenRange& range) {
CSSValue* CSSPropertyAlignmentUtils::consumeSelfPositionOverflowPosition(
CSSParserTokenRange& range) {
- if (CSSPropertyParserHelpers::identMatches<CSSValueAuto, CSSValueNormal,
- CSSValueStretch>(
- range.peek().id()))
+ CSSValueID id = range.peek().id();
+ if (isAutoOrNormalOrStretch(id))
return CSSPropertyParserHelpers::consumeIdent(range);
- if (isBaselineKeyword(range.peek().id()))
+ if (isBaselineKeyword(id))
return consumeBaselineKeyword(range);
CSSIdentifierValue* overflowPosition =
@@ -108,6 +115,18 @@ CSSValue* CSSPropertyAlignmentUtils::consumeSelfPositionOverflowPosition(
return selfPosition;
}
+CSSValue* CSSPropertyAlignmentUtils::consumeSimplifiedItemPosition(
+ CSSParserTokenRange& range) {
+ CSSValueID id = range.peek().id();
+ if (isAutoOrNormalOrStretch(id))
+ return CSSPropertyParserHelpers::consumeIdent(range);
+
+ if (isBaselineKeyword(id))
+ return consumeBaselineKeyword(range);
+
+ return consumeSelfPositionKeyword(range);
+}
+
CSSValue* CSSPropertyAlignmentUtils::consumeContentDistributionOverflowPosition(
CSSParserTokenRange& range) {
CSSValueID id = range.peek().id();

Powered by Google App Engine
This is Rietveld 408576698