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

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

Issue 1523803002: Move justify-content/align-content properties into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch for landing Created 4 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/parser/CSSPropertyParser.h" 5 #include "core/css/parser/CSSPropertyParser.h"
6 6
7 #include "core/StylePropertyShorthand.h" 7 #include "core/StylePropertyShorthand.h"
8 #include "core/css/CSSBasicShapeValues.h" 8 #include "core/css/CSSBasicShapeValues.h"
9 #include "core/css/CSSCalculationValue.h" 9 #include "core/css/CSSCalculationValue.h"
10 #include "core/css/CSSContentDistributionValue.h"
10 #include "core/css/CSSCounterValue.h" 11 #include "core/css/CSSCounterValue.h"
11 #include "core/css/CSSCrossfadeValue.h" 12 #include "core/css/CSSCrossfadeValue.h"
12 #include "core/css/CSSCursorImageValue.h" 13 #include "core/css/CSSCursorImageValue.h"
13 #include "core/css/CSSCustomIdentValue.h" 14 #include "core/css/CSSCustomIdentValue.h"
14 #include "core/css/CSSFontFaceSrcValue.h" 15 #include "core/css/CSSFontFaceSrcValue.h"
15 #include "core/css/CSSFontFeatureValue.h" 16 #include "core/css/CSSFontFeatureValue.h"
16 #include "core/css/CSSFunctionValue.h" 17 #include "core/css/CSSFunctionValue.h"
17 #include "core/css/CSSImageSetValue.h" 18 #include "core/css/CSSImageSetValue.h"
18 #include "core/css/CSSPathValue.h" 19 #include "core/css/CSSPathValue.h"
19 #include "core/css/CSSPrimitiveValueMappings.h" 20 #include "core/css/CSSPrimitiveValueMappings.h"
(...skipping 3121 matching lines...) Expand 10 before | Expand all | Expand 10 after
3141 if (list->length() < 2) { 3142 if (list->length() < 2) {
3142 if (RefPtrWillBeRawPtr<CSSValue> boxValue = consumeIdent<CSSValueCon tentBox, CSSValuePaddingBox, CSSValueBorderBox, CSSValueMarginBox>(range)) 3143 if (RefPtrWillBeRawPtr<CSSValue> boxValue = consumeIdent<CSSValueCon tentBox, CSSValuePaddingBox, CSSValueBorderBox, CSSValueMarginBox>(range))
3143 list->append(boxValue.release()); 3144 list->append(boxValue.release());
3144 } 3145 }
3145 } 3146 }
3146 if (!list->length()) 3147 if (!list->length())
3147 return nullptr; 3148 return nullptr;
3148 return list.release(); 3149 return list.release();
3149 } 3150 }
3150 3151
3152 static PassRefPtrWillBeRawPtr<CSSValue> consumeContentDistributionOverflowPositi on(CSSParserTokenRange& range)
3153 {
3154 if (identMatches<CSSValueAuto, CSSValueBaseline, CSSValueLastBaseline>(range .peek().id()))
3155 return CSSContentDistributionValue::create(CSSValueInvalid, range.consum eIncludingWhitespace().id(), CSSValueInvalid);
3156
3157 CSSValueID distribution = CSSValueInvalid;
3158 CSSValueID position = CSSValueInvalid;
3159 CSSValueID overflow = CSSValueInvalid;
3160 do {
3161 CSSValueID id = range.peek().id();
3162 if (identMatches<CSSValueSpaceBetween, CSSValueSpaceAround, CSSValueSpac eEvenly, CSSValueStretch>(id)) {
3163 if (distribution != CSSValueInvalid)
3164 return nullptr;
3165 distribution = id;
3166 } else if (identMatches<CSSValueStart, CSSValueEnd, CSSValueCenter, CSSV alueFlexStart, CSSValueFlexEnd, CSSValueLeft, CSSValueRight>(id)) {
3167 if (position != CSSValueInvalid)
3168 return nullptr;
3169 position = id;
3170 } else if (identMatches<CSSValueUnsafe, CSSValueSafe>(id)) {
3171 if (overflow != CSSValueInvalid)
3172 return nullptr;
3173 overflow = id;
3174 } else {
3175 return nullptr;
3176 }
3177 range.consumeIncludingWhitespace();
3178 } while (!range.atEnd());
3179
3180 // The grammar states that we should have at least <content-distribution> or <content-position>.
3181 if (position == CSSValueInvalid && distribution == CSSValueInvalid)
3182 return nullptr;
3183
3184 // The grammar states that <overflow-position> must be associated to <conten t-position>.
3185 if (overflow != CSSValueInvalid && position == CSSValueInvalid)
3186 return nullptr;
3187
3188 return CSSContentDistributionValue::create(distribution, position, overflow) ;
3189 }
3190
3151 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty) 3191 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty)
3152 { 3192 {
3153 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); 3193 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty);
3154 if (CSSParserFastPaths::isKeywordPropertyID(property)) { 3194 if (CSSParserFastPaths::isKeywordPropertyID(property)) {
3155 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang e.peek().id())) 3195 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang e.peek().id()))
3156 return nullptr; 3196 return nullptr;
3157 return consumeIdent(m_range); 3197 return consumeIdent(m_range);
3158 } 3198 }
3159 switch (property) { 3199 switch (property) {
3160 case CSSPropertyWillChange: 3200 case CSSPropertyWillChange:
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
3441 case CSSPropertyTextUnderlinePosition: 3481 case CSSPropertyTextUnderlinePosition:
3442 // auto | [ under || [ left | right ] ], but we only support auto | unde r for now 3482 // auto | [ under || [ left | right ] ], but we only support auto | unde r for now
3443 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled()); 3483 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled());
3444 return consumeIdent<CSSValueAuto, CSSValueUnder>(m_range); 3484 return consumeIdent<CSSValueAuto, CSSValueUnder>(m_range);
3445 case CSSPropertyVerticalAlign: 3485 case CSSPropertyVerticalAlign:
3446 return consumeVerticalAlign(m_range, m_context.mode()); 3486 return consumeVerticalAlign(m_range, m_context.mode());
3447 case CSSPropertyShapeOutside: 3487 case CSSPropertyShapeOutside:
3448 return consumeShapeOutside(m_range, m_context); 3488 return consumeShapeOutside(m_range, m_context);
3449 case CSSPropertyWebkitClipPath: 3489 case CSSPropertyWebkitClipPath:
3450 return consumeClipPath(m_range, m_context); 3490 return consumeClipPath(m_range, m_context);
3491 case CSSPropertyJustifyContent:
3492 case CSSPropertyAlignContent:
3493 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3494 return consumeContentDistributionOverflowPosition(m_range);
3451 default: 3495 default:
3452 CSSParserValueList valueList(m_range); 3496 CSSParserValueList valueList(m_range);
3453 if (valueList.size()) { 3497 if (valueList.size()) {
3454 m_valueList = &valueList; 3498 m_valueList = &valueList;
3455 if (RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(unresolve dProperty)) { 3499 if (RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(unresolve dProperty)) {
3456 while (!m_range.atEnd()) 3500 while (!m_range.atEnd())
3457 m_range.consume(); 3501 m_range.consume();
3458 return result.release(); 3502 return result.release();
3459 } 3503 }
3460 } 3504 }
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
4101 m_currentShorthand = oldShorthand; 4145 m_currentShorthand = oldShorthand;
4102 CSSParserValueList valueList(m_range); 4146 CSSParserValueList valueList(m_range);
4103 if (!valueList.size()) 4147 if (!valueList.size())
4104 return false; 4148 return false;
4105 m_valueList = &valueList; 4149 m_valueList = &valueList;
4106 return legacyParseShorthand(unresolvedProperty, important); 4150 return legacyParseShorthand(unresolvedProperty, important);
4107 } 4151 }
4108 } 4152 }
4109 4153
4110 } // namespace blink 4154 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698