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

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: 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 bool isItemPositionKeyword(CSSValueID id)
3557 {
3558 return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter
3559 || id == CSSValueSelfStart || id == CSSValueSelfEnd || id == CSSValueFle xStart
3560 || id == CSSValueFlexEnd || id == CSSValueLeft || id == CSSValueRight;
3561 }
3562
3563 static PassRefPtrWillBeRawPtr<CSSValue> consumeItemPositionOverflowPosition(CSSP arserTokenRange& range)
3564 {
3565 if (identMatches<CSSValueAuto, CSSValueStretch, CSSValueBaseline, CSSValueLa stBaseline>(range.peek().id()))
3566 return consumeIdent(range);
3567
3568 RefPtrWillBeRawPtr<CSSPrimitiveValue> position = nullptr;
3569 RefPtrWillBeRawPtr<CSSPrimitiveValue> overflowAlignmentKeyword = nullptr;
3570 if (isItemPositionKeyword(range.peek().id())) {
Timothy Loh 2016/03/10 00:12:14 Isn't this almost the same as the regular pattern
jfernandez 2016/03/10 14:11:02 The only special thing we do here is to take care
3571 position = consumeIdent(range);
3572 overflowAlignmentKeyword = consumeIdent<CSSValueUnsafe, CSSValueSafe>(ra nge);
3573 } else if (identMatches<CSSValueUnsafe, CSSValueSafe>(range.peek().id())) {
3574 overflowAlignmentKeyword = consumeIdent(range);
3575 if (isItemPositionKeyword(range.peek().id()))
3576 position = consumeIdent(range);
3577 }
3578 if (!position)
3579 return nullptr;
3580 if (overflowAlignmentKeyword)
3581 return CSSValuePair::create(position, overflowAlignmentKeyword, CSSValue Pair::DropIdenticalValues);
3582 return position.release();
3583 }
3584
3585 static PassRefPtrWillBeRawPtr<CSSValue> consumeJustifyItems(CSSParserTokenRange& range)
3586 {
3587 CSSParserTokenRange rangeCopy = range;
3588 RefPtrWillBeRawPtr<CSSPrimitiveValue> legacy = consumeIdent<CSSValueLegacy>( rangeCopy);
3589 RefPtrWillBeRawPtr<CSSPrimitiveValue> positionKeyword = consumeIdent<CSSValu eCenter, CSSValueLeft, CSSValueRight>(rangeCopy);
3590 if (!legacy)
3591 legacy = consumeIdent<CSSValueLegacy>(rangeCopy);
3592 if (legacy && positionKeyword) {
3593 range = rangeCopy;
3594 return CSSValuePair::create(legacy.release(), positionKeyword.release(), CSSValuePair::DropIdenticalValues);
3595 }
3596 return consumeItemPositionOverflowPosition(range);
3597 }
3598
3556 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty) 3599 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty)
3557 { 3600 {
3558 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); 3601 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty);
3559 if (CSSParserFastPaths::isKeywordPropertyID(property)) { 3602 if (CSSParserFastPaths::isKeywordPropertyID(property)) {
3560 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang e.peek().id())) 3603 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang e.peek().id()))
3561 return nullptr; 3604 return nullptr;
3562 return consumeIdent(m_range); 3605 return consumeIdent(m_range);
3563 } 3606 }
3564 switch (property) { 3607 switch (property) {
3565 case CSSPropertyWillChange: 3608 case CSSPropertyWillChange:
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
3900 case CSSPropertyWebkitMaskComposite: 3943 case CSSPropertyWebkitMaskComposite:
3901 case CSSPropertyWebkitMaskImage: 3944 case CSSPropertyWebkitMaskImage:
3902 case CSSPropertyWebkitMaskOrigin: 3945 case CSSPropertyWebkitMaskOrigin:
3903 case CSSPropertyWebkitMaskPositionX: 3946 case CSSPropertyWebkitMaskPositionX:
3904 case CSSPropertyWebkitMaskPositionY: 3947 case CSSPropertyWebkitMaskPositionY:
3905 case CSSPropertyWebkitMaskSize: 3948 case CSSPropertyWebkitMaskSize:
3906 return consumeCommaSeparatedBackgroundComponent(unresolvedProperty, m_ra nge, m_context); 3949 return consumeCommaSeparatedBackgroundComponent(unresolvedProperty, m_ra nge, m_context);
3907 case CSSPropertyWebkitMaskRepeatX: 3950 case CSSPropertyWebkitMaskRepeatX:
3908 case CSSPropertyWebkitMaskRepeatY: 3951 case CSSPropertyWebkitMaskRepeatY:
3909 return nullptr; 3952 return nullptr;
3953 case CSSPropertyJustifySelf:
3954 case CSSPropertyAlignSelf:
3955 case CSSPropertyAlignItems:
3956 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3957 return consumeItemPositionOverflowPosition(m_range);
3958 case CSSPropertyJustifyItems:
3959 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3960 return consumeJustifyItems(m_range);
3910 default: 3961 default:
3911 CSSParserValueList valueList(m_range); 3962 CSSParserValueList valueList(m_range);
3912 if (valueList.size()) { 3963 if (valueList.size()) {
3913 m_valueList = &valueList; 3964 m_valueList = &valueList;
3914 if (RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(unresolve dProperty)) { 3965 if (RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(unresolve dProperty)) {
3915 while (!m_range.atEnd()) 3966 while (!m_range.atEnd())
3916 m_range.consume(); 3967 m_range.consume();
3917 return result.release(); 3968 return result.release();
3918 } 3969 }
3919 } 3970 }
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
4834 m_currentShorthand = oldShorthand; 4885 m_currentShorthand = oldShorthand;
4835 CSSParserValueList valueList(m_range); 4886 CSSParserValueList valueList(m_range);
4836 if (!valueList.size()) 4887 if (!valueList.size())
4837 return false; 4888 return false;
4838 m_valueList = &valueList; 4889 m_valueList = &valueList;
4839 return legacyParseShorthand(unresolvedProperty, important); 4890 return legacyParseShorthand(unresolvedProperty, important);
4840 } 4891 }
4841 } 4892 }
4842 4893
4843 } // namespace blink 4894 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698