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

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

Issue 1419223002: Move text-shadow/box-shadow properties into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix failures 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"
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/CSSQuadValue.h" 14 #include "core/css/CSSQuadValue.h"
15 #include "core/css/CSSShadowValue.h"
15 #include "core/css/CSSStringValue.h" 16 #include "core/css/CSSStringValue.h"
16 #include "core/css/CSSTimingFunctionValue.h" 17 #include "core/css/CSSTimingFunctionValue.h"
17 #include "core/css/CSSURIValue.h" 18 #include "core/css/CSSURIValue.h"
18 #include "core/css/CSSUnicodeRangeValue.h" 19 #include "core/css/CSSUnicodeRangeValue.h"
19 #include "core/css/CSSValuePair.h" 20 #include "core/css/CSSValuePair.h"
20 #include "core/css/CSSValuePool.h" 21 #include "core/css/CSSValuePool.h"
21 #include "core/css/FontFace.h" 22 #include "core/css/FontFace.h"
22 #include "core/css/parser/CSSParserFastPaths.h" 23 #include "core/css/parser/CSSParserFastPaths.h"
23 #include "core/css/parser/CSSParserValues.h" 24 #include "core/css/parser/CSSParserValues.h"
24 #include "core/frame/UseCounter.h" 25 #include "core/frame/UseCounter.h"
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 return nullptr; 1138 return nullptr;
1138 } 1139 }
1139 1140
1140 static PassRefPtrWillBeRawPtr<CSSValue> consumeAnimationIterationCount(CSSParser TokenRange& range) 1141 static PassRefPtrWillBeRawPtr<CSSValue> consumeAnimationIterationCount(CSSParser TokenRange& range)
1141 { 1142 {
1142 if (range.peek().id() == CSSValueInfinite) 1143 if (range.peek().id() == CSSValueInfinite)
1143 return consumeIdent(range); 1144 return consumeIdent(range);
1144 return consumeNumber(range, ValueRangeNonNegative); 1145 return consumeNumber(range, ValueRangeNonNegative);
1145 } 1146 }
1146 1147
1147 static PassRefPtrWillBeRawPtr<CSSValue> consumeZIndex(CSSParserTokenRange& range )
1148 {
1149 if (range.peek().id() == CSSValueAuto)
1150 return consumeIdent(range);
1151 return consumeInteger(range);
1152 }
1153
1154 static PassRefPtrWillBeRawPtr<CSSValue> consumeAnimationPlayState(CSSParserToken Range& range) 1148 static PassRefPtrWillBeRawPtr<CSSValue> consumeAnimationPlayState(CSSParserToken Range& range)
1155 { 1149 {
1156 CSSValueID id = range.peek().id(); 1150 CSSValueID id = range.peek().id();
1157 if (id == CSSValueRunning || id == CSSValuePaused) 1151 if (id == CSSValueRunning || id == CSSValuePaused)
1158 return consumeIdent(range); 1152 return consumeIdent(range);
1159 return nullptr; 1153 return nullptr;
1160 } 1154 }
1161 1155
1162 static PassRefPtrWillBeRawPtr<CSSValue> consumeAnimationName(CSSParserTokenRange & range, const CSSParserContext& context, bool allowQuotedName) 1156 static PassRefPtrWillBeRawPtr<CSSValue> consumeAnimationName(CSSParserTokenRange & range, const CSSParserContext& context, bool allowQuotedName)
1163 { 1157 {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 && consumeCommaIncludingWhitespace(args) 1244 && consumeCommaIncludingWhitespace(args)
1251 && consumeNumberRaw(args, y2) 1245 && consumeNumberRaw(args, y2)
1252 && args.atEnd()) { 1246 && args.atEnd()) {
1253 range = rangeCopy; 1247 range = rangeCopy;
1254 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2); 1248 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2);
1255 } 1249 }
1256 1250
1257 return nullptr; 1251 return nullptr;
1258 } 1252 }
1259 1253
1260
1261 static PassRefPtrWillBeRawPtr<CSSValue> consumeAnimationTimingFunction(CSSParser TokenRange& range) 1254 static PassRefPtrWillBeRawPtr<CSSValue> consumeAnimationTimingFunction(CSSParser TokenRange& range)
1262 { 1255 {
1263 CSSValueID id = range.peek().id(); 1256 CSSValueID id = range.peek().id();
1264 if (id == CSSValueEase || id == CSSValueLinear || id == CSSValueEaseIn 1257 if (id == CSSValueEase || id == CSSValueLinear || id == CSSValueEaseIn
1265 || id == CSSValueEaseOut || id == CSSValueEaseInOut || id == CSSValueSte pStart 1258 || id == CSSValueEaseOut || id == CSSValueEaseInOut || id == CSSValueSte pStart
1266 || id == CSSValueStepEnd || id == CSSValueStepMiddle) 1259 || id == CSSValueStepEnd || id == CSSValueStepMiddle)
1267 return consumeIdent(range); 1260 return consumeIdent(range);
1268 1261
1269 CSSValueID function = range.peek().functionId(); 1262 CSSValueID function = range.peek().functionId();
1270 if (function == CSSValueSteps) 1263 if (function == CSSValueSteps)
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 } 1371 }
1379 1372
1380 static PassRefPtrWillBeRawPtr<CSSValue> consumeWidowsOrOrphans(CSSParserTokenRan ge& range) 1373 static PassRefPtrWillBeRawPtr<CSSValue> consumeWidowsOrOrphans(CSSParserTokenRan ge& range)
1381 { 1374 {
1382 // Support for auto is non-standard and for backwards compatibility. 1375 // Support for auto is non-standard and for backwards compatibility.
1383 if (range.peek().id() == CSSValueAuto) 1376 if (range.peek().id() == CSSValueAuto)
1384 return consumeIdent(range); 1377 return consumeIdent(range);
1385 return consumePositiveInteger(range); 1378 return consumePositiveInteger(range);
1386 } 1379 }
1387 1380
1381 static PassRefPtrWillBeRawPtr<CSSValue> consumeZIndex(CSSParserTokenRange& range )
1382 {
1383 if (range.peek().id() == CSSValueAuto)
1384 return consumeIdent(range);
1385 return consumeInteger(range);
1386 }
1387
1388 static PassRefPtrWillBeRawPtr<CSSShadowValue> parseSingleShadow(CSSParserTokenRa nge& range, const CSSParserContext& context, bool allowInset, bool allowSpread)
1389 {
1390 RefPtrWillBeRawPtr<CSSPrimitiveValue> style = nullptr;
1391 RefPtrWillBeRawPtr<CSSValue> color = nullptr;
1392
1393 if (range.atEnd())
1394 return nullptr;
1395 if (range.peek().id() == CSSValueInset) {
1396 if (!allowInset)
1397 return nullptr;
1398 style = consumeIdent(range);
1399 }
1400 color = consumeColor(range, context);
1401
1402 RefPtrWillBeRawPtr<CSSPrimitiveValue> horizontalOffset = consumeLength(range , context.mode(), ValueRangeAll);
1403 if (!horizontalOffset)
1404 return nullptr;
1405
1406 RefPtrWillBeRawPtr<CSSPrimitiveValue> verticalOffset = consumeLength(range, context.mode(), ValueRangeAll);
1407 if (!verticalOffset)
1408 return nullptr;
1409
1410 RefPtrWillBeRawPtr<CSSPrimitiveValue> blurRadius = consumeLength(range, cont ext.mode(), ValueRangeAll);
1411 RefPtrWillBeRawPtr<CSSPrimitiveValue> spreadDistance = nullptr;
1412 if (blurRadius) {
1413 // Blur radius must be non-negative.
1414 if (blurRadius->getDoubleValue() < 0)
1415 return nullptr;
1416 if (allowSpread)
1417 spreadDistance = consumeLength(range, context.mode(), ValueRangeAll) ;
1418 }
1419
1420 if (!range.atEnd()) {
1421 if (!color)
1422 color = consumeColor(range, context);
1423 if (range.peek().id() == CSSValueInset) {
1424 if (!allowInset || style)
1425 return nullptr;
1426 style = consumeIdent(range);
1427 }
1428 }
1429 return CSSShadowValue::create(horizontalOffset.release(), verticalOffset.rel ease(), blurRadius.release(),
1430 spreadDistance.release(), style.release(), color.release());
1431 }
1432
1433 static PassRefPtrWillBeRawPtr<CSSValue> consumeShadow(CSSParserTokenRange& range , const CSSParserContext& context, bool isBoxShadowProperty)
1434 {
1435 if (range.peek().id() == CSSValueNone)
1436 return consumeIdent(range);
1437
1438 RefPtrWillBeRawPtr<CSSValueList> shadowValueList = CSSValueList::createComma Separated();
1439 do {
1440 if (RefPtrWillBeRawPtr<CSSShadowValue> shadowValue = parseSingleShadow(r ange, context, isBoxShadowProperty, isBoxShadowProperty))
1441 shadowValueList->append(shadowValue.release());
1442 else
1443 return nullptr;
1444 } while (consumeCommaIncludingWhitespace(range));
1445 return shadowValueList;
1446 }
1447
1388 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty) 1448 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty)
1389 { 1449 {
1390 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); 1450 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty);
1391 m_range.consumeWhitespace(); 1451 m_range.consumeWhitespace();
1392 switch (property) { 1452 switch (property) {
1393 case CSSPropertyWillChange: 1453 case CSSPropertyWillChange:
1394 return consumeWillChange(m_range); 1454 return consumeWillChange(m_range);
1395 case CSSPropertyPage: 1455 case CSSPropertyPage:
1396 return consumePage(m_range); 1456 return consumePage(m_range);
1397 case CSSPropertyQuotes: 1457 case CSSPropertyQuotes:
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 case CSSPropertyOrphans: 1542 case CSSPropertyOrphans:
1483 case CSSPropertyWidows: 1543 case CSSPropertyWidows:
1484 return consumeWidowsOrOrphans(m_range); 1544 return consumeWidowsOrOrphans(m_range);
1485 case CSSPropertyWebkitTextFillColor: 1545 case CSSPropertyWebkitTextFillColor:
1486 case CSSPropertyWebkitTapHighlightColor: 1546 case CSSPropertyWebkitTapHighlightColor:
1487 return consumeColor(m_range, m_context); 1547 return consumeColor(m_range, m_context);
1488 case CSSPropertyColor: 1548 case CSSPropertyColor:
1489 return consumeColor(m_range, m_context, inQuirksMode()); 1549 return consumeColor(m_range, m_context, inQuirksMode());
1490 case CSSPropertyZIndex: 1550 case CSSPropertyZIndex:
1491 return consumeZIndex(m_range); 1551 return consumeZIndex(m_range);
1552 case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS 3, so treat as CSS3
1553 case CSSPropertyBoxShadow:
1554 return consumeShadow(m_range, m_context, property == CSSPropertyBoxShado w);
1492 default: 1555 default:
1493 return nullptr; 1556 return nullptr;
1494 } 1557 }
1495 } 1558 }
1496 1559
1497 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse rTokenRange& range) 1560 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse rTokenRange& range)
1498 { 1561 {
1499 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated (); 1562 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated ();
1500 1563
1501 do { 1564 do {
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 return consumeAnimationShorthand(animationShorthandForParsing(), unresol vedProperty == CSSPropertyAliasWebkitAnimation, important); 1981 return consumeAnimationShorthand(animationShorthandForParsing(), unresol vedProperty == CSSPropertyAliasWebkitAnimation, important);
1919 case CSSPropertyTransition: 1982 case CSSPropertyTransition:
1920 return consumeAnimationShorthand(transitionShorthandForParsing(), false, important); 1983 return consumeAnimationShorthand(transitionShorthandForParsing(), false, important);
1921 default: 1984 default:
1922 m_currentShorthand = oldShorthand; 1985 m_currentShorthand = oldShorthand;
1923 return false; 1986 return false;
1924 } 1987 }
1925 } 1988 }
1926 1989
1927 } // namespace blink 1990 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698