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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/properties/CSSPropertyAlignmentUtils.h" 5 #include "core/css/properties/CSSPropertyAlignmentUtils.h"
6 6
7 #include "core/css/CSSContentDistributionValue.h" 7 #include "core/css/CSSContentDistributionValue.h"
8 #include "core/css/CSSValuePair.h" 8 #include "core/css/CSSValuePair.h"
9 #include "core/css/parser/CSSPropertyParserHelpers.h" 9 #include "core/css/parser/CSSPropertyParserHelpers.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 namespace { 13 namespace {
14 14
15 bool isSelfPositionKeyword(CSSValueID id) {
16 return CSSPropertyParserHelpers::identMatches<
17 CSSValueStart, CSSValueEnd, CSSValueCenter, CSSValueSelfStart,
18 CSSValueSelfEnd, CSSValueFlexStart, CSSValueFlexEnd, CSSValueLeft,
19 CSSValueRight>(id);
20 }
21
15 CSSIdentifierValue* consumeSelfPositionKeyword(CSSParserTokenRange& range) { 22 CSSIdentifierValue* consumeSelfPositionKeyword(CSSParserTokenRange& range) {
16 CSSValueID id = range.peek().id(); 23 return isSelfPositionKeyword(range.peek().id())
17 if (id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter || 24 ? CSSPropertyParserHelpers::consumeIdent(range)
18 id == CSSValueSelfStart || id == CSSValueSelfEnd || 25 : nullptr;
19 id == CSSValueFlexStart || id == CSSValueFlexEnd || id == CSSValueLeft || 26 }
20 id == CSSValueRight) 27
21 return CSSPropertyParserHelpers::consumeIdent(range); 28 bool isAutoOrNormalOrStretch(CSSValueID id) {
22 return nullptr; 29 return CSSPropertyParserHelpers::identMatches<CSSValueAuto, CSSValueNormal,
30 CSSValueStretch>(id);
23 } 31 }
24 32
25 bool isContentDistributionKeyword(CSSValueID id) { 33 bool isContentDistributionKeyword(CSSValueID id) {
26 return CSSPropertyParserHelpers::identMatches< 34 return CSSPropertyParserHelpers::identMatches<
27 CSSValueSpaceBetween, CSSValueSpaceAround, CSSValueSpaceEvenly, 35 CSSValueSpaceBetween, CSSValueSpaceAround, CSSValueSpaceEvenly,
28 CSSValueStretch>(id); 36 CSSValueStretch>(id);
29 } 37 }
30 38
31 bool isContentPositionKeyword(CSSValueID id) { 39 bool isContentPositionKeyword(CSSValueID id) {
32 return CSSPropertyParserHelpers::identMatches< 40 return CSSPropertyParserHelpers::identMatches<
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 CSSValuePair::DropIdenticalValues); 83 CSSValuePair::DropIdenticalValues);
76 } 84 }
77 } 85 }
78 return nullptr; 86 return nullptr;
79 } 87 }
80 88
81 } // namespace 89 } // namespace
82 90
83 CSSValue* CSSPropertyAlignmentUtils::consumeSelfPositionOverflowPosition( 91 CSSValue* CSSPropertyAlignmentUtils::consumeSelfPositionOverflowPosition(
84 CSSParserTokenRange& range) { 92 CSSParserTokenRange& range) {
85 if (CSSPropertyParserHelpers::identMatches<CSSValueAuto, CSSValueNormal, 93 CSSValueID id = range.peek().id();
86 CSSValueStretch>( 94 if (isAutoOrNormalOrStretch(id))
87 range.peek().id()))
88 return CSSPropertyParserHelpers::consumeIdent(range); 95 return CSSPropertyParserHelpers::consumeIdent(range);
89 96
90 if (isBaselineKeyword(range.peek().id())) 97 if (isBaselineKeyword(id))
91 return consumeBaselineKeyword(range); 98 return consumeBaselineKeyword(range);
92 99
93 CSSIdentifierValue* overflowPosition = 100 CSSIdentifierValue* overflowPosition =
94 CSSPropertyParserHelpers::consumeIdent<CSSValueUnsafe, CSSValueSafe>( 101 CSSPropertyParserHelpers::consumeIdent<CSSValueUnsafe, CSSValueSafe>(
95 range); 102 range);
96 CSSIdentifierValue* selfPosition = consumeSelfPositionKeyword(range); 103 CSSIdentifierValue* selfPosition = consumeSelfPositionKeyword(range);
97 if (!selfPosition) 104 if (!selfPosition)
98 return nullptr; 105 return nullptr;
99 if (!overflowPosition) { 106 if (!overflowPosition) {
100 overflowPosition = 107 overflowPosition =
101 CSSPropertyParserHelpers::consumeIdent<CSSValueUnsafe, CSSValueSafe>( 108 CSSPropertyParserHelpers::consumeIdent<CSSValueUnsafe, CSSValueSafe>(
102 range); 109 range);
103 } 110 }
104 if (overflowPosition) { 111 if (overflowPosition) {
105 return CSSValuePair::create(selfPosition, overflowPosition, 112 return CSSValuePair::create(selfPosition, overflowPosition,
106 CSSValuePair::DropIdenticalValues); 113 CSSValuePair::DropIdenticalValues);
107 } 114 }
108 return selfPosition; 115 return selfPosition;
109 } 116 }
110 117
118 CSSValue* CSSPropertyAlignmentUtils::consumeSimplifiedItemPosition(
119 CSSParserTokenRange& range) {
120 CSSValueID id = range.peek().id();
121 if (isAutoOrNormalOrStretch(id))
122 return CSSPropertyParserHelpers::consumeIdent(range);
123
124 if (isBaselineKeyword(id))
125 return consumeBaselineKeyword(range);
126
127 return consumeSelfPositionKeyword(range);
128 }
129
111 CSSValue* CSSPropertyAlignmentUtils::consumeContentDistributionOverflowPosition( 130 CSSValue* CSSPropertyAlignmentUtils::consumeContentDistributionOverflowPosition(
112 CSSParserTokenRange& range) { 131 CSSParserTokenRange& range) {
113 CSSValueID id = range.peek().id(); 132 CSSValueID id = range.peek().id();
114 if (CSSPropertyParserHelpers::identMatches<CSSValueNormal>(id)) { 133 if (CSSPropertyParserHelpers::identMatches<CSSValueNormal>(id)) {
115 return CSSContentDistributionValue::create( 134 return CSSContentDistributionValue::create(
116 CSSValueInvalid, range.consumeIncludingWhitespace().id(), 135 CSSValueInvalid, range.consumeIncludingWhitespace().id(),
117 CSSValueInvalid); 136 CSSValueInvalid);
118 } 137 }
119 138
120 if (isBaselineKeyword(id)) { 139 if (isBaselineKeyword(id)) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 200
182 if (isContentDistributionKeyword(id)) { 201 if (isContentDistributionKeyword(id)) {
183 return CSSContentDistributionValue::create( 202 return CSSContentDistributionValue::create(
184 range.consumeIncludingWhitespace().id(), CSSValueInvalid, 203 range.consumeIncludingWhitespace().id(), CSSValueInvalid,
185 CSSValueInvalid); 204 CSSValueInvalid);
186 } 205 }
187 return nullptr; 206 return nullptr;
188 } 207 }
189 208
190 } // namespace blink 209 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698