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

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

Issue 1776983003: Move some grid related longhands into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: V3 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/CSSCalculationValue.h" 10 #include "core/css/CSSCalculationValue.h"
(...skipping 3535 matching lines...) Expand 10 before | Expand all | Expand 10 after
3546 RefPtrWillBeRawPtr<CSSValue> result = nullptr; 3546 RefPtrWillBeRawPtr<CSSValue> result = nullptr;
3547 do { 3547 do {
3548 RefPtrWillBeRawPtr<CSSValue> value = consumeBackgroundComponent(unresolv edProperty, range, context); 3548 RefPtrWillBeRawPtr<CSSValue> value = consumeBackgroundComponent(unresolv edProperty, range, context);
3549 if (!value) 3549 if (!value)
3550 return nullptr; 3550 return nullptr;
3551 addBackgroundValue(result, value); 3551 addBackgroundValue(result, value);
3552 } while (consumeCommaIncludingWhitespace(range)); 3552 } while (consumeCommaIncludingWhitespace(range));
3553 return result.release(); 3553 return result.release();
3554 } 3554 }
3555 3555
3556 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeSelfPositionKeyword(CSSP arserTokenRange& range)
3557 {
3558 CSSValueID id = range.peek().id();
3559 if (id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter
3560 || id == CSSValueSelfStart || id == CSSValueSelfEnd || id == CSSValueFle xStart
3561 || id == CSSValueFlexEnd || id == CSSValueLeft || id == CSSValueRight)
3562 return consumeIdent(range);
3563 return nullptr;
3564 }
3565
3566 static PassRefPtrWillBeRawPtr<CSSValue> consumeSelfPositionOverflowPosition(CSSP arserTokenRange& range)
3567 {
3568 if (identMatches<CSSValueAuto, CSSValueStretch, CSSValueBaseline, CSSValueLa stBaseline>(range.peek().id()))
3569 return consumeIdent(range);
3570
3571 RefPtrWillBeRawPtr<CSSPrimitiveValue> overflowPosition = consumeIdent<CSSVal ueUnsafe, CSSValueSafe>(range);
3572 RefPtrWillBeRawPtr<CSSPrimitiveValue> selfPosition = consumeSelfPositionKeyw ord(range);
3573 if (!selfPosition)
3574 return nullptr;
3575 if (!overflowPosition)
3576 overflowPosition = consumeIdent<CSSValueUnsafe, CSSValueSafe>(range);
3577 if (overflowPosition)
3578 return CSSValuePair::create(selfPosition.release(), overflowPosition, CS SValuePair::DropIdenticalValues);
3579 return selfPosition.release();
3580 }
3581
3582 static PassRefPtrWillBeRawPtr<CSSValue> consumeJustifyItems(CSSParserTokenRange& range)
3583 {
3584 CSSParserTokenRange rangeCopy = range;
3585 RefPtrWillBeRawPtr<CSSPrimitiveValue> legacy = consumeIdent<CSSValueLegacy>( rangeCopy);
3586 RefPtrWillBeRawPtr<CSSPrimitiveValue> positionKeyword = consumeIdent<CSSValu eCenter, CSSValueLeft, CSSValueRight>(rangeCopy);
3587 if (!legacy)
3588 legacy = consumeIdent<CSSValueLegacy>(rangeCopy);
3589 if (legacy && positionKeyword) {
3590 range = rangeCopy;
3591 return CSSValuePair::create(legacy.release(), positionKeyword.release(), CSSValuePair::DropIdenticalValues);
3592 }
3593 return consumeSelfPositionOverflowPosition(range);
3594 }
3595
3556 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty) 3596 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty)
3557 { 3597 {
3558 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); 3598 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty);
3559 if (CSSParserFastPaths::isKeywordPropertyID(property)) { 3599 if (CSSParserFastPaths::isKeywordPropertyID(property)) {
3560 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang e.peek().id())) 3600 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang e.peek().id()))
3561 return nullptr; 3601 return nullptr;
3562 return consumeIdent(m_range); 3602 return consumeIdent(m_range);
3563 } 3603 }
3564 switch (property) { 3604 switch (property) {
3565 case CSSPropertyWillChange: 3605 case CSSPropertyWillChange:
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
3900 case CSSPropertyWebkitMaskComposite: 3940 case CSSPropertyWebkitMaskComposite:
3901 case CSSPropertyWebkitMaskImage: 3941 case CSSPropertyWebkitMaskImage:
3902 case CSSPropertyWebkitMaskOrigin: 3942 case CSSPropertyWebkitMaskOrigin:
3903 case CSSPropertyWebkitMaskPositionX: 3943 case CSSPropertyWebkitMaskPositionX:
3904 case CSSPropertyWebkitMaskPositionY: 3944 case CSSPropertyWebkitMaskPositionY:
3905 case CSSPropertyWebkitMaskSize: 3945 case CSSPropertyWebkitMaskSize:
3906 return consumeCommaSeparatedBackgroundComponent(unresolvedProperty, m_ra nge, m_context); 3946 return consumeCommaSeparatedBackgroundComponent(unresolvedProperty, m_ra nge, m_context);
3907 case CSSPropertyWebkitMaskRepeatX: 3947 case CSSPropertyWebkitMaskRepeatX:
3908 case CSSPropertyWebkitMaskRepeatY: 3948 case CSSPropertyWebkitMaskRepeatY:
3909 return nullptr; 3949 return nullptr;
3950 case CSSPropertyJustifySelf:
3951 case CSSPropertyAlignSelf:
3952 case CSSPropertyAlignItems:
3953 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3954 return consumeSelfPositionOverflowPosition(m_range);
3955 case CSSPropertyJustifyItems:
3956 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3957 return consumeJustifyItems(m_range);
3910 default: 3958 default:
3911 CSSParserValueList valueList(m_range); 3959 CSSParserValueList valueList(m_range);
3912 if (valueList.size()) { 3960 if (valueList.size()) {
3913 m_valueList = &valueList; 3961 m_valueList = &valueList;
3914 if (RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(unresolve dProperty)) { 3962 if (RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(unresolve dProperty)) {
3915 while (!m_range.atEnd()) 3963 while (!m_range.atEnd())
3916 m_range.consume(); 3964 m_range.consume();
3917 return result.release(); 3965 return result.release();
3918 } 3966 }
3919 } 3967 }
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
4834 m_currentShorthand = oldShorthand; 4882 m_currentShorthand = oldShorthand;
4835 CSSParserValueList valueList(m_range); 4883 CSSParserValueList valueList(m_range);
4836 if (!valueList.size()) 4884 if (!valueList.size())
4837 return false; 4885 return false;
4838 m_valueList = &valueList; 4886 m_valueList = &valueList;
4839 return legacyParseShorthand(unresolvedProperty, important); 4887 return legacyParseShorthand(unresolvedProperty, important);
4840 } 4888 }
4841 } 4889 }
4842 4890
4843 } // namespace blink 4891 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698