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 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 #else | 1468 #else |
1469 filterProperties(true, m_parsedProperties, results, unusedEntries, seenPrope
rties); | 1469 filterProperties(true, m_parsedProperties, results, unusedEntries, seenPrope
rties); |
1470 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProp
erties); | 1470 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProp
erties); |
1471 #endif | 1471 #endif |
1472 if (unusedEntries) | 1472 if (unusedEntries) |
1473 results.remove(0, unusedEntries); | 1473 results.remove(0, unusedEntries); |
1474 | 1474 |
1475 return StylePropertySet::createImmutable(results.data(), results.size(), m_c
ontext.mode); | 1475 return StylePropertySet::createImmutable(results.data(), results.size(), m_c
ontext.mode); |
1476 } | 1476 } |
1477 | 1477 |
| 1478 void CSSParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtr
<CSSValue> value, bool important, bool implicit) |
| 1479 { |
| 1480 RefPtr<CSSValue> val = value.get(); |
| 1481 addProperty(propId, value, important, implicit); |
| 1482 |
| 1483 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propId); |
| 1484 if (prefixingVariant == propId) |
| 1485 return; |
| 1486 addProperty(prefixingVariant, val.release(), important, implicit); |
| 1487 } |
| 1488 |
1478 void CSSParser::addProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bo
ol important, bool implicit) | 1489 void CSSParser::addProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bo
ol important, bool implicit) |
1479 { | 1490 { |
1480 m_parsedProperties.append(CSSProperty(propId, value, important, m_currentSho
rthand, m_implicitShorthand || implicit)); | 1491 m_parsedProperties.append(CSSProperty(propId, value, important, m_currentSho
rthand, m_implicitShorthand || implicit)); |
1481 } | 1492 } |
1482 | 1493 |
1483 void CSSParser::rollbackLastProperties(int num) | 1494 void CSSParser::rollbackLastProperties(int num) |
1484 { | 1495 { |
1485 ASSERT(num >= 0); | 1496 ASSERT(num >= 0); |
1486 ASSERT(m_parsedProperties.size() >= static_cast<unsigned>(num)); | 1497 ASSERT(m_parsedProperties.size() >= static_cast<unsigned>(num)); |
1487 m_parsedProperties.shrink(m_parsedProperties.size() - num); | 1498 m_parsedProperties.shrink(m_parsedProperties.size() - num); |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2492 return false; | 2503 return false; |
2493 } | 2504 } |
2494 case CSSPropertyWebkitAnimationDelay: | 2505 case CSSPropertyWebkitAnimationDelay: |
2495 case CSSPropertyWebkitAnimationDirection: | 2506 case CSSPropertyWebkitAnimationDirection: |
2496 case CSSPropertyWebkitAnimationDuration: | 2507 case CSSPropertyWebkitAnimationDuration: |
2497 case CSSPropertyWebkitAnimationFillMode: | 2508 case CSSPropertyWebkitAnimationFillMode: |
2498 case CSSPropertyWebkitAnimationName: | 2509 case CSSPropertyWebkitAnimationName: |
2499 case CSSPropertyWebkitAnimationPlayState: | 2510 case CSSPropertyWebkitAnimationPlayState: |
2500 case CSSPropertyWebkitAnimationIterationCount: | 2511 case CSSPropertyWebkitAnimationIterationCount: |
2501 case CSSPropertyWebkitAnimationTimingFunction: | 2512 case CSSPropertyWebkitAnimationTimingFunction: |
| 2513 case CSSPropertyTransitionDelay: |
| 2514 case CSSPropertyTransitionDuration: |
| 2515 case CSSPropertyTransitionTimingFunction: |
| 2516 case CSSPropertyTransitionProperty: |
2502 case CSSPropertyWebkitTransitionDelay: | 2517 case CSSPropertyWebkitTransitionDelay: |
2503 case CSSPropertyWebkitTransitionDuration: | 2518 case CSSPropertyWebkitTransitionDuration: |
2504 case CSSPropertyWebkitTransitionTimingFunction: | 2519 case CSSPropertyWebkitTransitionTimingFunction: |
2505 case CSSPropertyWebkitTransitionProperty: { | 2520 case CSSPropertyWebkitTransitionProperty: { |
2506 RefPtr<CSSValue> val; | 2521 RefPtr<CSSValue> val; |
2507 if (parseAnimationProperty(propId, val)) { | 2522 if (parseAnimationProperty(propId, val)) { |
2508 addProperty(propId, val.release(), important); | 2523 addPropertyWithPrefixingVariant(propId, val.release(), important); |
2509 return true; | 2524 return true; |
2510 } | 2525 } |
2511 return false; | 2526 return false; |
2512 } | 2527 } |
2513 | 2528 |
2514 case CSSPropertyWebkitGridColumns: | 2529 case CSSPropertyWebkitGridColumns: |
2515 case CSSPropertyWebkitGridRows: | 2530 case CSSPropertyWebkitGridRows: |
2516 if (!cssGridLayoutEnabled()) | 2531 if (!cssGridLayoutEnabled()) |
2517 return false; | 2532 return false; |
2518 return parseGridTrackList(propId, important); | 2533 return parseGridTrackList(propId, important); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2737 case CSSPropertyListStyle: | 2752 case CSSPropertyListStyle: |
2738 return parseShorthand(propId, listStyleShorthand(), important); | 2753 return parseShorthand(propId, listStyleShorthand(), important); |
2739 case CSSPropertyWebkitColumns: | 2754 case CSSPropertyWebkitColumns: |
2740 return parseShorthand(propId, webkitColumnsShorthand(), important); | 2755 return parseShorthand(propId, webkitColumnsShorthand(), important); |
2741 case CSSPropertyWebkitColumnRule: | 2756 case CSSPropertyWebkitColumnRule: |
2742 return parseShorthand(propId, webkitColumnRuleShorthand(), important); | 2757 return parseShorthand(propId, webkitColumnRuleShorthand(), important); |
2743 case CSSPropertyWebkitTextStroke: | 2758 case CSSPropertyWebkitTextStroke: |
2744 return parseShorthand(propId, webkitTextStrokeShorthand(), important); | 2759 return parseShorthand(propId, webkitTextStrokeShorthand(), important); |
2745 case CSSPropertyWebkitAnimation: | 2760 case CSSPropertyWebkitAnimation: |
2746 return parseAnimationShorthand(important); | 2761 return parseAnimationShorthand(important); |
| 2762 case CSSPropertyTransition: |
2747 case CSSPropertyWebkitTransition: | 2763 case CSSPropertyWebkitTransition: |
2748 return parseTransitionShorthand(important); | 2764 return parseTransitionShorthand(propId, important); |
2749 case CSSPropertyInvalid: | 2765 case CSSPropertyInvalid: |
2750 return false; | 2766 return false; |
2751 case CSSPropertyPage: | 2767 case CSSPropertyPage: |
2752 return parsePage(propId, important); | 2768 return parsePage(propId, important); |
2753 case CSSPropertyFontStretch: | 2769 case CSSPropertyFontStretch: |
2754 case CSSPropertyTextLineThrough: | 2770 case CSSPropertyTextLineThrough: |
2755 case CSSPropertyTextOverline: | 2771 case CSSPropertyTextOverline: |
2756 case CSSPropertyTextUnderline: | 2772 case CSSPropertyTextUnderline: |
2757 return false; | 2773 return false; |
2758 // CSS Text Layout Module Level 3: Vertical writing support | 2774 // CSS Text Layout Module Level 3: Vertical writing support |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3249 // If we didn't find the property, set an intial value. | 3265 // If we didn't find the property, set an intial value. |
3250 if (!parsedProperty[i]) | 3266 if (!parsedProperty[i]) |
3251 addAnimationValue(values[i], cssValuePool().createImplicitInitialVal
ue()); | 3267 addAnimationValue(values[i], cssValuePool().createImplicitInitialVal
ue()); |
3252 | 3268 |
3253 addProperty(animationProperties.properties()[i], values[i].release(), im
portant); | 3269 addProperty(animationProperties.properties()[i], values[i].release(), im
portant); |
3254 } | 3270 } |
3255 | 3271 |
3256 return true; | 3272 return true; |
3257 } | 3273 } |
3258 | 3274 |
3259 bool CSSParser::parseTransitionShorthand(bool important) | 3275 bool CSSParser::parseTransitionShorthand(CSSPropertyID propId, bool important) |
3260 { | 3276 { |
3261 const unsigned numProperties = 4; | 3277 const unsigned numProperties = 4; |
3262 ASSERT(numProperties == webkitTransitionShorthand().length()); | 3278 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); |
| 3279 ASSERT(numProperties == shorthand.length()); |
3263 | 3280 |
3264 ShorthandScope scope(this, CSSPropertyWebkitTransition); | 3281 ShorthandScope scope(this, propId); |
3265 | 3282 |
3266 bool parsedProperty[numProperties] = { false }; | 3283 bool parsedProperty[numProperties] = { false }; |
3267 RefPtr<CSSValue> values[numProperties]; | 3284 RefPtr<CSSValue> values[numProperties]; |
3268 | 3285 |
3269 unsigned i; | 3286 unsigned i; |
3270 while (m_valueList->current()) { | 3287 while (m_valueList->current()) { |
3271 CSSParserValue* val = m_valueList->current(); | 3288 CSSParserValue* val = m_valueList->current(); |
3272 if (val->unit == CSSParserValue::Operator && val->iValue == ',') { | 3289 if (val->unit == CSSParserValue::Operator && val->iValue == ',') { |
3273 // We hit the end. Fill in all remaining values with the initial val
ue. | 3290 // We hit the end. Fill in all remaining values with the initial val
ue. |
3274 m_valueList->next(); | 3291 m_valueList->next(); |
3275 for (i = 0; i < numProperties; ++i) { | 3292 for (i = 0; i < numProperties; ++i) { |
3276 if (!parsedProperty[i]) | 3293 if (!parsedProperty[i]) |
3277 addAnimationValue(values[i], cssValuePool().createImplicitIn
itialValue()); | 3294 addAnimationValue(values[i], cssValuePool().createImplicitIn
itialValue()); |
3278 parsedProperty[i] = false; | 3295 parsedProperty[i] = false; |
3279 } | 3296 } |
3280 if (!m_valueList->current()) | 3297 if (!m_valueList->current()) |
3281 break; | 3298 break; |
3282 } | 3299 } |
3283 | 3300 |
3284 bool found = false; | 3301 bool found = false; |
3285 for (i = 0; !found && i < numProperties; ++i) { | 3302 for (i = 0; !found && i < numProperties; ++i) { |
3286 if (!parsedProperty[i]) { | 3303 if (!parsedProperty[i]) { |
3287 RefPtr<CSSValue> val; | 3304 RefPtr<CSSValue> val; |
3288 if (parseAnimationProperty(webkitTransitionShorthand().propertie
s()[i], val)) { | 3305 if (parseAnimationProperty(shorthand.properties()[i], val)) { |
3289 parsedProperty[i] = found = true; | 3306 parsedProperty[i] = found = true; |
3290 addAnimationValue(values[i], val.release()); | 3307 addAnimationValue(values[i], val.release()); |
3291 } | 3308 } |
3292 } | 3309 } |
3293 } | 3310 } |
3294 | 3311 |
3295 // if we didn't find at least one match, this is an | 3312 // if we didn't find at least one match, this is an |
3296 // invalid shorthand and we have to ignore it | 3313 // invalid shorthand and we have to ignore it |
3297 if (!found) | 3314 if (!found) |
3298 return false; | 3315 return false; |
3299 } | 3316 } |
3300 | 3317 |
3301 // Fill in any remaining properties with the initial value. | 3318 // Fill in any remaining properties with the initial value. |
3302 for (i = 0; i < numProperties; ++i) { | 3319 for (i = 0; i < numProperties; ++i) { |
3303 if (!parsedProperty[i]) | 3320 if (!parsedProperty[i]) |
3304 addAnimationValue(values[i], cssValuePool().createImplicitInitialVal
ue()); | 3321 addAnimationValue(values[i], cssValuePool().createImplicitInitialVal
ue()); |
3305 } | 3322 } |
3306 | 3323 |
3307 // Now add all of the properties we found. | 3324 // Now add all of the properties we found. |
3308 for (i = 0; i < numProperties; i++) | 3325 for (i = 0; i < numProperties; i++) |
3309 addProperty(webkitTransitionShorthand().properties()[i], values[i].relea
se(), important); | 3326 addPropertyWithPrefixingVariant(shorthand.properties()[i], values[i].rel
ease(), important); |
3310 | 3327 |
3311 return true; | 3328 return true; |
3312 } | 3329 } |
3313 | 3330 |
3314 bool CSSParser::parseShorthand(CSSPropertyID propId, const StylePropertyShorthan
d& shorthand, bool important) | 3331 bool CSSParser::parseShorthand(CSSPropertyID propId, const StylePropertyShorthan
d& shorthand, bool important) |
3315 { | 3332 { |
3316 // We try to match as many properties as possible | 3333 // We try to match as many properties as possible |
3317 // We set up an array of booleans to mark which property has been found, | 3334 // We set up an array of booleans to mark which property has been found, |
3318 // and we try to search for properties until it makes no longer any sense. | 3335 // and we try to search for properties until it makes no longer any sense. |
3319 ShorthandScope scope(this, propId); | 3336 ShorthandScope scope(this, propId); |
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4474 RefPtr<CSSValue> currValue; | 4491 RefPtr<CSSValue> currValue; |
4475 if (allowComma) { | 4492 if (allowComma) { |
4476 if (!isComma(val)) | 4493 if (!isComma(val)) |
4477 return false; | 4494 return false; |
4478 m_valueList->next(); | 4495 m_valueList->next(); |
4479 allowComma = false; | 4496 allowComma = false; |
4480 } | 4497 } |
4481 else { | 4498 else { |
4482 switch (propId) { | 4499 switch (propId) { |
4483 case CSSPropertyWebkitAnimationDelay: | 4500 case CSSPropertyWebkitAnimationDelay: |
| 4501 case CSSPropertyTransitionDelay: |
4484 case CSSPropertyWebkitTransitionDelay: | 4502 case CSSPropertyWebkitTransitionDelay: |
4485 currValue = parseAnimationDelay(); | 4503 currValue = parseAnimationDelay(); |
4486 if (currValue) | 4504 if (currValue) |
4487 m_valueList->next(); | 4505 m_valueList->next(); |
4488 break; | 4506 break; |
4489 case CSSPropertyWebkitAnimationDirection: | 4507 case CSSPropertyWebkitAnimationDirection: |
4490 currValue = parseAnimationDirection(); | 4508 currValue = parseAnimationDirection(); |
4491 if (currValue) | 4509 if (currValue) |
4492 m_valueList->next(); | 4510 m_valueList->next(); |
4493 break; | 4511 break; |
4494 case CSSPropertyWebkitAnimationDuration: | 4512 case CSSPropertyWebkitAnimationDuration: |
| 4513 case CSSPropertyTransitionDuration: |
4495 case CSSPropertyWebkitTransitionDuration: | 4514 case CSSPropertyWebkitTransitionDuration: |
4496 currValue = parseAnimationDuration(); | 4515 currValue = parseAnimationDuration(); |
4497 if (currValue) | 4516 if (currValue) |
4498 m_valueList->next(); | 4517 m_valueList->next(); |
4499 break; | 4518 break; |
4500 case CSSPropertyWebkitAnimationFillMode: | 4519 case CSSPropertyWebkitAnimationFillMode: |
4501 currValue = parseAnimationFillMode(); | 4520 currValue = parseAnimationFillMode(); |
4502 if (currValue) | 4521 if (currValue) |
4503 m_valueList->next(); | 4522 m_valueList->next(); |
4504 break; | 4523 break; |
4505 case CSSPropertyWebkitAnimationIterationCount: | 4524 case CSSPropertyWebkitAnimationIterationCount: |
4506 currValue = parseAnimationIterationCount(); | 4525 currValue = parseAnimationIterationCount(); |
4507 if (currValue) | 4526 if (currValue) |
4508 m_valueList->next(); | 4527 m_valueList->next(); |
4509 break; | 4528 break; |
4510 case CSSPropertyWebkitAnimationName: | 4529 case CSSPropertyWebkitAnimationName: |
4511 currValue = parseAnimationName(); | 4530 currValue = parseAnimationName(); |
4512 if (currValue) | 4531 if (currValue) |
4513 m_valueList->next(); | 4532 m_valueList->next(); |
4514 break; | 4533 break; |
4515 case CSSPropertyWebkitAnimationPlayState: | 4534 case CSSPropertyWebkitAnimationPlayState: |
4516 currValue = parseAnimationPlayState(); | 4535 currValue = parseAnimationPlayState(); |
4517 if (currValue) | 4536 if (currValue) |
4518 m_valueList->next(); | 4537 m_valueList->next(); |
4519 break; | 4538 break; |
| 4539 case CSSPropertyTransitionProperty: |
4520 case CSSPropertyWebkitTransitionProperty: | 4540 case CSSPropertyWebkitTransitionProperty: |
4521 if (allowAnimationProperty) | 4541 if (allowAnimationProperty) |
4522 currValue = parseAnimationProperty(allowAnimationPropert
y); | 4542 currValue = parseAnimationProperty(allowAnimationPropert
y); |
4523 if (value && !allowAnimationProperty) | 4543 if (value && !allowAnimationProperty) |
4524 return false; | 4544 return false; |
4525 if (currValue) | 4545 if (currValue) |
4526 m_valueList->next(); | 4546 m_valueList->next(); |
4527 break; | 4547 break; |
4528 case CSSPropertyWebkitAnimationTimingFunction: | 4548 case CSSPropertyWebkitAnimationTimingFunction: |
| 4549 case CSSPropertyTransitionTimingFunction: |
4529 case CSSPropertyWebkitTransitionTimingFunction: | 4550 case CSSPropertyWebkitTransitionTimingFunction: |
4530 currValue = parseAnimationTimingFunction(); | 4551 currValue = parseAnimationTimingFunction(); |
4531 if (currValue) | 4552 if (currValue) |
4532 m_valueList->next(); | 4553 m_valueList->next(); |
4533 break; | 4554 break; |
4534 default: | 4555 default: |
4535 ASSERT_NOT_REACHED(); | 4556 ASSERT_NOT_REACHED(); |
4536 return false; | 4557 return false; |
4537 } | 4558 } |
4538 | 4559 |
(...skipping 7248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11787 { | 11808 { |
11788 // The tokenizer checks for the construct of an+b. | 11809 // The tokenizer checks for the construct of an+b. |
11789 // However, since the {ident} rule precedes the {nth} rule, some of those | 11810 // However, since the {ident} rule precedes the {nth} rule, some of those |
11790 // tokens are identified as string literal. Furthermore we need to accept | 11811 // tokens are identified as string literal. Furthermore we need to accept |
11791 // "odd" and "even" which does not match to an+b. | 11812 // "odd" and "even" which does not match to an+b. |
11792 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 11813 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
11793 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 11814 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
11794 } | 11815 } |
11795 | 11816 |
11796 } | 11817 } |
OLD | NEW |