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

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

Issue 1442233002: Move stroke-dasharray property into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 5 years, 1 month 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"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 case CSSPrimitiveValue::UnitType::Rems: 273 case CSSPrimitiveValue::UnitType::Rems:
274 case CSSPrimitiveValue::UnitType::Chs: 274 case CSSPrimitiveValue::UnitType::Chs:
275 case CSSPrimitiveValue::UnitType::Exs: 275 case CSSPrimitiveValue::UnitType::Exs:
276 case CSSPrimitiveValue::UnitType::Pixels: 276 case CSSPrimitiveValue::UnitType::Pixels:
277 case CSSPrimitiveValue::UnitType::Centimeters: 277 case CSSPrimitiveValue::UnitType::Centimeters:
278 case CSSPrimitiveValue::UnitType::Millimeters: 278 case CSSPrimitiveValue::UnitType::Millimeters:
279 case CSSPrimitiveValue::UnitType::Inches: 279 case CSSPrimitiveValue::UnitType::Inches:
280 case CSSPrimitiveValue::UnitType::Points: 280 case CSSPrimitiveValue::UnitType::Points:
281 case CSSPrimitiveValue::UnitType::Picas: 281 case CSSPrimitiveValue::UnitType::Picas:
282 case CSSPrimitiveValue::UnitType::UserUnits: 282 case CSSPrimitiveValue::UnitType::UserUnits:
283 break;
283 case CSSPrimitiveValue::UnitType::ViewportWidth: 284 case CSSPrimitiveValue::UnitType::ViewportWidth:
284 case CSSPrimitiveValue::UnitType::ViewportHeight: 285 case CSSPrimitiveValue::UnitType::ViewportHeight:
285 case CSSPrimitiveValue::UnitType::ViewportMin: 286 case CSSPrimitiveValue::UnitType::ViewportMin:
286 case CSSPrimitiveValue::UnitType::ViewportMax: 287 case CSSPrimitiveValue::UnitType::ViewportMax:
288 if (cssParserMode == SVGAttributeMode)
289 return nullptr;
287 break; 290 break;
288 default: 291 default:
289 return nullptr; 292 return nullptr;
290 } 293 }
291 if (valueRange == ValueRangeNonNegative && token.numericValue() < 0) 294 if (valueRange == ValueRangeNonNegative && token.numericValue() < 0)
292 return nullptr; 295 return nullptr;
293 return cssValuePool().createValue(range.consumeIncludingWhitespace().num ericValue(), token.unitType()); 296 return cssValuePool().createValue(range.consumeIncludingWhitespace().num ericValue(), token.unitType());
294 } 297 }
295 if (token.type() == NumberToken) { 298 if (token.type() == NumberToken) {
296 if (!shouldAcceptUnitlessValues(token.numericValue(), cssParserMode, uni tless) 299 if (!shouldAcceptUnitlessValues(token.numericValue(), cssParserMode, uni tless)
297 || (valueRange == ValueRangeNonNegative && token.numericValue() < 0) ) 300 || (valueRange == ValueRangeNonNegative && token.numericValue() < 0) )
298 return nullptr; 301 return nullptr;
299 CSSPrimitiveValue::UnitType unitType = CSSPrimitiveValue::UnitType::Pixe ls; 302 CSSPrimitiveValue::UnitType unitType = CSSPrimitiveValue::UnitType::Pixe ls;
300 if (cssParserMode == SVGAttributeMode) 303 if (cssParserMode == SVGAttributeMode)
301 unitType = CSSPrimitiveValue::UnitType::UserUnits; 304 unitType = CSSPrimitiveValue::UnitType::UserUnits;
302 return cssValuePool().createValue(range.consumeIncludingWhitespace().num ericValue(), unitType); 305 return cssValuePool().createValue(range.consumeIncludingWhitespace().num ericValue(), unitType);
303 } 306 }
307 if (cssParserMode == SVGAttributeMode)
308 return nullptr;
304 CalcParser calcParser(range, valueRange); 309 CalcParser calcParser(range, valueRange);
305 if (calcParser.value() && calcParser.value()->category() == CalcLength) 310 if (calcParser.value() && calcParser.value()->category() == CalcLength)
306 return calcParser.consumeValue(); 311 return calcParser.consumeValue();
307 return nullptr; 312 return nullptr;
308 } 313 }
309 314
310 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumePercent(CSSParserTokenRa nge& range, ValueRange valueRange) 315 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumePercent(CSSParserTokenRa nge& range, ValueRange valueRange)
311 { 316 {
312 const CSSParserToken& token = range.peek(); 317 const CSSParserToken& token = range.peek();
313 if (token.type() == PercentageToken) { 318 if (token.type() == PercentageToken) {
(...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 } 1848 }
1844 1849
1845 static PassRefPtrWillBeRawPtr<CSSValue> consumeFlexBasis(CSSParserTokenRange& ra nge, CSSParserMode cssParserMode) 1850 static PassRefPtrWillBeRawPtr<CSSValue> consumeFlexBasis(CSSParserTokenRange& ra nge, CSSParserMode cssParserMode)
1846 { 1851 {
1847 // FIXME: Support intrinsic dimensions too. 1852 // FIXME: Support intrinsic dimensions too.
1848 if (range.peek().id() == CSSValueAuto) 1853 if (range.peek().id() == CSSValueAuto)
1849 return consumeIdent(range); 1854 return consumeIdent(range);
1850 return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative); 1855 return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative);
1851 } 1856 }
1852 1857
1858 static PassRefPtrWillBeRawPtr<CSSValue> consumeStrokeDasharray(CSSParserTokenRan ge& range)
1859 {
1860 CSSValueID id = range.peek().id();
1861 if (id == CSSValueNone)
1862 return consumeIdent(range);
1863
1864 RefPtrWillBeRawPtr<CSSValueList> dashes = CSSValueList::createCommaSeparated ();
1865 do {
1866 RefPtrWillBeRawPtr<CSSPrimitiveValue> dash = consumeLengthOrPercent(rang e, SVGAttributeMode, ValueRangeNonNegative, UnitlessQuirk::Allow);
1867 if (!dash || (consumeCommaIncludingWhitespace(range) && range.atEnd()))
1868 return nullptr;
1869 dashes->append(dash.release());
1870 } while (!range.atEnd());
1871 return dashes.release();
1872 }
1873
1853 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty) 1874 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty)
1854 { 1875 {
1855 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); 1876 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty);
1856 m_range.consumeWhitespace(); 1877 m_range.consumeWhitespace();
1857 switch (property) { 1878 switch (property) {
1858 case CSSPropertyWillChange: 1879 case CSSPropertyWillChange:
1859 return consumeWillChange(m_range); 1880 return consumeWillChange(m_range);
1860 case CSSPropertyPage: 1881 case CSSPropertyPage:
1861 return consumePage(m_range); 1882 return consumePage(m_range);
1862 case CSSPropertyQuotes: 1883 case CSSPropertyQuotes:
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2018 return consumePaintOrder(m_range); 2039 return consumePaintOrder(m_range);
2019 case CSSPropertyMarkerStart: 2040 case CSSPropertyMarkerStart:
2020 case CSSPropertyMarkerMid: 2041 case CSSPropertyMarkerMid:
2021 case CSSPropertyMarkerEnd: 2042 case CSSPropertyMarkerEnd:
2022 return consumeNoneOrURI(m_range); 2043 return consumeNoneOrURI(m_range);
2023 case CSSPropertyFlexBasis: 2044 case CSSPropertyFlexBasis:
2024 return consumeFlexBasis(m_range, m_context.mode()); 2045 return consumeFlexBasis(m_range, m_context.mode());
2025 case CSSPropertyFlexGrow: 2046 case CSSPropertyFlexGrow:
2026 case CSSPropertyFlexShrink: 2047 case CSSPropertyFlexShrink:
2027 return consumeNumber(m_range, ValueRangeNonNegative); 2048 return consumeNumber(m_range, ValueRangeNonNegative);
2049 case CSSPropertyStrokeDasharray:
2050 return consumeStrokeDasharray(m_range);
2028 default: 2051 default:
2029 return nullptr; 2052 return nullptr;
2030 } 2053 }
2031 } 2054 }
2032 2055
2033 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse rTokenRange& range) 2056 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse rTokenRange& range)
2034 { 2057 {
2035 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated (); 2058 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated ();
2036 2059
2037 do { 2060 do {
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
2618 return consumeFlex(important); 2641 return consumeFlex(important);
2619 case CSSPropertyFlexFlow: 2642 case CSSPropertyFlexFlow:
2620 return consumeShorthandGreedily(flexFlowShorthand(), important); 2643 return consumeShorthandGreedily(flexFlowShorthand(), important);
2621 default: 2644 default:
2622 m_currentShorthand = oldShorthand; 2645 m_currentShorthand = oldShorthand;
2623 return false; 2646 return false;
2624 } 2647 }
2625 } 2648 }
2626 2649
2627 } // namespace blink 2650 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698