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

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

Issue 1398553002: Move counter-increment/counter-reset handling into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Work around ::lowest problem Created 5 years, 2 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 "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"
11 #include "core/css/CSSFontFaceSrcValue.h" 11 #include "core/css/CSSFontFaceSrcValue.h"
12 #include "core/css/CSSFontFeatureValue.h" 12 #include "core/css/CSSFontFeatureValue.h"
13 #include "core/css/CSSPrimitiveValueMappings.h" 13 #include "core/css/CSSPrimitiveValueMappings.h"
14 #include "core/css/CSSStringValue.h" 14 #include "core/css/CSSStringValue.h"
15 #include "core/css/CSSURIValue.h" 15 #include "core/css/CSSURIValue.h"
16 #include "core/css/CSSUnicodeRangeValue.h" 16 #include "core/css/CSSUnicodeRangeValue.h"
17 #include "core/css/CSSValuePair.h"
17 #include "core/css/CSSValuePool.h" 18 #include "core/css/CSSValuePool.h"
18 #include "core/css/FontFace.h" 19 #include "core/css/FontFace.h"
19 #include "core/css/parser/CSSParserFastPaths.h" 20 #include "core/css/parser/CSSParserFastPaths.h"
20 #include "core/css/parser/CSSParserValues.h" 21 #include "core/css/parser/CSSParserValues.h"
21 #include "core/frame/UseCounter.h" 22 #include "core/frame/UseCounter.h"
22 #include "core/layout/LayoutTheme.h" 23 #include "core/layout/LayoutTheme.h"
23 #include "wtf/text/StringBuilder.h" 24 #include "wtf/text/StringBuilder.h"
24 25
25 namespace blink { 26 namespace blink {
26 27
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 CSSPrimitiveValue::UnitType unitType = m_calcValue->isInt() ? CSSPrimiti veValue::UnitType::Integer : CSSPrimitiveValue::UnitType::Number; 162 CSSPrimitiveValue::UnitType unitType = m_calcValue->isInt() ? CSSPrimiti veValue::UnitType::Integer : CSSPrimitiveValue::UnitType::Number;
162 return cssValuePool().createValue(m_calcValue->doubleValue(), unitType); 163 return cssValuePool().createValue(m_calcValue->doubleValue(), unitType);
163 } 164 }
164 165
165 private: 166 private:
166 CSSParserTokenRange& m_sourceRange; 167 CSSParserTokenRange& m_sourceRange;
167 CSSParserTokenRange m_range; 168 CSSParserTokenRange m_range;
168 RefPtrWillBeMember<CSSCalcValue> m_calcValue; 169 RefPtrWillBeMember<CSSCalcValue> m_calcValue;
169 }; 170 };
170 171
171 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeInteger(CSSParserTokenRa nge& range, CSSParserMode cssParserMode, double minimumValue = std::numeric_limi ts<int>::min()) 172 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeInteger(CSSParserTokenRa nge& range, CSSParserMode cssParserMode, double minimumValue = -std::numeric_lim its<double>::max())
172 { 173 {
173 const CSSParserToken& token = range.peek(); 174 const CSSParserToken& token = range.peek();
174 if (token.type() == NumberToken) { 175 if (token.type() == NumberToken) {
175 if (token.numericValueType() == NumberValueType || token.numericValue() < minimumValue) 176 if (token.numericValueType() == NumberValueType || token.numericValue() < minimumValue)
176 return nullptr; 177 return nullptr;
177 return cssValuePool().createValue(range.consumeIncludingWhitespace().num ericValue(), token.unitType()); 178 return cssValuePool().createValue(range.consumeIncludingWhitespace().num ericValue(), token.unitType());
178 } 179 }
179 CalcParser calcParser(range); 180 CalcParser calcParser(range);
180 if (const CSSCalcValue* calculation = calcParser.value()) { 181 if (const CSSCalcValue* calculation = calcParser.value()) {
181 if (calculation->category() != CalcNumber || !calculation->isInt()) 182 if (calculation->category() != CalcNumber || !calculation->isInt())
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 for (unsigned i = 0; i < 3; i++) { // 3 dimensions of rotation 635 for (unsigned i = 0; i < 3; i++) { // 3 dimensions of rotation
635 RefPtrWillBeRawPtr<CSSValue> dimension = consumeNumber(range, ValueRange All); 636 RefPtrWillBeRawPtr<CSSValue> dimension = consumeNumber(range, ValueRange All);
636 if (!dimension) 637 if (!dimension)
637 return nullptr; 638 return nullptr;
638 list->append(dimension.release()); 639 list->append(dimension.release());
639 } 640 }
640 641
641 return list.release(); 642 return list.release();
642 } 643 }
643 644
645 static PassRefPtrWillBeRawPtr<CSSValue> consumeCounter(CSSParserTokenRange& rang e, CSSParserMode cssParserMode, int defaultValue)
646 {
647 if (range.peek().id() == CSSValueNone)
648 return consumeIdent(range);
649
650 // TODO(rwlbuis): should be space separated list.
651 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ;
652 do {
653 RefPtrWillBeRawPtr<CSSCustomIdentValue> counterName = consumeCustomIdent (range);
654 if (!counterName)
655 return nullptr;
656 int i = defaultValue;
657 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> counterValue = consumeInteger( range, cssParserMode))
658 i = clampTo<int>(counterValue->getDoubleValue());
659 list->append(CSSValuePair::create(counterName.release(),
660 cssValuePool().createValue(i, CSSPrimitiveValue::UnitType::Number),
661 CSSValuePair::DropIdenticalValues));
662 } while (!range.atEnd());
663 return list.release();
664 }
665
644 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID propId) 666 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID propId)
645 { 667 {
646 m_range.consumeWhitespace(); 668 m_range.consumeWhitespace();
647 switch (propId) { 669 switch (propId) {
648 case CSSPropertyWillChange: 670 case CSSPropertyWillChange:
649 return consumeWillChange(m_range); 671 return consumeWillChange(m_range);
650 case CSSPropertyPage: 672 case CSSPropertyPage:
651 return consumePage(m_range); 673 return consumePage(m_range);
652 case CSSPropertyQuotes: 674 case CSSPropertyQuotes:
653 return consumeQuotes(m_range); 675 return consumeQuotes(m_range);
(...skipping 16 matching lines...) Expand all
670 return consumeTabSize(m_range, m_context.mode()); 692 return consumeTabSize(m_range, m_context.mode());
671 case CSSPropertyFontSize: 693 case CSSPropertyFontSize:
672 return consumeFontSize(m_range, m_context.mode(), UnitlessQuirk::Allow); 694 return consumeFontSize(m_range, m_context.mode(), UnitlessQuirk::Allow);
673 case CSSPropertyLineHeight: 695 case CSSPropertyLineHeight:
674 return consumeLineHeight(m_range, m_context.mode()); 696 return consumeLineHeight(m_range, m_context.mode());
675 case CSSPropertyRotate: 697 case CSSPropertyRotate:
676 return consumeRotation(m_range); 698 return consumeRotation(m_range);
677 case CSSPropertyWebkitBorderHorizontalSpacing: 699 case CSSPropertyWebkitBorderHorizontalSpacing:
678 case CSSPropertyWebkitBorderVerticalSpacing: 700 case CSSPropertyWebkitBorderVerticalSpacing:
679 return consumeLength(m_range, m_context.mode(), ValueRangeNonNegative); 701 return consumeLength(m_range, m_context.mode(), ValueRangeNonNegative);
702 case CSSPropertyCounterIncrement:
703 case CSSPropertyCounterReset:
704 return consumeCounter(m_range, m_context.mode(), propId == CSSPropertyCo unterIncrement ? 1 : 0);
680 default: 705 default:
681 return nullptr; 706 return nullptr;
682 } 707 }
683 } 708 }
684 709
685 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse rTokenRange& range) 710 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse rTokenRange& range)
686 { 711 {
687 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated (); 712 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated ();
688 713
689 do { 714 do {
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 } 1089 }
1065 case CSSPropertyBorderSpacing: 1090 case CSSPropertyBorderSpacing:
1066 return consumeBorderSpacing(important); 1091 return consumeBorderSpacing(important);
1067 default: 1092 default:
1068 m_currentShorthand = oldShorthand; 1093 m_currentShorthand = oldShorthand;
1069 return false; 1094 return false;
1070 } 1095 }
1071 } 1096 }
1072 1097
1073 } // namespace blink 1098 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698