OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
10 * | 10 * |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 template <unsigned N> | 67 template <unsigned N> |
68 static bool equalIgnoringCase(const CSSParserString& a, const char (&b)[N]) | 68 static bool equalIgnoringCase(const CSSParserString& a, const char (&b)[N]) |
69 { | 69 { |
70 unsigned length = N - 1; // Ignore the trailing null character | 70 unsigned length = N - 1; // Ignore the trailing null character |
71 if (a.length() != length) | 71 if (a.length() != length) |
72 return false; | 72 return false; |
73 | 73 |
74 return a.is8Bit() ? WTF::equalIgnoringCase(b, a.characters8(), length) : WTF
::equalIgnoringCase(b, a.characters16(), length); | 74 return a.is8Bit() ? WTF::equalIgnoringCase(b, a.characters8(), length) : WTF
::equalIgnoringCase(b, a.characters16(), length); |
75 } | 75 } |
76 | 76 |
77 CSSPropertyParser::CSSPropertyParser(CSSParserValueList* valueList, | 77 CSSPropertyParser::CSSPropertyParser(CSSParserValueList* valueList, const CSSPar
serTokenRange& range, |
78 const CSSParserContext& context, WillBeHeapVector<CSSProperty, 256>& parsedP
roperties, | 78 const CSSParserContext& context, WillBeHeapVector<CSSProperty, 256>& parsedP
roperties, |
79 StyleRule::Type ruleType) | 79 StyleRule::Type ruleType) |
80 : m_valueList(valueList) | 80 : m_valueList(valueList) |
| 81 , m_range(range) |
81 , m_context(context) | 82 , m_context(context) |
82 , m_parsedProperties(parsedProperties) | 83 , m_parsedProperties(parsedProperties) |
83 , m_ruleType(ruleType) | 84 , m_ruleType(ruleType) |
84 , m_inParseShorthand(0) | 85 , m_inParseShorthand(0) |
85 , m_currentShorthand(CSSPropertyInvalid) | 86 , m_currentShorthand(CSSPropertyInvalid) |
86 , m_implicitShorthand(false) | 87 , m_implicitShorthand(false) |
87 { | 88 { |
88 } | 89 } |
89 | 90 |
90 bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
ant, | 91 bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
ant, |
91 CSSParserValueList* valueList, const CSSParserContext& context, | 92 const CSSParserTokenRange& range, const CSSParserContext& context, |
92 WillBeHeapVector<CSSProperty, 256>& parsedProperties, StyleRule::Type ruleTy
pe) | 93 WillBeHeapVector<CSSProperty, 256>& parsedProperties, StyleRule::Type ruleTy
pe) |
93 { | 94 { |
94 int parsedPropertiesSize = parsedProperties.size(); | 95 int parsedPropertiesSize = parsedProperties.size(); |
95 | 96 |
96 CSSPropertyParser parser(valueList, context, parsedProperties, ruleType); | 97 CSSParserValueList valueList(range); |
| 98 if (!valueList.size()) |
| 99 return false; // Parser error |
| 100 CSSPropertyParser parser(&valueList, range, context, parsedProperties, ruleT
ype); |
97 CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty); | 101 CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty); |
98 bool parseSuccess; | 102 bool parseSuccess; |
99 | 103 |
100 if (ruleType == StyleRule::Viewport) { | 104 if (ruleType == StyleRule::Viewport) { |
101 parseSuccess = (RuntimeEnabledFeatures::cssViewportEnabled() || isUAShee
tBehavior(context.mode())) | 105 parseSuccess = (RuntimeEnabledFeatures::cssViewportEnabled() || isUAShee
tBehavior(context.mode())) |
102 && parser.parseViewportProperty(resolvedProperty, important); | 106 && parser.parseViewportProperty(resolvedProperty, important); |
103 } else if (ruleType == StyleRule::FontFace) { | 107 } else if (ruleType == StyleRule::FontFace) { |
104 parseSuccess = parser.parseFontFaceDescriptor(resolvedProperty); | 108 parseSuccess = parser.parseFontFaceDescriptor(resolvedProperty); |
105 } else { | 109 } else { |
106 parseSuccess = parser.parseValue(unresolvedProperty, important); | 110 parseSuccess = parser.parseValue(unresolvedProperty, important); |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 | 466 |
463 if (CSSParserFastPaths::isKeywordPropertyID(propId)) { | 467 if (CSSParserFastPaths::isKeywordPropertyID(propId)) { |
464 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) | 468 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) |
465 return false; | 469 return false; |
466 if (m_valueList->next() && !inShorthand()) | 470 if (m_valueList->next() && !inShorthand()) |
467 return false; | 471 return false; |
468 addProperty(propId, cssValuePool().createIdentifierValue(id), important)
; | 472 addProperty(propId, cssValuePool().createIdentifierValue(id), important)
; |
469 return true; | 473 return true; |
470 } | 474 } |
471 | 475 |
| 476 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; |
| 477 if ((parsedValue = parseSingleValue(propId))) { |
| 478 if (!m_range.atEnd()) |
| 479 return false; |
| 480 addProperty(propId, parsedValue.release(), important); |
| 481 return true; |
| 482 } |
| 483 if (parseShorthand(propId, important)) |
| 484 return true; |
| 485 |
472 bool validPrimitive = false; | 486 bool validPrimitive = false; |
473 Units unitless = FUnknown; | 487 Units unitless = FUnknown; |
474 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | |
475 | 488 |
476 switch (propId) { | 489 switch (propId) { |
477 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size> || [ portrait
| landscape] ] | 490 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size> || [ portrait
| landscape] ] |
478 parsedValue = parseSize(); | 491 parsedValue = parseSize(); |
479 break; | 492 break; |
480 case CSSPropertyQuotes: // [<string> <string>]+ | none | |
481 if (id == CSSValueNone) | |
482 validPrimitive = true; | |
483 else | |
484 parsedValue = parseQuotes(); | |
485 break; | |
486 | 493 |
487 case CSSPropertyContent: // [ <string> | <uri> | <counter> | at
tr(X) | open-quote | | 494 case CSSPropertyContent: // [ <string> | <uri> | <counter> | at
tr(X) | open-quote | |
488 // close-quote | no-open-quote | no-close-quote ]+ | inherit | 495 // close-quote | no-open-quote | no-close-quote ]+ | inherit |
489 parsedValue = parseContent(); | 496 parsedValue = parseContent(); |
490 break; | 497 break; |
491 case CSSPropertyClip: // <shape> | auto | inherit | 498 case CSSPropertyClip: // <shape> | auto | inherit |
492 if (id == CSSValueAuto) | 499 if (id == CSSValueAuto) |
493 validPrimitive = true; | 500 validPrimitive = true; |
494 else if (value->m_unit == CSSParserValue::Function) | 501 else if (value->m_unit == CSSParserValue::Function) |
495 parsedValue = parseClipShape(); | 502 parsedValue = parseClipShape(); |
496 break; | 503 break; |
497 | 504 |
498 /* Start of supported CSS properties with validation. This is needed for par
seShorthand to work | 505 /* Start of supported CSS properties with validation. This is needed for par
seShorthand to work |
499 * correctly and allows optimization in blink::applyRule(..) | 506 * correctly and allows optimization in blink::applyRule(..) |
500 */ | 507 */ |
501 case CSSPropertyOverflow: { | |
502 ShorthandScope scope(this, propId); | |
503 if (!parseValue(CSSPropertyOverflowY, important) || m_valueList->current
()) | |
504 return false; | |
505 | |
506 RefPtrWillBeRawPtr<CSSValue> overflowXValue = nullptr; | |
507 | |
508 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. I
f this value has been | |
509 // set using the shorthand, then for now overflow-x will default to auto
, but once we implement | |
510 // pagination controls, it should default to hidden. If the overflow-y v
alue is anything but | |
511 // paged-x or paged-y, then overflow-x and overflow-y should have the sa
me value. | |
512 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY) | |
513 overflowXValue = cssValuePool().createIdentifierValue(CSSValueAuto); | |
514 else | |
515 overflowXValue = m_parsedProperties.last().value(); | |
516 addProperty(CSSPropertyOverflowX, overflowXValue.release(), important); | |
517 return true; | |
518 } | |
519 | 508 |
520 case CSSPropertyTextAlign: | 509 case CSSPropertyTextAlign: |
521 // left | right | center | justify | -webkit-left | -webkit-right | -web
kit-center | -webkit-match-parent | 510 // left | right | center | justify | -webkit-left | -webkit-right | -web
kit-center | -webkit-match-parent |
522 // | start | end | <string> | inherit | -webkit-auto (converted to start
) | 511 // | start | end | <string> | inherit | -webkit-auto (converted to start
) |
523 // FIXME: <string> not supported right now | 512 // FIXME: <string> not supported right now |
524 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id
== CSSValueStart || id == CSSValueEnd) { | 513 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id
== CSSValueStart || id == CSSValueEnd) { |
525 validPrimitive = true; | 514 validPrimitive = true; |
526 } | 515 } |
527 break; | 516 break; |
528 | 517 |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 break; | 1263 break; |
1275 | 1264 |
1276 case CSSPropertyGridTemplate: | 1265 case CSSPropertyGridTemplate: |
1277 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 1266 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
1278 return parseGridTemplateShorthand(important); | 1267 return parseGridTemplateShorthand(important); |
1279 | 1268 |
1280 case CSSPropertyGrid: | 1269 case CSSPropertyGrid: |
1281 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 1270 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
1282 return parseGridShorthand(important); | 1271 return parseGridShorthand(important); |
1283 | 1272 |
1284 case CSSPropertyWebkitMarginCollapse: { | |
1285 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); | |
1286 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], importa
nt)) | |
1287 return false; | |
1288 if (!m_valueList->current()) { | |
1289 CSSValue* value = m_parsedProperties.last().value(); | |
1290 addProperty(webkitMarginCollapseShorthand().properties()[1], value,
important); | |
1291 return true; | |
1292 } | |
1293 if (!parseValue(webkitMarginCollapseShorthand().properties()[1], importa
nt)) | |
1294 return false; | |
1295 return !m_valueList->current(); | |
1296 } | |
1297 case CSSPropertyWebkitColumnCount: | 1273 case CSSPropertyWebkitColumnCount: |
1298 parsedValue = parseColumnCount(); | 1274 parsedValue = parseColumnCount(); |
1299 break; | 1275 break; |
1300 case CSSPropertyWebkitColumnGap: // normal | <length> | 1276 case CSSPropertyWebkitColumnGap: // normal | <length> |
1301 if (id == CSSValueNormal) | 1277 if (id == CSSValueNormal) |
1302 validPrimitive = true; | 1278 validPrimitive = true; |
1303 else | 1279 else |
1304 validPrimitive = validUnit(value, FLength | FNonNeg); | 1280 validPrimitive = validUnit(value, FLength | FNonNeg); |
1305 break; | 1281 break; |
1306 case CSSPropertyWebkitColumnSpan: // none | all | 1 (will be dropped in the
unprefixed property) | 1282 case CSSPropertyWebkitColumnSpan: // none | all | 1 (will be dropped in the
unprefixed property) |
1307 validPrimitive = id == CSSValueAll || id == CSSValueNone || (value->unit
() == CSSPrimitiveValue::UnitType::Number && value->fValue == 1); | 1283 validPrimitive = id == CSSValueAll || id == CSSValueNone || (value->unit
() == CSSPrimitiveValue::UnitType::Number && value->fValue == 1); |
1308 break; | 1284 break; |
1309 case CSSPropertyWebkitColumnWidth: // auto | <length> | 1285 case CSSPropertyWebkitColumnWidth: // auto | <length> |
1310 parsedValue = parseColumnWidth(); | 1286 parsedValue = parseColumnWidth(); |
1311 break; | 1287 break; |
1312 case CSSPropertyWillChange: | |
1313 parsedValue = parseWillChange(); | |
1314 break; | |
1315 // End of CSS3 properties | 1288 // End of CSS3 properties |
1316 | 1289 |
1317 // Apple specific properties. These will never be standardized and are pure
ly to | 1290 // Apple specific properties. These will never be standardized and are pure
ly to |
1318 // support custom WebKit-based Apple applications. | 1291 // support custom WebKit-based Apple applications. |
1319 case CSSPropertyWebkitLineClamp: | 1292 case CSSPropertyWebkitLineClamp: |
1320 // When specifying number of lines, don't allow 0 as a valid value | 1293 // When specifying number of lines, don't allow 0 as a valid value |
1321 // When specifying either type of unit, require non-negative integers | 1294 // When specifying either type of unit, require non-negative integers |
1322 validPrimitive = (!id && !isCalculation(value) && validUnit(value, FInte
ger | FPercent | FNonNeg) && (value->unit() == CSSPrimitiveValue::UnitType::Perc
entage || value->fValue)); | 1295 validPrimitive = (!id && !isCalculation(value) && validUnit(value, FInte
ger | FPercent | FNonNeg) && (value->unit() == CSSPrimitiveValue::UnitType::Perc
entage || value->fValue)); |
1323 break; | 1296 break; |
1324 | 1297 |
1325 case CSSPropertyWebkitFontSizeDelta: // <length> | 1298 case CSSPropertyWebkitFontSizeDelta: // <length> |
1326 validPrimitive = validUnit(value, FLength | FUnitlessQuirk); | 1299 validPrimitive = validUnit(value, FLength | FUnitlessQuirk); |
1327 break; | 1300 break; |
1328 | 1301 |
1329 case CSSPropertyWebkitHighlight: | |
1330 if (id == CSSValueNone) { | |
1331 validPrimitive = true; | |
1332 } else if (value->unit() == CSSPrimitiveValue::UnitType::String) { | |
1333 parsedValue = createPrimitiveStringValue(value); | |
1334 m_valueList->next(); | |
1335 } | |
1336 break; | |
1337 | |
1338 case CSSPropertyWebkitHyphenateCharacter: | 1302 case CSSPropertyWebkitHyphenateCharacter: |
1339 case CSSPropertyWebkitLocale: | 1303 case CSSPropertyWebkitLocale: |
1340 if (id == CSSValueAuto) { | 1304 if (id == CSSValueAuto) { |
1341 validPrimitive = true; | 1305 validPrimitive = true; |
1342 } else if (value->unit() == CSSPrimitiveValue::UnitType::String) { | 1306 } else if (value->unit() == CSSPrimitiveValue::UnitType::String) { |
1343 parsedValue = createPrimitiveStringValue(value); | 1307 parsedValue = createPrimitiveStringValue(value); |
1344 m_valueList->next(); | 1308 m_valueList->next(); |
1345 } | 1309 } |
1346 break; | 1310 break; |
1347 | 1311 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1436 case CSSPropertyWebkitColumnRule: | 1400 case CSSPropertyWebkitColumnRule: |
1437 return parseShorthand(propId, webkitColumnRuleShorthand(), important); | 1401 return parseShorthand(propId, webkitColumnRuleShorthand(), important); |
1438 case CSSPropertyWebkitTextStroke: | 1402 case CSSPropertyWebkitTextStroke: |
1439 return parseShorthand(propId, webkitTextStrokeShorthand(), important); | 1403 return parseShorthand(propId, webkitTextStrokeShorthand(), important); |
1440 case CSSPropertyAnimation: | 1404 case CSSPropertyAnimation: |
1441 return parseAnimationShorthand(unresolvedProperty == CSSPropertyAliasWeb
kitAnimation, important); | 1405 return parseAnimationShorthand(unresolvedProperty == CSSPropertyAliasWeb
kitAnimation, important); |
1442 case CSSPropertyTransition: | 1406 case CSSPropertyTransition: |
1443 return parseTransitionShorthand(important); | 1407 return parseTransitionShorthand(important); |
1444 case CSSPropertyInvalid: | 1408 case CSSPropertyInvalid: |
1445 return false; | 1409 return false; |
1446 case CSSPropertyPage: | |
1447 parsedValue = parsePage(); | |
1448 break; | |
1449 // CSS Text Layout Module Level 3: Vertical writing support | 1410 // CSS Text Layout Module Level 3: Vertical writing support |
1450 case CSSPropertyWebkitTextEmphasis: | 1411 case CSSPropertyWebkitTextEmphasis: |
1451 return parseShorthand(propId, webkitTextEmphasisShorthand(), important); | 1412 return parseShorthand(propId, webkitTextEmphasisShorthand(), important); |
1452 | 1413 |
1453 case CSSPropertyWebkitTextEmphasisStyle: | 1414 case CSSPropertyWebkitTextEmphasisStyle: |
1454 parsedValue = parseTextEmphasisStyle(); | 1415 parsedValue = parseTextEmphasisStyle(); |
1455 break; | 1416 break; |
1456 | 1417 |
1457 case CSSPropertyWebkitTextOrientation: | 1418 case CSSPropertyWebkitTextOrientation: |
1458 // FIXME: For now just support sideways, sideways-right, upright and ver
tical-right. | 1419 // FIXME: For now just support sideways, sideways-right, upright and ver
tical-right. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 // Properties below are validated inside parseViewportProperty, because we | 1477 // Properties below are validated inside parseViewportProperty, because we |
1517 // check for parser state. We need to invalidate if someone adds them outsid
e | 1478 // check for parser state. We need to invalidate if someone adds them outsid
e |
1518 // a @viewport rule. | 1479 // a @viewport rule. |
1519 case CSSPropertyMaxZoom: | 1480 case CSSPropertyMaxZoom: |
1520 case CSSPropertyMinZoom: | 1481 case CSSPropertyMinZoom: |
1521 case CSSPropertyOrientation: | 1482 case CSSPropertyOrientation: |
1522 case CSSPropertyUserZoom: | 1483 case CSSPropertyUserZoom: |
1523 validPrimitive = false; | 1484 validPrimitive = false; |
1524 break; | 1485 break; |
1525 | 1486 |
| 1487 // These were not accepted by the new path above so we should return false. |
| 1488 case CSSPropertyWebkitMarginCollapse: |
| 1489 case CSSPropertyWillChange: |
| 1490 case CSSPropertyPage: |
| 1491 case CSSPropertyOverflow: |
| 1492 case CSSPropertyQuotes: |
| 1493 case CSSPropertyWebkitHighlight: |
| 1494 validPrimitive = false; |
| 1495 break; |
| 1496 |
1526 case CSSPropertyScrollSnapPointsX: | 1497 case CSSPropertyScrollSnapPointsX: |
1527 case CSSPropertyScrollSnapPointsY: | 1498 case CSSPropertyScrollSnapPointsY: |
1528 parsedValue = parseScrollSnapPoints(); | 1499 parsedValue = parseScrollSnapPoints(); |
1529 break; | 1500 break; |
1530 case CSSPropertyScrollSnapCoordinate: | 1501 case CSSPropertyScrollSnapCoordinate: |
1531 parsedValue = parseScrollSnapCoordinate(); | 1502 parsedValue = parseScrollSnapCoordinate(); |
1532 break; | 1503 break; |
1533 case CSSPropertyScrollSnapDestination: | 1504 case CSSPropertyScrollSnapDestination: |
1534 parsedValue = parsePosition(m_valueList); | 1505 parsedValue = parsePosition(m_valueList); |
1535 break; | 1506 break; |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2057 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapCoordinate() | 2028 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapCoordinate() |
2058 { | 2029 { |
2059 if (m_valueList->current()->id == CSSValueNone) { | 2030 if (m_valueList->current()->id == CSSValueNone) { |
2060 m_valueList->next(); | 2031 m_valueList->next(); |
2061 return cssValuePool().createIdentifierValue(CSSValueNone); | 2032 return cssValuePool().createIdentifierValue(CSSValueNone); |
2062 } | 2033 } |
2063 | 2034 |
2064 return parsePositionList(m_valueList); | 2035 return parsePositionList(m_valueList); |
2065 } | 2036 } |
2066 | 2037 |
2067 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parsePage() | |
2068 { | |
2069 CSSParserValue* value = m_valueList->current(); | |
2070 m_valueList->next(); | |
2071 ASSERT(value); | |
2072 | |
2073 if (value->id == CSSValueAuto) | |
2074 return cssValuePool().createIdentifierValue(value->id); | |
2075 if (value->m_unit == CSSParserValue::Identifier) | |
2076 return createPrimitiveCustomIdentValue(value); | |
2077 return nullptr; | |
2078 } | |
2079 | |
2080 // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ] | 2038 // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ] |
2081 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseSize() | 2039 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseSize() |
2082 { | 2040 { |
2083 CSSParserValue* value = m_valueList->current(); | 2041 CSSParserValue* value = m_valueList->current(); |
2084 ASSERT(value); | 2042 ASSERT(value); |
2085 | 2043 |
2086 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep
arated(); | 2044 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep
arated(); |
2087 | 2045 |
2088 // First parameter. | 2046 // First parameter. |
2089 SizeParameterType paramType = parseSizeParameter(parsedValues.get(), value,
None); | 2047 SizeParameterType paramType = parseSizeParameter(parsedValues.get(), value,
None); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2136 if (validUnit(value, FLength | FNonNeg) && (prevParamType == None || pre
vParamType == Length)) { | 2094 if (validUnit(value, FLength | FNonNeg) && (prevParamType == None || pre
vParamType == Length)) { |
2137 parsedValues->append(createPrimitiveNumericValue(value)); | 2095 parsedValues->append(createPrimitiveNumericValue(value)); |
2138 return Length; | 2096 return Length; |
2139 } | 2097 } |
2140 return None; | 2098 return None; |
2141 default: | 2099 default: |
2142 return None; | 2100 return None; |
2143 } | 2101 } |
2144 } | 2102 } |
2145 | 2103 |
2146 // [ <string> <string> ]+ | none, but none is handled in parseValue | |
2147 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseQuotes() | |
2148 { | |
2149 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); | |
2150 while (CSSParserValue* val = m_valueList->current()) { | |
2151 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | |
2152 if (val->unit() != CSSPrimitiveValue::UnitType::String) | |
2153 return nullptr; | |
2154 parsedValue = createPrimitiveStringValue(val); | |
2155 values->append(parsedValue.release()); | |
2156 m_valueList->next(); | |
2157 } | |
2158 if (values->length() && values->length() % 2 == 0) | |
2159 return values.release(); | |
2160 return nullptr; | |
2161 } | |
2162 | |
2163 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open
-quote | no-close-quote ]+ | inherit | 2104 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open
-quote | no-close-quote ]+ | inherit |
2164 // in CSS 2.1 this got somewhat reduced: | 2105 // in CSS 2.1 this got somewhat reduced: |
2165 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit | 2106 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit |
2166 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent() | 2107 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent() |
2167 { | 2108 { |
2168 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); | 2109 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); |
2169 | 2110 |
2170 while (CSSParserValue* val = m_valueList->current()) { | 2111 while (CSSParserValue* val = m_valueList->current()) { |
2171 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 2112 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; |
2172 if (val->unit() == CSSPrimitiveValue::UnitType::URI) { | 2113 if (val->unit() == CSSPrimitiveValue::UnitType::URI) { |
(...skipping 4536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6709 break; | 6650 break; |
6710 | 6651 |
6711 // If there are more arguments, they should be after a comma. | 6652 // If there are more arguments, they should be after a comma. |
6712 if (!consumeComma(functionArgs)) | 6653 if (!consumeComma(functionArgs)) |
6713 return nullptr; | 6654 return nullptr; |
6714 } | 6655 } |
6715 | 6656 |
6716 return imageSet.release(); | 6657 return imageSet.release(); |
6717 } | 6658 } |
6718 | 6659 |
6719 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseWillChange() | |
6720 { | |
6721 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); | |
6722 if (m_valueList->current()->id == CSSValueAuto) { | |
6723 // FIXME: This will be read back as an empty string instead of auto | |
6724 return values.release(); | |
6725 } | |
6726 | |
6727 // Every comma-separated list of identifiers is a valid will-change value, | |
6728 // unless the list includes an explicitly disallowed identifier. | |
6729 while (true) { | |
6730 CSSParserValue* currentValue = m_valueList->current(); | |
6731 if (!currentValue || currentValue->m_unit != CSSParserValue::Identifier) | |
6732 return nullptr; | |
6733 | |
6734 CSSPropertyID unresolvedProperty = unresolvedCSSPropertyID(currentValue-
>string); | |
6735 if (unresolvedProperty) { | |
6736 ASSERT(CSSPropertyMetadata::isEnabledProperty(unresolvedProperty)); | |
6737 // Now "all" is used by both CSSValue and CSSPropertyValue. | |
6738 // Need to return nullptr when currentValue is CSSPropertyAll. | |
6739 if (unresolvedProperty == CSSPropertyWillChange || unresolvedPropert
y == CSSPropertyAll) | |
6740 return nullptr; | |
6741 values->append(cssValuePool().createIdentifierValue(unresolvedProper
ty)); | |
6742 } else { | |
6743 switch (currentValue->id) { | |
6744 case CSSValueNone: | |
6745 case CSSValueAll: | |
6746 case CSSValueAuto: | |
6747 case CSSValueDefault: | |
6748 case CSSValueInitial: | |
6749 case CSSValueInherit: | |
6750 return nullptr; | |
6751 case CSSValueContents: | |
6752 case CSSValueScrollPosition: | |
6753 values->append(cssValuePool().createIdentifierValue(currentValue
->id)); | |
6754 break; | |
6755 default: | |
6756 break; | |
6757 } | |
6758 } | |
6759 | |
6760 if (!m_valueList->next()) | |
6761 break; | |
6762 if (!consumeComma(m_valueList)) | |
6763 return nullptr; | |
6764 } | |
6765 | |
6766 return values.release(); | |
6767 } | |
6768 | |
6769 PassRefPtrWillBeRawPtr<CSSFunctionValue> CSSPropertyParser::parseBuiltinFilterAr
guments(CSSParserValueList* args, CSSValueID filterType) | 6660 PassRefPtrWillBeRawPtr<CSSFunctionValue> CSSPropertyParser::parseBuiltinFilterAr
guments(CSSParserValueList* args, CSSValueID filterType) |
6770 { | 6661 { |
6771 RefPtrWillBeRawPtr<CSSFunctionValue> filterValue = CSSFunctionValue::create(
filterType); | 6662 RefPtrWillBeRawPtr<CSSFunctionValue> filterValue = CSSFunctionValue::create(
filterType); |
6772 ASSERT(args); | 6663 ASSERT(args); |
6773 | 6664 |
6774 switch (filterType) { | 6665 switch (filterType) { |
6775 case CSSValueGrayscale: | 6666 case CSSValueGrayscale: |
6776 case CSSValueSepia: | 6667 case CSSValueSepia: |
6777 case CSSValueSaturate: | 6668 case CSSValueSaturate: |
6778 case CSSValueInvert: | 6669 case CSSValueInvert: |
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7941 } | 7832 } |
7942 } | 7833 } |
7943 | 7834 |
7944 if (!list->length()) | 7835 if (!list->length()) |
7945 return nullptr; | 7836 return nullptr; |
7946 | 7837 |
7947 return list.release(); | 7838 return list.release(); |
7948 } | 7839 } |
7949 | 7840 |
7950 } // namespace blink | 7841 } // namespace blink |
OLD | NEW |