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

Side by Side Diff: Source/core/css/CSSParser-in.cpp

Issue 22925002: Add support to resolve unprefixed CSS animations properties. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 months 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 | Annotate | Revision Log
OLDNEW
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 2384 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 RefPtr<CSSValue> val2; 2395 RefPtr<CSSValue> val2;
2396 CSSPropertyID propId1, propId2; 2396 CSSPropertyID propId1, propId2;
2397 if (parsePerspectiveOrigin(propId, propId1, propId2, val1, val2)) { 2397 if (parsePerspectiveOrigin(propId, propId1, propId2, val1, val2)) {
2398 addProperty(propId1, val1.release(), important); 2398 addProperty(propId1, val1.release(), important);
2399 if (val2) 2399 if (val2)
2400 addProperty(propId2, val2.release(), important); 2400 addProperty(propId2, val2.release(), important);
2401 return true; 2401 return true;
2402 } 2402 }
2403 return false; 2403 return false;
2404 } 2404 }
2405 case CSSPropertyAnimationDelay:
2406 case CSSPropertyAnimationDirection:
2407 case CSSPropertyAnimationDuration:
2408 case CSSPropertyAnimationFillMode:
2409 case CSSPropertyAnimationName:
2410 case CSSPropertyAnimationPlayState:
2411 case CSSPropertyAnimationIterationCount:
2412 case CSSPropertyAnimationTimingFunction:
2413 if (!RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled())
2414 break;
2405 case CSSPropertyWebkitAnimationDelay: 2415 case CSSPropertyWebkitAnimationDelay:
2406 case CSSPropertyWebkitAnimationDirection: 2416 case CSSPropertyWebkitAnimationDirection:
2407 case CSSPropertyWebkitAnimationDuration: 2417 case CSSPropertyWebkitAnimationDuration:
2408 case CSSPropertyWebkitAnimationFillMode: 2418 case CSSPropertyWebkitAnimationFillMode:
2409 case CSSPropertyWebkitAnimationName: 2419 case CSSPropertyWebkitAnimationName:
2410 case CSSPropertyWebkitAnimationPlayState: 2420 case CSSPropertyWebkitAnimationPlayState:
2411 case CSSPropertyWebkitAnimationIterationCount: 2421 case CSSPropertyWebkitAnimationIterationCount:
2412 case CSSPropertyWebkitAnimationTimingFunction: 2422 case CSSPropertyWebkitAnimationTimingFunction:
2413 case CSSPropertyTransitionDelay: 2423 case CSSPropertyTransitionDelay:
2414 case CSSPropertyTransitionDuration: 2424 case CSSPropertyTransitionDuration:
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
2586 return parseFillShorthand(propId, properties, WTF_ARRAY_LENGTH(propertie s), important); 2596 return parseFillShorthand(propId, properties, WTF_ARRAY_LENGTH(propertie s), important);
2587 } 2597 }
2588 case CSSPropertyWebkitMask: { 2598 case CSSPropertyWebkitMask: {
2589 const CSSPropertyID properties[] = { CSSPropertyWebkitMaskImage, CSSProp ertyWebkitMaskRepeat, 2599 const CSSPropertyID properties[] = { CSSPropertyWebkitMaskImage, CSSProp ertyWebkitMaskRepeat,
2590 CSSPropertyWebkitMaskPosition, CSSPropertyWebkitMaskOrigin, CSSPrope rtyWebkitMaskClip, CSSPropertyWebkitMaskSize }; 2600 CSSPropertyWebkitMaskPosition, CSSPropertyWebkitMaskOrigin, CSSPrope rtyWebkitMaskClip, CSSPropertyWebkitMaskSize };
2591 return parseFillShorthand(propId, properties, WTF_ARRAY_LENGTH(propertie s), important); 2601 return parseFillShorthand(propId, properties, WTF_ARRAY_LENGTH(propertie s), important);
2592 } 2602 }
2593 case CSSPropertyBorder: 2603 case CSSPropertyBorder:
2594 // [ 'border-width' || 'border-style' || <color> ] | inherit 2604 // [ 'border-width' || 'border-style' || <color> ] | inherit
2595 { 2605 {
2596 if (parseShorthand(propId, borderShorthandForParsing(), important)) { 2606 if (parseShorthand(propId, parsingShorthandForProperty(CSSPropertyBorder ), important)) {
2597 // The CSS3 Borders and Backgrounds specification says that border a lso resets border-image. It's as 2607 // The CSS3 Borders and Backgrounds specification says that border a lso resets border-image. It's as
2598 // though a value of none was specified for the image. 2608 // though a value of none was specified for the image.
2599 addExpandedPropertyForValue(CSSPropertyBorderImage, cssValuePool().c reateImplicitInitialValue(), important); 2609 addExpandedPropertyForValue(CSSPropertyBorderImage, cssValuePool().c reateImplicitInitialValue(), important);
2600 return true; 2610 return true;
2601 } 2611 }
2602 return false; 2612 return false;
2603 } 2613 }
2604 case CSSPropertyBorderTop: 2614 case CSSPropertyBorderTop:
2605 // [ 'border-top-width' || 'border-style' || <color> ] | inherit 2615 // [ 'border-top-width' || 'border-style' || <color> ] | inherit
2606 return parseShorthand(propId, borderTopShorthand(), important); 2616 return parseShorthand(propId, borderTopShorthand(), important);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2650 return parseFont(important); 2660 return parseFont(important);
2651 break; 2661 break;
2652 case CSSPropertyListStyle: 2662 case CSSPropertyListStyle:
2653 return parseShorthand(propId, listStyleShorthand(), important); 2663 return parseShorthand(propId, listStyleShorthand(), important);
2654 case CSSPropertyWebkitColumns: 2664 case CSSPropertyWebkitColumns:
2655 return parseColumnsShorthand(important); 2665 return parseColumnsShorthand(important);
2656 case CSSPropertyWebkitColumnRule: 2666 case CSSPropertyWebkitColumnRule:
2657 return parseShorthand(propId, webkitColumnRuleShorthand(), important); 2667 return parseShorthand(propId, webkitColumnRuleShorthand(), important);
2658 case CSSPropertyWebkitTextStroke: 2668 case CSSPropertyWebkitTextStroke:
2659 return parseShorthand(propId, webkitTextStrokeShorthand(), important); 2669 return parseShorthand(propId, webkitTextStrokeShorthand(), important);
2670 case CSSPropertyAnimation:
2671 if (!RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled())
2672 break;
2660 case CSSPropertyWebkitAnimation: 2673 case CSSPropertyWebkitAnimation:
2661 return parseAnimationShorthand(important); 2674 return parseAnimationShorthand(propId, important);
2662 case CSSPropertyTransition: 2675 case CSSPropertyTransition:
2663 case CSSPropertyWebkitTransition: 2676 case CSSPropertyWebkitTransition:
2664 return parseTransitionShorthand(propId, important); 2677 return parseTransitionShorthand(propId, important);
2665 case CSSPropertyInvalid: 2678 case CSSPropertyInvalid:
2666 return false; 2679 return false;
2667 case CSSPropertyPage: 2680 case CSSPropertyPage:
2668 return parsePage(propId, important); 2681 return parsePage(propId, important);
2669 case CSSPropertyFontStretch: 2682 case CSSPropertyFontStretch:
2670 return false; 2683 return false;
2671 // CSS Text Layout Module Level 3: Vertical writing support 2684 // CSS Text Layout Module Level 3: Vertical writing support
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
3066 PassRefPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ; 3079 PassRefPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ;
3067 list->append(oldVal); 3080 list->append(oldVal);
3068 list->append(rval); 3081 list->append(rval);
3069 lval = list; 3082 lval = list;
3070 } 3083 }
3071 } 3084 }
3072 else 3085 else
3073 lval = rval; 3086 lval = rval;
3074 } 3087 }
3075 3088
3076 bool CSSParser::parseAnimationShorthand(bool important) 3089 bool CSSParser::parseAnimationShorthand(CSSPropertyID propId, bool important)
3077 { 3090 {
3078 const StylePropertyShorthand& animationProperties = webkitAnimationShorthand ForParsing(); 3091 const StylePropertyShorthand& animationProperties = parsingShorthandForPrope rty(propId);
3079 const unsigned numProperties = 7; 3092 const unsigned numProperties = 7;
3080 3093
3081 // The list of properties in the shorthand should be the same 3094 // The list of properties in the shorthand should be the same
3082 // length as the list with animation name in last position, even though they are 3095 // length as the list with animation name in last position, even though they are
3083 // in a different order. 3096 // in a different order.
3084 ASSERT(numProperties == webkitAnimationShorthandForParsing().length()); 3097 ASSERT(numProperties == animationProperties.length());
3085 ASSERT(numProperties == webkitAnimationShorthand().length()); 3098 ASSERT(numProperties == shorthandForProperty(propId).length());
3086 3099
3087 ShorthandScope scope(this, CSSPropertyWebkitAnimation); 3100 ShorthandScope scope(this, propId);
3088 3101
3089 bool parsedProperty[numProperties] = { false }; 3102 bool parsedProperty[numProperties] = { false };
3090 AnimationParseContext context; 3103 AnimationParseContext context;
3091 RefPtr<CSSValue> values[numProperties]; 3104 RefPtr<CSSValue> values[numProperties];
3092 3105
3093 unsigned i; 3106 unsigned i;
3094 while (m_valueList->current()) { 3107 while (m_valueList->current()) {
3095 CSSParserValue* val = m_valueList->current(); 3108 CSSParserValue* val = m_valueList->current();
3096 if (val->unit == CSSParserValue::Operator && val->iValue == ',') { 3109 if (val->unit == CSSParserValue::Operator && val->iValue == ',') {
3097 // We hit the end. Fill in all remaining values with the initial va lue. 3110 // We hit the end. Fill in all remaining values with the initial va lue.
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after
4443 while ((val = m_valueList->current())) { 4456 while ((val = m_valueList->current())) {
4444 RefPtr<CSSValue> currValue; 4457 RefPtr<CSSValue> currValue;
4445 if (allowComma) { 4458 if (allowComma) {
4446 if (!isComma(val)) 4459 if (!isComma(val))
4447 return false; 4460 return false;
4448 m_valueList->next(); 4461 m_valueList->next();
4449 allowComma = false; 4462 allowComma = false;
4450 } 4463 }
4451 else { 4464 else {
4452 switch (propId) { 4465 switch (propId) {
4466 case CSSPropertyAnimationDelay:
4453 case CSSPropertyWebkitAnimationDelay: 4467 case CSSPropertyWebkitAnimationDelay:
4454 case CSSPropertyTransitionDelay: 4468 case CSSPropertyTransitionDelay:
4455 case CSSPropertyWebkitTransitionDelay: 4469 case CSSPropertyWebkitTransitionDelay:
4456 currValue = parseAnimationDelay(); 4470 currValue = parseAnimationDelay();
4457 if (currValue) 4471 if (currValue)
4458 m_valueList->next(); 4472 m_valueList->next();
4459 break; 4473 break;
4474 case CSSPropertyAnimationDirection:
4460 case CSSPropertyWebkitAnimationDirection: 4475 case CSSPropertyWebkitAnimationDirection:
4461 currValue = parseAnimationDirection(); 4476 currValue = parseAnimationDirection();
4462 if (currValue) 4477 if (currValue)
4463 m_valueList->next(); 4478 m_valueList->next();
4464 break; 4479 break;
4480 case CSSPropertyAnimationDuration:
4465 case CSSPropertyWebkitAnimationDuration: 4481 case CSSPropertyWebkitAnimationDuration:
4466 case CSSPropertyTransitionDuration: 4482 case CSSPropertyTransitionDuration:
4467 case CSSPropertyWebkitTransitionDuration: 4483 case CSSPropertyWebkitTransitionDuration:
4468 currValue = parseAnimationDuration(); 4484 currValue = parseAnimationDuration();
4469 if (currValue) 4485 if (currValue)
4470 m_valueList->next(); 4486 m_valueList->next();
4471 break; 4487 break;
4488 case CSSPropertyAnimationFillMode:
eseidel 2013/08/13 17:49:15 Are the expected implementations of these really i
darktears 2013/08/13 18:08:54 The parsing should be the same. And the tests adde
4472 case CSSPropertyWebkitAnimationFillMode: 4489 case CSSPropertyWebkitAnimationFillMode:
4473 currValue = parseAnimationFillMode(); 4490 currValue = parseAnimationFillMode();
4474 if (currValue) 4491 if (currValue)
4475 m_valueList->next(); 4492 m_valueList->next();
4476 break; 4493 break;
4494 case CSSPropertyAnimationIterationCount:
4477 case CSSPropertyWebkitAnimationIterationCount: 4495 case CSSPropertyWebkitAnimationIterationCount:
4478 currValue = parseAnimationIterationCount(); 4496 currValue = parseAnimationIterationCount();
4479 if (currValue) 4497 if (currValue)
4480 m_valueList->next(); 4498 m_valueList->next();
4481 break; 4499 break;
4500 case CSSPropertyAnimationName:
4482 case CSSPropertyWebkitAnimationName: 4501 case CSSPropertyWebkitAnimationName:
4483 currValue = parseAnimationName(); 4502 currValue = parseAnimationName();
4484 if (currValue) 4503 if (currValue)
4485 m_valueList->next(); 4504 m_valueList->next();
4486 break; 4505 break;
4506 case CSSPropertyAnimationPlayState:
4487 case CSSPropertyWebkitAnimationPlayState: 4507 case CSSPropertyWebkitAnimationPlayState:
4488 currValue = parseAnimationPlayState(); 4508 currValue = parseAnimationPlayState();
4489 if (currValue) 4509 if (currValue)
4490 m_valueList->next(); 4510 m_valueList->next();
4491 break; 4511 break;
4492 case CSSPropertyTransitionProperty: 4512 case CSSPropertyTransitionProperty:
4493 case CSSPropertyWebkitTransitionProperty: 4513 case CSSPropertyWebkitTransitionProperty:
4494 currValue = parseAnimationProperty(context); 4514 currValue = parseAnimationProperty(context);
4495 if (value && !context.animationPropertyKeywordAllowed()) 4515 if (value && !context.animationPropertyKeywordAllowed())
4496 return false; 4516 return false;
4497 if (currValue) 4517 if (currValue)
4498 m_valueList->next(); 4518 m_valueList->next();
4499 break; 4519 break;
4520 case CSSPropertyAnimationTimingFunction:
4500 case CSSPropertyWebkitAnimationTimingFunction: 4521 case CSSPropertyWebkitAnimationTimingFunction:
4501 case CSSPropertyTransitionTimingFunction: 4522 case CSSPropertyTransitionTimingFunction:
4502 case CSSPropertyWebkitTransitionTimingFunction: 4523 case CSSPropertyWebkitTransitionTimingFunction:
4503 currValue = parseAnimationTimingFunction(); 4524 currValue = parseAnimationTimingFunction();
4504 if (currValue) 4525 if (currValue)
4505 m_valueList->next(); 4526 m_valueList->next();
4506 break; 4527 break;
4507 default: 4528 default:
4508 ASSERT_NOT_REACHED(); 4529 ASSERT_NOT_REACHED();
4509 return false; 4530 return false;
(...skipping 5688 matching lines...) Expand 10 before | Expand all | Expand 10 after
10198 inline void CSSParser::detectAtToken(int length, bool hasEscape) 10219 inline void CSSParser::detectAtToken(int length, bool hasEscape)
10199 { 10220 {
10200 CharacterType* name = tokenStart<CharacterType>(); 10221 CharacterType* name = tokenStart<CharacterType>();
10201 ASSERT(name[0] == '@' && length >= 2); 10222 ASSERT(name[0] == '@' && length >= 2);
10202 10223
10203 // Ignore leading @. 10224 // Ignore leading @.
10204 ++name; 10225 ++name;
10205 --length; 10226 --length;
10206 10227
10207 // charset, font-face, import, media, namespace, page, supports, 10228 // charset, font-face, import, media, namespace, page, supports,
10208 // -webkit-keyframes, and -webkit-mediaquery are not affected by hasEscape. 10229 // -webkit-keyframes, keyframes, and -webkit-mediaquery are not affected by hasEscape.
10209 SWITCH(name, length) { 10230 SWITCH(name, length) {
10210 CASE("bottom-left") { 10231 CASE("bottom-left") {
10211 if (LIKELY(!hasEscape)) 10232 if (LIKELY(!hasEscape))
10212 m_token = BOTTOMLEFT_SYM; 10233 m_token = BOTTOMLEFT_SYM;
10213 } 10234 }
10214 CASE("bottom-right") { 10235 CASE("bottom-right") {
10215 if (LIKELY(!hasEscape)) 10236 if (LIKELY(!hasEscape))
10216 m_token = BOTTOMRIGHT_SYM; 10237 m_token = BOTTOMRIGHT_SYM;
10217 } 10238 }
10218 CASE("bottom-center") { 10239 CASE("bottom-center") {
(...skipping 15 matching lines...) Expand all
10234 CASE("font-face") { 10255 CASE("font-face") {
10235 m_token = FONT_FACE_SYM; 10256 m_token = FONT_FACE_SYM;
10236 } 10257 }
10237 CASE("host") { 10258 CASE("host") {
10238 m_token = HOST_SYM; 10259 m_token = HOST_SYM;
10239 } 10260 }
10240 CASE("import") { 10261 CASE("import") {
10241 m_parsingMode = MediaQueryMode; 10262 m_parsingMode = MediaQueryMode;
10242 m_token = IMPORT_SYM; 10263 m_token = IMPORT_SYM;
10243 } 10264 }
10265 CASE("keyframes") {
10266 m_token = WEBKIT_KEYFRAMES_SYM;
10267 }
10244 CASE("left-top") { 10268 CASE("left-top") {
10245 if (LIKELY(!hasEscape)) 10269 if (LIKELY(!hasEscape))
10246 m_token = LEFTTOP_SYM; 10270 m_token = LEFTTOP_SYM;
10247 } 10271 }
10248 CASE("left-middle") { 10272 CASE("left-middle") {
10249 if (LIKELY(!hasEscape)) 10273 if (LIKELY(!hasEscape))
10250 m_token = LEFTMIDDLE_SYM; 10274 m_token = LEFTMIDDLE_SYM;
10251 } 10275 }
10252 CASE("left-bottom") { 10276 CASE("left-bottom") {
10253 if (LIKELY(!hasEscape)) 10277 if (LIKELY(!hasEscape))
(...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after
11920 { 11944 {
11921 // The tokenizer checks for the construct of an+b. 11945 // The tokenizer checks for the construct of an+b.
11922 // However, since the {ident} rule precedes the {nth} rule, some of those 11946 // However, since the {ident} rule precedes the {nth} rule, some of those
11923 // tokens are identified as string literal. Furthermore we need to accept 11947 // tokens are identified as string literal. Furthermore we need to accept
11924 // "odd" and "even" which does not match to an+b. 11948 // "odd" and "even" which does not match to an+b.
11925 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 11949 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11926 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 11950 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11927 } 11951 }
11928 11952
11929 } 11953 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698