| 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, | |
| 78 const CSSParserContext& context, WillBeHeapVector<CSSProperty, 256>& parsedP
roperties, | |
| 79 StyleRule::Type ruleType) | |
| 80 : m_valueList(valueList) | |
| 81 , m_context(context) | |
| 82 , m_parsedProperties(parsedProperties) | |
| 83 , m_ruleType(ruleType) | |
| 84 , m_inParseShorthand(0) | |
| 85 , m_currentShorthand(CSSPropertyInvalid) | |
| 86 , m_implicitShorthand(false) | |
| 87 { | |
| 88 } | |
| 89 | |
| 90 bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
ant, | |
| 91 CSSParserValueList* valueList, const CSSParserContext& context, | |
| 92 WillBeHeapVector<CSSProperty, 256>& parsedProperties, StyleRule::Type ruleTy
pe) | |
| 93 { | |
| 94 int parsedPropertiesSize = parsedProperties.size(); | |
| 95 | |
| 96 CSSPropertyParser parser(valueList, context, parsedProperties, ruleType); | |
| 97 CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty); | |
| 98 bool parseSuccess; | |
| 99 | |
| 100 if (ruleType == StyleRule::Viewport) { | |
| 101 parseSuccess = (RuntimeEnabledFeatures::cssViewportEnabled() || isUAShee
tBehavior(context.mode())) | |
| 102 && parser.parseViewportProperty(resolvedProperty, important); | |
| 103 } else if (ruleType == StyleRule::FontFace) { | |
| 104 parseSuccess = parser.parseFontFaceDescriptor(resolvedProperty); | |
| 105 } else { | |
| 106 parseSuccess = parser.parseValue(unresolvedProperty, important); | |
| 107 } | |
| 108 | |
| 109 // This doesn't count UA style sheets | |
| 110 if (parseSuccess && context.useCounter()) | |
| 111 context.useCounter()->count(context, unresolvedProperty); | |
| 112 | |
| 113 if (!parseSuccess) | |
| 114 parser.rollbackLastProperties(parsedProperties.size() - parsedProperties
Size); | |
| 115 | |
| 116 return parseSuccess; | |
| 117 } | |
| 118 | |
| 119 void CSSPropertyParser::addProperty(CSSPropertyID propId, PassRefPtrWillBeRawPtr
<CSSValue> value, bool important, bool implicit) | 77 void CSSPropertyParser::addProperty(CSSPropertyID propId, PassRefPtrWillBeRawPtr
<CSSValue> value, bool important, bool implicit) |
| 120 { | 78 { |
| 121 ASSERT(!isPropertyAlias(propId)); | 79 ASSERT(!isPropertyAlias(propId)); |
| 122 | 80 |
| 123 int shorthandIndex = 0; | 81 int shorthandIndex = 0; |
| 124 bool setFromShorthand = false; | 82 bool setFromShorthand = false; |
| 125 | 83 |
| 126 if (m_currentShorthand) { | 84 if (m_currentShorthand) { |
| 127 Vector<StylePropertyShorthand, 4> shorthands; | 85 Vector<StylePropertyShorthand, 4> shorthands; |
| 128 getMatchingShorthandsForLonghand(propId, &shorthands); | 86 getMatchingShorthandsForLonghand(propId, &shorthands); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 | 420 |
| 463 if (CSSParserFastPaths::isKeywordPropertyID(propId)) { | 421 if (CSSParserFastPaths::isKeywordPropertyID(propId)) { |
| 464 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) | 422 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) |
| 465 return false; | 423 return false; |
| 466 if (m_valueList->next() && !inShorthand()) | 424 if (m_valueList->next() && !inShorthand()) |
| 467 return false; | 425 return false; |
| 468 addProperty(propId, cssValuePool().createIdentifierValue(id), important)
; | 426 addProperty(propId, cssValuePool().createIdentifierValue(id), important)
; |
| 469 return true; | 427 return true; |
| 470 } | 428 } |
| 471 | 429 |
| 430 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; |
| 431 if ((parsedValue = parseSingleValue(propId))) { |
| 432 if (!m_range.atEnd()) |
| 433 return false; |
| 434 addProperty(propId, parsedValue.release(), important); |
| 435 return true; |
| 436 } |
| 437 if (parseShorthand(propId, important)) |
| 438 return true; |
| 439 |
| 472 bool validPrimitive = false; | 440 bool validPrimitive = false; |
| 473 Units unitless = FUnknown; | 441 Units unitless = FUnknown; |
| 474 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | |
| 475 | 442 |
| 476 switch (propId) { | 443 switch (propId) { |
| 477 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size> || [ portrait
| landscape] ] | 444 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size> || [ portrait
| landscape] ] |
| 478 parsedValue = parseSize(); | 445 parsedValue = parseSize(); |
| 479 break; | 446 break; |
| 480 case CSSPropertyQuotes: // [<string> <string>]+ | none | |
| 481 if (id == CSSValueNone) | |
| 482 validPrimitive = true; | |
| 483 else | |
| 484 parsedValue = parseQuotes(); | |
| 485 break; | |
| 486 | 447 |
| 487 case CSSPropertyContent: // [ <string> | <uri> | <counter> | at
tr(X) | open-quote | | 448 case CSSPropertyContent: // [ <string> | <uri> | <counter> | at
tr(X) | open-quote | |
| 488 // close-quote | no-open-quote | no-close-quote ]+ | inherit | 449 // close-quote | no-open-quote | no-close-quote ]+ | inherit |
| 489 parsedValue = parseContent(); | 450 parsedValue = parseContent(); |
| 490 break; | 451 break; |
| 491 case CSSPropertyClip: // <shape> | auto | inherit | 452 case CSSPropertyClip: // <shape> | auto | inherit |
| 492 if (id == CSSValueAuto) | 453 if (id == CSSValueAuto) |
| 493 validPrimitive = true; | 454 validPrimitive = true; |
| 494 else if (value->m_unit == CSSParserValue::Function) | 455 else if (value->m_unit == CSSParserValue::Function) |
| 495 parsedValue = parseClipShape(); | 456 parsedValue = parseClipShape(); |
| 496 break; | 457 break; |
| 497 | 458 |
| 498 /* Start of supported CSS properties with validation. This is needed for par
seShorthand to work | 459 /* Start of supported CSS properties with validation. This is needed for par
seShorthand to work |
| 499 * correctly and allows optimization in blink::applyRule(..) | 460 * correctly and allows optimization in blink::applyRule(..) |
| 500 */ | 461 */ |
| 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 | 462 |
| 520 case CSSPropertyTextAlign: | 463 case CSSPropertyTextAlign: |
| 521 // left | right | center | justify | -webkit-left | -webkit-right | -web
kit-center | -webkit-match-parent | 464 // left | right | center | justify | -webkit-left | -webkit-right | -web
kit-center | -webkit-match-parent |
| 522 // | start | end | <string> | inherit | -webkit-auto (converted to start
) | 465 // | start | end | <string> | inherit | -webkit-auto (converted to start
) |
| 523 // FIXME: <string> not supported right now | 466 // FIXME: <string> not supported right now |
| 524 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id
== CSSValueStart || id == CSSValueEnd) { | 467 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id
== CSSValueStart || id == CSSValueEnd) { |
| 525 validPrimitive = true; | 468 validPrimitive = true; |
| 526 } | 469 } |
| 527 break; | 470 break; |
| 528 | 471 |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 break; | 1217 break; |
| 1275 | 1218 |
| 1276 case CSSPropertyGridTemplate: | 1219 case CSSPropertyGridTemplate: |
| 1277 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 1220 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 1278 return parseGridTemplateShorthand(important); | 1221 return parseGridTemplateShorthand(important); |
| 1279 | 1222 |
| 1280 case CSSPropertyGrid: | 1223 case CSSPropertyGrid: |
| 1281 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 1224 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 1282 return parseGridShorthand(important); | 1225 return parseGridShorthand(important); |
| 1283 | 1226 |
| 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: | 1227 case CSSPropertyWebkitColumnCount: |
| 1298 parsedValue = parseColumnCount(); | 1228 parsedValue = parseColumnCount(); |
| 1299 break; | 1229 break; |
| 1300 case CSSPropertyWebkitColumnGap: // normal | <length> | 1230 case CSSPropertyWebkitColumnGap: // normal | <length> |
| 1301 if (id == CSSValueNormal) | 1231 if (id == CSSValueNormal) |
| 1302 validPrimitive = true; | 1232 validPrimitive = true; |
| 1303 else | 1233 else |
| 1304 validPrimitive = validUnit(value, FLength | FNonNeg); | 1234 validPrimitive = validUnit(value, FLength | FNonNeg); |
| 1305 break; | 1235 break; |
| 1306 case CSSPropertyWebkitColumnSpan: // none | all | 1 (will be dropped in the
unprefixed property) | 1236 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); | 1237 validPrimitive = id == CSSValueAll || id == CSSValueNone || (value->unit
() == CSSPrimitiveValue::UnitType::Number && value->fValue == 1); |
| 1308 break; | 1238 break; |
| 1309 case CSSPropertyWebkitColumnWidth: // auto | <length> | 1239 case CSSPropertyWebkitColumnWidth: // auto | <length> |
| 1310 parsedValue = parseColumnWidth(); | 1240 parsedValue = parseColumnWidth(); |
| 1311 break; | 1241 break; |
| 1312 case CSSPropertyWillChange: | |
| 1313 parsedValue = parseWillChange(); | |
| 1314 break; | |
| 1315 // End of CSS3 properties | 1242 // End of CSS3 properties |
| 1316 | 1243 |
| 1317 // Apple specific properties. These will never be standardized and are pure
ly to | 1244 // Apple specific properties. These will never be standardized and are pure
ly to |
| 1318 // support custom WebKit-based Apple applications. | 1245 // support custom WebKit-based Apple applications. |
| 1319 case CSSPropertyWebkitLineClamp: | 1246 case CSSPropertyWebkitLineClamp: |
| 1320 // When specifying number of lines, don't allow 0 as a valid value | 1247 // When specifying number of lines, don't allow 0 as a valid value |
| 1321 // When specifying either type of unit, require non-negative integers | 1248 // 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)); | 1249 validPrimitive = (!id && !isCalculation(value) && validUnit(value, FInte
ger | FPercent | FNonNeg) && (value->unit() == CSSPrimitiveValue::UnitType::Perc
entage || value->fValue)); |
| 1323 break; | 1250 break; |
| 1324 | 1251 |
| 1325 case CSSPropertyWebkitFontSizeDelta: // <length> | 1252 case CSSPropertyWebkitFontSizeDelta: // <length> |
| 1326 validPrimitive = validUnit(value, FLength | FUnitlessQuirk); | 1253 validPrimitive = validUnit(value, FLength | FUnitlessQuirk); |
| 1327 break; | 1254 break; |
| 1328 | 1255 |
| 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: | 1256 case CSSPropertyWebkitHyphenateCharacter: |
| 1339 case CSSPropertyWebkitLocale: | 1257 case CSSPropertyWebkitLocale: |
| 1340 if (id == CSSValueAuto) { | 1258 if (id == CSSValueAuto) { |
| 1341 validPrimitive = true; | 1259 validPrimitive = true; |
| 1342 } else if (value->unit() == CSSPrimitiveValue::UnitType::String) { | 1260 } else if (value->unit() == CSSPrimitiveValue::UnitType::String) { |
| 1343 parsedValue = createPrimitiveStringValue(value); | 1261 parsedValue = createPrimitiveStringValue(value); |
| 1344 m_valueList->next(); | 1262 m_valueList->next(); |
| 1345 } | 1263 } |
| 1346 break; | 1264 break; |
| 1347 | 1265 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1436 case CSSPropertyWebkitColumnRule: | 1354 case CSSPropertyWebkitColumnRule: |
| 1437 return parseShorthand(propId, webkitColumnRuleShorthand(), important); | 1355 return parseShorthand(propId, webkitColumnRuleShorthand(), important); |
| 1438 case CSSPropertyWebkitTextStroke: | 1356 case CSSPropertyWebkitTextStroke: |
| 1439 return parseShorthand(propId, webkitTextStrokeShorthand(), important); | 1357 return parseShorthand(propId, webkitTextStrokeShorthand(), important); |
| 1440 case CSSPropertyAnimation: | 1358 case CSSPropertyAnimation: |
| 1441 return parseAnimationShorthand(unresolvedProperty == CSSPropertyAliasWeb
kitAnimation, important); | 1359 return parseAnimationShorthand(unresolvedProperty == CSSPropertyAliasWeb
kitAnimation, important); |
| 1442 case CSSPropertyTransition: | 1360 case CSSPropertyTransition: |
| 1443 return parseTransitionShorthand(important); | 1361 return parseTransitionShorthand(important); |
| 1444 case CSSPropertyInvalid: | 1362 case CSSPropertyInvalid: |
| 1445 return false; | 1363 return false; |
| 1446 case CSSPropertyPage: | |
| 1447 parsedValue = parsePage(); | |
| 1448 break; | |
| 1449 // CSS Text Layout Module Level 3: Vertical writing support | 1364 // CSS Text Layout Module Level 3: Vertical writing support |
| 1450 case CSSPropertyWebkitTextEmphasis: | 1365 case CSSPropertyWebkitTextEmphasis: |
| 1451 return parseShorthand(propId, webkitTextEmphasisShorthand(), important); | 1366 return parseShorthand(propId, webkitTextEmphasisShorthand(), important); |
| 1452 | 1367 |
| 1453 case CSSPropertyWebkitTextEmphasisStyle: | 1368 case CSSPropertyWebkitTextEmphasisStyle: |
| 1454 parsedValue = parseTextEmphasisStyle(); | 1369 parsedValue = parseTextEmphasisStyle(); |
| 1455 break; | 1370 break; |
| 1456 | 1371 |
| 1457 case CSSPropertyWebkitTextOrientation: | 1372 case CSSPropertyWebkitTextOrientation: |
| 1458 // FIXME: For now just support sideways, sideways-right, upright and ver
tical-right. | 1373 // 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 | 1431 // Properties below are validated inside parseViewportProperty, because we |
| 1517 // check for parser state. We need to invalidate if someone adds them outsid
e | 1432 // check for parser state. We need to invalidate if someone adds them outsid
e |
| 1518 // a @viewport rule. | 1433 // a @viewport rule. |
| 1519 case CSSPropertyMaxZoom: | 1434 case CSSPropertyMaxZoom: |
| 1520 case CSSPropertyMinZoom: | 1435 case CSSPropertyMinZoom: |
| 1521 case CSSPropertyOrientation: | 1436 case CSSPropertyOrientation: |
| 1522 case CSSPropertyUserZoom: | 1437 case CSSPropertyUserZoom: |
| 1523 validPrimitive = false; | 1438 validPrimitive = false; |
| 1524 break; | 1439 break; |
| 1525 | 1440 |
| 1441 // These were not accepted by the new path above so we should return false. |
| 1442 case CSSPropertyWebkitMarginCollapse: |
| 1443 case CSSPropertyWillChange: |
| 1444 case CSSPropertyPage: |
| 1445 case CSSPropertyOverflow: |
| 1446 case CSSPropertyQuotes: |
| 1447 case CSSPropertyWebkitHighlight: |
| 1448 validPrimitive = false; |
| 1449 break; |
| 1450 |
| 1526 case CSSPropertyScrollSnapPointsX: | 1451 case CSSPropertyScrollSnapPointsX: |
| 1527 case CSSPropertyScrollSnapPointsY: | 1452 case CSSPropertyScrollSnapPointsY: |
| 1528 parsedValue = parseScrollSnapPoints(); | 1453 parsedValue = parseScrollSnapPoints(); |
| 1529 break; | 1454 break; |
| 1530 case CSSPropertyScrollSnapCoordinate: | 1455 case CSSPropertyScrollSnapCoordinate: |
| 1531 parsedValue = parseScrollSnapCoordinate(); | 1456 parsedValue = parseScrollSnapCoordinate(); |
| 1532 break; | 1457 break; |
| 1533 case CSSPropertyScrollSnapDestination: | 1458 case CSSPropertyScrollSnapDestination: |
| 1534 parsedValue = parsePosition(m_valueList); | 1459 parsedValue = parsePosition(m_valueList); |
| 1535 break; | 1460 break; |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2057 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapCoordinate() | 1982 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapCoordinate() |
| 2058 { | 1983 { |
| 2059 if (m_valueList->current()->id == CSSValueNone) { | 1984 if (m_valueList->current()->id == CSSValueNone) { |
| 2060 m_valueList->next(); | 1985 m_valueList->next(); |
| 2061 return cssValuePool().createIdentifierValue(CSSValueNone); | 1986 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 2062 } | 1987 } |
| 2063 | 1988 |
| 2064 return parsePositionList(m_valueList); | 1989 return parsePositionList(m_valueList); |
| 2065 } | 1990 } |
| 2066 | 1991 |
| 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] ] | 1992 // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ] |
| 2081 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseSize() | 1993 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseSize() |
| 2082 { | 1994 { |
| 2083 CSSParserValue* value = m_valueList->current(); | 1995 CSSParserValue* value = m_valueList->current(); |
| 2084 ASSERT(value); | 1996 ASSERT(value); |
| 2085 | 1997 |
| 2086 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep
arated(); | 1998 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep
arated(); |
| 2087 | 1999 |
| 2088 // First parameter. | 2000 // First parameter. |
| 2089 SizeParameterType paramType = parseSizeParameter(parsedValues.get(), value,
None); | 2001 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)) { | 2048 if (validUnit(value, FLength | FNonNeg) && (prevParamType == None || pre
vParamType == Length)) { |
| 2137 parsedValues->append(createPrimitiveNumericValue(value)); | 2049 parsedValues->append(createPrimitiveNumericValue(value)); |
| 2138 return Length; | 2050 return Length; |
| 2139 } | 2051 } |
| 2140 return None; | 2052 return None; |
| 2141 default: | 2053 default: |
| 2142 return None; | 2054 return None; |
| 2143 } | 2055 } |
| 2144 } | 2056 } |
| 2145 | 2057 |
| 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 | 2058 // [ <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: | 2059 // in CSS 2.1 this got somewhat reduced: |
| 2165 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit | 2060 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit |
| 2166 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent() | 2061 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent() |
| 2167 { | 2062 { |
| 2168 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); | 2063 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); |
| 2169 | 2064 |
| 2170 while (CSSParserValue* val = m_valueList->current()) { | 2065 while (CSSParserValue* val = m_valueList->current()) { |
| 2171 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 2066 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; |
| 2172 if (val->unit() == CSSPrimitiveValue::UnitType::URI) { | 2067 if (val->unit() == CSSPrimitiveValue::UnitType::URI) { |
| (...skipping 4536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6709 break; | 6604 break; |
| 6710 | 6605 |
| 6711 // If there are more arguments, they should be after a comma. | 6606 // If there are more arguments, they should be after a comma. |
| 6712 if (!consumeComma(functionArgs)) | 6607 if (!consumeComma(functionArgs)) |
| 6713 return nullptr; | 6608 return nullptr; |
| 6714 } | 6609 } |
| 6715 | 6610 |
| 6716 return imageSet.release(); | 6611 return imageSet.release(); |
| 6717 } | 6612 } |
| 6718 | 6613 |
| 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) | 6614 PassRefPtrWillBeRawPtr<CSSFunctionValue> CSSPropertyParser::parseBuiltinFilterAr
guments(CSSParserValueList* args, CSSValueID filterType) |
| 6770 { | 6615 { |
| 6771 RefPtrWillBeRawPtr<CSSFunctionValue> filterValue = CSSFunctionValue::create(
filterType); | 6616 RefPtrWillBeRawPtr<CSSFunctionValue> filterValue = CSSFunctionValue::create(
filterType); |
| 6772 ASSERT(args); | 6617 ASSERT(args); |
| 6773 | 6618 |
| 6774 switch (filterType) { | 6619 switch (filterType) { |
| 6775 case CSSValueGrayscale: | 6620 case CSSValueGrayscale: |
| 6776 case CSSValueSepia: | 6621 case CSSValueSepia: |
| 6777 case CSSValueSaturate: | 6622 case CSSValueSaturate: |
| 6778 case CSSValueInvert: | 6623 case CSSValueInvert: |
| (...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7941 } | 7786 } |
| 7942 } | 7787 } |
| 7943 | 7788 |
| 7944 if (!list->length()) | 7789 if (!list->length()) |
| 7945 return nullptr; | 7790 return nullptr; |
| 7946 | 7791 |
| 7947 return list.release(); | 7792 return list.release(); |
| 7948 } | 7793 } |
| 7949 | 7794 |
| 7950 } // namespace blink | 7795 } // namespace blink |
| OLD | NEW |