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

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

Issue 2746453005: [css-align] Adapt self-alignment properties to the new baseline syntax (Closed)
Patch Set: More layout tests fixes. 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 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/CSSValuePair.h" 7 #include "core/css/CSSValuePair.h"
8 #include "core/css/parser/CSSPropertyParserHelpers.h" 8 #include "core/css/parser/CSSPropertyParserHelpers.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 namespace { 12 namespace {
13 13
14 CSSIdentifierValue* consumeSelfPositionKeyword(CSSParserTokenRange& range) { 14 CSSIdentifierValue* consumeSelfPositionKeyword(CSSParserTokenRange& range) {
15 CSSValueID id = range.peek().id(); 15 CSSValueID id = range.peek().id();
16 if (id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter || 16 if (id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter ||
17 id == CSSValueSelfStart || id == CSSValueSelfEnd || 17 id == CSSValueSelfStart || id == CSSValueSelfEnd ||
18 id == CSSValueFlexStart || id == CSSValueFlexEnd || id == CSSValueLeft || 18 id == CSSValueFlexStart || id == CSSValueFlexEnd || id == CSSValueLeft ||
19 id == CSSValueRight) 19 id == CSSValueRight)
20 return CSSPropertyParserHelpers::consumeIdent(range); 20 return CSSPropertyParserHelpers::consumeIdent(range);
21 return nullptr; 21 return nullptr;
22 } 22 }
23 23
24 CSSValue* consumeBaselineKeyword(CSSParserTokenRange& range) {
25 CSSValueID id = range.peek().id();
26 if (CSSPropertyParserHelpers::identMatches<CSSValueBaseline>(id))
27 return CSSPropertyParserHelpers::consumeIdent(range);
28
29 if (CSSIdentifierValue* preference =
30 CSSPropertyParserHelpers::consumeIdent<CSSValueFirst, CSSValueLast>(
31 range)) {
32 if (range.peek().id() == CSSValueBaseline) {
33 return CSSValuePair::create(preference,
34 CSSPropertyParserHelpers::consumeIdent(range),
35 CSSValuePair::DropIdenticalValues);
36 }
37 }
38 return nullptr;
39 }
40
24 } // namespace 41 } // namespace
25 42
26 CSSValue* CSSPropertyAlignmentUtils::consumeSelfPositionOverflowPosition( 43 CSSValue* CSSPropertyAlignmentUtils::consumeSelfPositionOverflowPosition(
27 CSSParserTokenRange& range) { 44 CSSParserTokenRange& range) {
28 if (CSSPropertyParserHelpers::identMatches<CSSValueAuto, CSSValueNormal, 45 if (CSSPropertyParserHelpers::identMatches<CSSValueAuto, CSSValueNormal,
29 CSSValueStretch, CSSValueBaseline, 46 CSSValueStretch>(
30 CSSValueLastBaseline>(
31 range.peek().id())) 47 range.peek().id()))
32 return CSSPropertyParserHelpers::consumeIdent(range); 48 return CSSPropertyParserHelpers::consumeIdent(range);
33 49
50 if (CSSPropertyParserHelpers::identMatches<CSSValueFirst, CSSValueLast,
51 CSSValueBaseline>(
52 range.peek().id()))
53 return consumeBaselineKeyword(range);
54
34 CSSIdentifierValue* overflowPosition = 55 CSSIdentifierValue* overflowPosition =
35 CSSPropertyParserHelpers::consumeIdent<CSSValueUnsafe, CSSValueSafe>( 56 CSSPropertyParserHelpers::consumeIdent<CSSValueUnsafe, CSSValueSafe>(
36 range); 57 range);
37 CSSIdentifierValue* selfPosition = consumeSelfPositionKeyword(range); 58 CSSIdentifierValue* selfPosition = consumeSelfPositionKeyword(range);
38 if (!selfPosition) 59 if (!selfPosition)
39 return nullptr; 60 return nullptr;
40 if (!overflowPosition) { 61 if (!overflowPosition) {
41 overflowPosition = 62 overflowPosition =
42 CSSPropertyParserHelpers::consumeIdent<CSSValueUnsafe, CSSValueSafe>( 63 CSSPropertyParserHelpers::consumeIdent<CSSValueUnsafe, CSSValueSafe>(
43 range); 64 range);
44 } 65 }
45 if (overflowPosition) { 66 if (overflowPosition) {
46 return CSSValuePair::create(selfPosition, overflowPosition, 67 return CSSValuePair::create(selfPosition, overflowPosition,
47 CSSValuePair::DropIdenticalValues); 68 CSSValuePair::DropIdenticalValues);
48 } 69 }
49 return selfPosition; 70 return selfPosition;
50 } 71 }
51 72
52 } // namespace blink 73 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698