Chromium Code Reviews| 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 e8af1bb83d0d2c50984be3c4b375214eac0b2811..f878691f6ddd7c1552855214081e9603c7c520c1 100644 |
| --- a/third_party/WebKit/Source/core/css/properties/CSSPropertyAlignmentUtils.cpp |
| +++ b/third_party/WebKit/Source/core/css/properties/CSSPropertyAlignmentUtils.cpp |
| @@ -44,6 +44,23 @@ bool isBaselineKeyword(CSSValueID id) { |
| CSSValueBaseline>(id); |
| } |
| +CSSValueID getBaselineKeyword(CSSValue& value) { |
| + if (!value.isValuePair()) { |
| + DCHECK(toCSSIdentifierValue(value).getValueID() == CSSValueBaseline); |
| + return CSSValueBaseline; |
| + } |
| + |
| + DCHECK(toCSSIdentifierValue(toCSSValuePair(value).second()).getValueID() == |
| + CSSValueBaseline); |
| + if (toCSSIdentifierValue(toCSSValuePair(value).first()).getValueID() == |
| + CSSValueLast) { |
| + return CSSValueLastBaseline; |
| + } |
| + DCHECK(toCSSIdentifierValue(toCSSValuePair(value).first()).getValueID() == |
| + CSSValueFirst); |
| + return CSSValueFirstBaseline; |
| +} |
| + |
| CSSValue* consumeBaselineKeyword(CSSParserTokenRange& range) { |
| CSSValueID id = range.peek().id(); |
| if (CSSPropertyParserHelpers::identMatches<CSSValueBaseline>(id)) |
| @@ -104,17 +121,8 @@ CSSValue* CSSPropertyAlignmentUtils::consumeContentDistributionOverflowPosition( |
| CSSValue* baseline = consumeBaselineKeyword(range); |
| if (!baseline) |
| return nullptr; |
| - CSSValueID baselineID = CSSValueBaseline; |
| - if (baseline->isValuePair()) { |
| - if (toCSSIdentifierValue(toCSSValuePair(baseline)->first()) |
| - .getValueID() == CSSValueLast) { |
| - baselineID = CSSValueLastBaseline; |
| - } else { |
| - baselineID = CSSValueFirstBaseline; |
| - } |
| - } |
| - return CSSContentDistributionValue::create(CSSValueInvalid, baselineID, |
| - CSSValueInvalid); |
| + return CSSContentDistributionValue::create( |
| + CSSValueInvalid, getBaselineKeyword(*baseline), CSSValueInvalid); |
| } |
| CSSValueID distribution = CSSValueInvalid; |
| @@ -153,4 +161,30 @@ CSSValue* CSSPropertyAlignmentUtils::consumeContentDistributionOverflowPosition( |
| return CSSContentDistributionValue::create(distribution, position, overflow); |
| } |
| +CSSValue* CSSPropertyAlignmentUtils::consumeSimplifiedContentPosition( |
| + CSSParserTokenRange& range) { |
| + CSSValueID id = range.peek().id(); |
| + if (CSSPropertyParserHelpers::identMatches<CSSValueNormal>(id) || |
|
Bugs Nash
2017/03/29 21:52:11
Didn't you say you were going to keep CSSValueLast
jfernandez
2017/03/29 22:03:51
Probably I didn't explain it properly. I thought y
|
| + isContentPositionKeyword(id)) { |
| + return CSSContentDistributionValue::create( |
| + CSSValueInvalid, range.consumeIncludingWhitespace().id(), |
| + CSSValueInvalid); |
| + } |
| + |
| + if (isBaselineKeyword(id)) { |
| + CSSValue* baseline = consumeBaselineKeyword(range); |
| + if (!baseline) |
| + return nullptr; |
| + return CSSContentDistributionValue::create( |
| + CSSValueInvalid, getBaselineKeyword(*baseline), CSSValueInvalid); |
| + } |
| + |
| + if (isContentDistributionKeyword(id)) { |
| + return CSSContentDistributionValue::create( |
| + range.consumeIncludingWhitespace().id(), CSSValueInvalid, |
| + CSSValueInvalid); |
| + } |
| + return nullptr; |
| +} |
| + |
| } // namespace blink |