OLD | NEW |
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 "config.h" | 5 #include "config.h" |
6 #include "core/css/parser/CSSPropertyParser.h" | 6 #include "core/css/parser/CSSPropertyParser.h" |
7 | 7 |
8 #include "core/StylePropertyShorthand.h" | 8 #include "core/StylePropertyShorthand.h" |
9 #include "core/css/CSSCalculationValue.h" | 9 #include "core/css/CSSCalculationValue.h" |
10 #include "core/css/CSSCustomIdentValue.h" | 10 #include "core/css/CSSCustomIdentValue.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 return false; | 130 return false; |
131 } | 131 } |
132 | 132 |
133 bool CSSPropertyParser::consumeCSSWideKeyword(CSSPropertyID unresolvedProperty,
bool important) | 133 bool CSSPropertyParser::consumeCSSWideKeyword(CSSPropertyID unresolvedProperty,
bool important) |
134 { | 134 { |
135 CSSParserTokenRange rangeCopy = m_range; | 135 CSSParserTokenRange rangeCopy = m_range; |
136 CSSValueID id = rangeCopy.consumeIncludingWhitespace().id(); | 136 CSSValueID id = rangeCopy.consumeIncludingWhitespace().id(); |
137 if (!rangeCopy.atEnd()) | 137 if (!rangeCopy.atEnd()) |
138 return false; | 138 return false; |
139 | 139 |
140 RefPtrWillBeRawPtr<CSSValue> value; | 140 RefPtrWillBeRawPtr<CSSValue> value = nullptr; |
141 if (id == CSSValueInitial) | 141 if (id == CSSValueInitial) |
142 value = cssValuePool().createExplicitInitialValue(); | 142 value = cssValuePool().createExplicitInitialValue(); |
143 else if (id == CSSValueInherit) | 143 else if (id == CSSValueInherit) |
144 value = cssValuePool().createInheritedValue(); | 144 value = cssValuePool().createInheritedValue(); |
145 else if (id == CSSValueUnset) | 145 else if (id == CSSValueUnset) |
146 value = cssValuePool().createUnsetValue(); | 146 value = cssValuePool().createUnsetValue(); |
147 else | 147 else |
148 return false; | 148 return false; |
149 | 149 |
150 addExpandedPropertyForValue(resolveCSSPropertyID(unresolvedProperty), value.
release(), important); | 150 addExpandedPropertyForValue(resolveCSSPropertyID(unresolvedProperty), value.
release(), important); |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 return false; | 658 return false; |
659 CSSValueID id = currentValue->getValueID(); | 659 CSSValueID id = currentValue->getValueID(); |
660 | 660 |
661 if (id == CSSValueCenter) { | 661 if (id == CSSValueCenter) { |
662 if (seenCenter) | 662 if (seenCenter) |
663 return false; | 663 return false; |
664 seenCenter = true; | 664 seenCenter = true; |
665 continue; | 665 continue; |
666 } | 666 } |
667 | 667 |
668 RefPtrWillBeRawPtr<CSSPrimitiveValue> offset; | 668 RefPtrWillBeRawPtr<CSSPrimitiveValue> offset = nullptr; |
669 if (values[i + 1] && !values[i + 1]->isValueID()) { | 669 if (values[i + 1] && !values[i + 1]->isValueID()) { |
670 offset = values[++i]; | 670 offset = values[++i]; |
671 } else { | 671 } else { |
672 offset = cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::
Percentage); | 672 offset = cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::
Percentage); |
673 } | 673 } |
674 | 674 |
675 RefPtrWillBeRawPtr<CSSValuePair> pair = CSSValuePair::create(currentValu
e, offset.release(), CSSValuePair::KeepIdenticalValues); | 675 RefPtrWillBeRawPtr<CSSValuePair> pair = CSSValuePair::create(currentValu
e, offset.release(), CSSValuePair::KeepIdenticalValues); |
676 | 676 |
677 if (id == CSSValueLeft || id == CSSValueRight) { | 677 if (id == CSSValueLeft || id == CSSValueRight) { |
678 if (resultX) | 678 if (resultX) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 values[0] = value1.get(); | 723 values[0] = value1.get(); |
724 values[1] = value2.get(); | 724 values[1] = value2.get(); |
725 values[2] = value3.get(); | 725 values[2] = value3.get(); |
726 values[3] = value4.get(); | 726 values[3] = value4.get(); |
727 values[4] = nullptr; | 727 values[4] = nullptr; |
728 return positionFromThreeOrFourValues(values, resultX, resultY); | 728 return positionFromThreeOrFourValues(values, resultX, resultY); |
729 } | 729 } |
730 | 730 |
731 static PassRefPtrWillBeRawPtr<CSSValue> consumePosition(CSSParserTokenRange& ran
ge, CSSParserMode cssParserMode, UnitlessQuirk unitless) | 731 static PassRefPtrWillBeRawPtr<CSSValue> consumePosition(CSSParserTokenRange& ran
ge, CSSParserMode cssParserMode, UnitlessQuirk unitless) |
732 { | 732 { |
733 RefPtrWillBeRawPtr<CSSValue> resultX; | 733 RefPtrWillBeRawPtr<CSSValue> resultX = nullptr; |
734 RefPtrWillBeRawPtr<CSSValue> resultY; | 734 RefPtrWillBeRawPtr<CSSValue> resultY = nullptr; |
735 if (consumePosition(range, cssParserMode, unitless, resultX, resultY)) | 735 if (consumePosition(range, cssParserMode, unitless, resultX, resultY)) |
736 return CSSValuePair::create(resultX.release(), resultY.release(), CSSVal
uePair::KeepIdenticalValues); | 736 return CSSValuePair::create(resultX.release(), resultY.release(), CSSVal
uePair::KeepIdenticalValues); |
737 return nullptr; | 737 return nullptr; |
738 } | 738 } |
739 | 739 |
740 static inline bool isCSSWideKeyword(const CSSValueID& id) | 740 static inline bool isCSSWideKeyword(const CSSValueID& id) |
741 { | 741 { |
742 return id == CSSValueInitial || id == CSSValueInherit || id == CSSValueUnset
|| id == CSSValueDefault; | 742 return id == CSSValueInitial || id == CSSValueInherit || id == CSSValueUnset
|| id == CSSValueDefault; |
743 } | 743 } |
744 | 744 |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 // 1 (will be dropped in the unprefixed property). | 1337 // 1 (will be dropped in the unprefixed property). |
1338 if (spanValue->getIntValue() == 1) | 1338 if (spanValue->getIntValue() == 1) |
1339 return spanValue.release(); | 1339 return spanValue.release(); |
1340 } | 1340 } |
1341 return nullptr; | 1341 return nullptr; |
1342 } | 1342 } |
1343 | 1343 |
1344 static PassRefPtrWillBeRawPtr<CSSValue> consumeZoom(CSSParserTokenRange& range,
const CSSParserContext& context) | 1344 static PassRefPtrWillBeRawPtr<CSSValue> consumeZoom(CSSParserTokenRange& range,
const CSSParserContext& context) |
1345 { | 1345 { |
1346 const CSSParserToken& token = range.peek(); | 1346 const CSSParserToken& token = range.peek(); |
1347 RefPtrWillBeRawPtr<CSSPrimitiveValue> zoom; | 1347 RefPtrWillBeRawPtr<CSSPrimitiveValue> zoom = nullptr; |
1348 if (token.type() == IdentToken) { | 1348 if (token.type() == IdentToken) { |
1349 zoom = consumeIdent<CSSValueNormal, CSSValueReset, CSSValueDocument>(ran
ge); | 1349 zoom = consumeIdent<CSSValueNormal, CSSValueReset, CSSValueDocument>(ran
ge); |
1350 } else { | 1350 } else { |
1351 zoom = consumePercent(range, ValueRangeNonNegative); | 1351 zoom = consumePercent(range, ValueRangeNonNegative); |
1352 if (!zoom) | 1352 if (!zoom) |
1353 zoom = consumeNumber(range, ValueRangeNonNegative); | 1353 zoom = consumeNumber(range, ValueRangeNonNegative); |
1354 } | 1354 } |
1355 if (zoom && context.useCounter() | 1355 if (zoom && context.useCounter() |
1356 && !(token.id() == CSSValueNormal | 1356 && !(token.id() == CSSValueNormal |
1357 || (token.type() == NumberToken && zoom->getDoubleValue() == 1) | 1357 || (token.type() == NumberToken && zoom->getDoubleValue() == 1) |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1723 return list.release(); | 1723 return list.release(); |
1724 } | 1724 } |
1725 | 1725 |
1726 static PassRefPtrWillBeRawPtr<CSSValue> consumeTextDecorationLine(CSSParserToken
Range& range) | 1726 static PassRefPtrWillBeRawPtr<CSSValue> consumeTextDecorationLine(CSSParserToken
Range& range) |
1727 { | 1727 { |
1728 CSSValueID id = range.peek().id(); | 1728 CSSValueID id = range.peek().id(); |
1729 if (id == CSSValueNone) | 1729 if (id == CSSValueNone) |
1730 return consumeIdent(range); | 1730 return consumeIdent(range); |
1731 | 1731 |
1732 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 1732 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; |
1733 RefPtrWillBeRawPtr<CSSPrimitiveValue> ident; | 1733 RefPtrWillBeRawPtr<CSSPrimitiveValue> ident = nullptr; |
1734 while ((ident = consumeIdent<CSSValueBlink, CSSValueUnderline, CSSValueOverl
ine, CSSValueLineThrough>(range))) { | 1734 while ((ident = consumeIdent<CSSValueBlink, CSSValueUnderline, CSSValueOverl
ine, CSSValueLineThrough>(range))) { |
1735 if (list->hasValue(ident.get())) | 1735 if (list->hasValue(ident.get())) |
1736 return nullptr; | 1736 return nullptr; |
1737 list->append(ident.release()); | 1737 list->append(ident.release()); |
1738 } | 1738 } |
1739 | 1739 |
1740 if (!list->length()) | 1740 if (!list->length()) |
1741 return nullptr; | 1741 return nullptr; |
1742 return list.release(); | 1742 return list.release(); |
1743 } | 1743 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1838 } | 1838 } |
1839 | 1839 |
1840 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeColumnRuleWidth(CSSParse
rTokenRange& range, CSSParserMode cssParserMode) | 1840 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeColumnRuleWidth(CSSParse
rTokenRange& range, CSSParserMode cssParserMode) |
1841 { | 1841 { |
1842 return consumeLineWidth(range, cssParserMode); | 1842 return consumeLineWidth(range, cssParserMode); |
1843 } | 1843 } |
1844 | 1844 |
1845 static bool consumeTranslate3d(CSSParserTokenRange& args, CSSParserMode cssParse
rMode, RefPtrWillBeRawPtr<CSSFunctionValue>& transformValue) | 1845 static bool consumeTranslate3d(CSSParserTokenRange& args, CSSParserMode cssParse
rMode, RefPtrWillBeRawPtr<CSSFunctionValue>& transformValue) |
1846 { | 1846 { |
1847 unsigned numberOfArguments = 2; | 1847 unsigned numberOfArguments = 2; |
1848 RefPtrWillBeRawPtr<CSSValue> parsedValue; | 1848 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; |
1849 do { | 1849 do { |
1850 parsedValue = consumeLengthOrPercent(args, cssParserMode, ValueRangeAll)
; | 1850 parsedValue = consumeLengthOrPercent(args, cssParserMode, ValueRangeAll)
; |
1851 if (!parsedValue) | 1851 if (!parsedValue) |
1852 return false; | 1852 return false; |
1853 transformValue->append(parsedValue); | 1853 transformValue->append(parsedValue); |
1854 if (!consumeCommaIncludingWhitespace(args)) | 1854 if (!consumeCommaIncludingWhitespace(args)) |
1855 return false; | 1855 return false; |
1856 } while (--numberOfArguments); | 1856 } while (--numberOfArguments); |
1857 parsedValue = consumeLength(args, cssParserMode, ValueRangeAll); | 1857 parsedValue = consumeLength(args, cssParserMode, ValueRangeAll); |
1858 if (!parsedValue) | 1858 if (!parsedValue) |
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2874 return consumeShorthandGreedily(flexFlowShorthand(), important); | 2874 return consumeShorthandGreedily(flexFlowShorthand(), important); |
2875 case CSSPropertyWebkitColumnRule: | 2875 case CSSPropertyWebkitColumnRule: |
2876 return consumeShorthandGreedily(webkitColumnRuleShorthand(), important); | 2876 return consumeShorthandGreedily(webkitColumnRuleShorthand(), important); |
2877 default: | 2877 default: |
2878 m_currentShorthand = oldShorthand; | 2878 m_currentShorthand = oldShorthand; |
2879 return false; | 2879 return false; |
2880 } | 2880 } |
2881 } | 2881 } |
2882 | 2882 |
2883 } // namespace blink | 2883 } // namespace blink |
OLD | NEW |