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

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

Issue 1813053004: Move grid-auto-column/grid-auto-row into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 4 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 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/CSSBorderImage.h" 9 #include "core/css/CSSBorderImage.h"
10 #include "core/css/CSSContentDistributionValue.h" 10 #include "core/css/CSSContentDistributionValue.h"
(...skipping 3048 matching lines...) Expand 10 before | Expand all | Expand 10 after
3059 if (spanValue) 3059 if (spanValue)
3060 values->append(spanValue.release()); 3060 values->append(spanValue.release());
3061 if (numericValue) 3061 if (numericValue)
3062 values->append(numericValue.release()); 3062 values->append(numericValue.release());
3063 if (gridLineName) 3063 if (gridLineName)
3064 values->append(gridLineName.release()); 3064 values->append(gridLineName.release());
3065 ASSERT(values->length()); 3065 ASSERT(values->length());
3066 return values.release(); 3066 return values.release();
3067 } 3067 }
3068 3068
3069 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeGridBreadth(CSSParserTok enRange& range, CSSParserMode cssParserMode, TrackSizeRestriction restriction = AllowAll)
3070 {
3071 if (restriction == AllowAll) {
3072 const CSSParserToken& token = range.peek();
3073 if (identMatches<CSSValueMinContent, CSSValueMaxContent, CSSValueAuto>(t oken.id()))
3074 return consumeIdent(range);
3075 if (token.type() == DimensionToken && token.unitType() == CSSPrimitiveVa lue::UnitType::Fraction) {
3076 if (range.peek().numericValue() < 0)
3077 return nullptr;
3078 return cssValuePool().createValue(range.consumeIncludingWhitespace() .numericValue(), CSSPrimitiveValue::UnitType::Fraction);
3079 }
3080 }
3081 return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative, U nitlessQuirk::Allow);
3082 }
3083
3084 static PassRefPtrWillBeRawPtr<CSSValue> consumeGridTrackSize(CSSParserTokenRange & range, CSSParserMode cssParserMode, TrackSizeRestriction restriction = AllowAl l)
3085 {
3086 const CSSParserToken& token = range.peek();
3087 if (restriction == AllowAll && identMatches<CSSValueAuto>(token.id()))
3088 return consumeIdent(range);
3089
3090 if (token.functionId() == CSSValueMinmax) {
3091 CSSParserTokenRange rangeCopy = range;
3092 CSSParserTokenRange args = consumeFunction(rangeCopy);
3093 RefPtrWillBeRawPtr<CSSPrimitiveValue> minTrackBreadth = consumeGridBread th(args, cssParserMode, restriction);
3094 if (!minTrackBreadth || !consumeCommaIncludingWhitespace(args))
3095 return nullptr;
3096 RefPtrWillBeRawPtr<CSSPrimitiveValue> maxTrackBreadth = consumeGridBread th(args, cssParserMode);
3097 if (!maxTrackBreadth || !args.atEnd())
3098 return nullptr;
3099 range = rangeCopy;
3100 RefPtrWillBeRawPtr<CSSFunctionValue> result = CSSFunctionValue::create(C SSValueMinmax);
3101 result->append(minTrackBreadth.release());
3102 result->append(maxTrackBreadth.release());
3103 return result.release();
3104 }
3105 return consumeGridBreadth(range, cssParserMode, restriction);
3106 }
3107
3069 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty) 3108 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty)
3070 { 3109 {
3071 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); 3110 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty);
3072 if (CSSParserFastPaths::isKeywordPropertyID(property)) { 3111 if (CSSParserFastPaths::isKeywordPropertyID(property)) {
3073 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang e.peek().id())) 3112 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang e.peek().id()))
3074 return nullptr; 3113 return nullptr;
3075 return consumeIdent(m_range); 3114 return consumeIdent(m_range);
3076 } 3115 }
3077 switch (property) { 3116 switch (property) {
3078 case CSSPropertyWillChange: 3117 case CSSPropertyWillChange:
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
3427 return consumeSelfPositionOverflowPosition(m_range); 3466 return consumeSelfPositionOverflowPosition(m_range);
3428 case CSSPropertyJustifyItems: 3467 case CSSPropertyJustifyItems:
3429 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3468 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3430 return consumeJustifyItems(m_range); 3469 return consumeJustifyItems(m_range);
3431 case CSSPropertyGridColumnEnd: 3470 case CSSPropertyGridColumnEnd:
3432 case CSSPropertyGridColumnStart: 3471 case CSSPropertyGridColumnStart:
3433 case CSSPropertyGridRowEnd: 3472 case CSSPropertyGridRowEnd:
3434 case CSSPropertyGridRowStart: 3473 case CSSPropertyGridRowStart:
3435 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3474 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3436 return consumeGridLine(m_range); 3475 return consumeGridLine(m_range);
3476 case CSSPropertyGridAutoColumns:
3477 case CSSPropertyGridAutoRows:
3478 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3479 return consumeGridTrackSize(m_range, m_context.mode());
3437 default: 3480 default:
3438 CSSParserValueList valueList(m_range); 3481 CSSParserValueList valueList(m_range);
3439 if (valueList.size()) { 3482 if (valueList.size()) {
3440 m_valueList = &valueList; 3483 m_valueList = &valueList;
3441 if (RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(unresolve dProperty)) { 3484 if (RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(unresolve dProperty)) {
3442 while (!m_range.atEnd()) 3485 while (!m_range.atEnd())
3443 m_range.consume(); 3486 m_range.consume();
3444 return result.release(); 3487 return result.release();
3445 } 3488 }
3446 } 3489 }
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
4440 m_currentShorthand = oldShorthand; 4483 m_currentShorthand = oldShorthand;
4441 CSSParserValueList valueList(m_range); 4484 CSSParserValueList valueList(m_range);
4442 if (!valueList.size()) 4485 if (!valueList.size())
4443 return false; 4486 return false;
4444 m_valueList = &valueList; 4487 m_valueList = &valueList;
4445 return legacyParseShorthand(unresolvedProperty, important); 4488 return legacyParseShorthand(unresolvedProperty, important);
4446 } 4489 }
4447 } 4490 }
4448 4491
4449 } // namespace blink 4492 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698