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

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

Issue 13871007: Add CSS parser recovery from errors while parsing @-webkit-keyframes key values. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added tests for out-of-range percentage key values Created 7 years, 8 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
« no previous file with comments | « Source/core/css/CSSGrammar.y.in ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 11222 matching lines...) Expand 10 before | Expand all | Expand 10 after
11233 } 11233 }
11234 ++i; 11234 ++i;
11235 } 11235 }
11236 } 11236 }
11237 11237
11238 StyleKeyframe* CSSParser::createKeyframe(CSSParserValueList* keys) 11238 StyleKeyframe* CSSParser::createKeyframe(CSSParserValueList* keys)
11239 { 11239 {
11240 // Create a key string from the passed keys 11240 // Create a key string from the passed keys
11241 StringBuilder keyString; 11241 StringBuilder keyString;
11242 for (unsigned i = 0; i < keys->size(); ++i) { 11242 for (unsigned i = 0; i < keys->size(); ++i) {
11243 // Just as per the comment below, we ignore keyframes with
11244 // invalid key values (plain numbers or unknown identifiers)
11245 // marked as CSSPrimitiveValue::CSS_UNKNOWN during parsing.
11246 if (keys->valueAt(i)->unit == CSSPrimitiveValue::CSS_UNKNOWN) {
11247 clearProperties();
11248 return 0;
11249 }
11250
11251 ASSERT(keys->valueAt(i)->unit == CSSPrimitiveValue::CSS_NUMBER);
11243 float key = static_cast<float>(keys->valueAt(i)->fValue); 11252 float key = static_cast<float>(keys->valueAt(i)->fValue);
11253 if (key < 0 || key > 100) {
11254 // As per http://www.w3.org/TR/css3-animations/#keyframes,
11255 // "If a keyframe selector specifies negative percentage values
11256 // or values higher than 100%, then the keyframe will be ignored."
11257 clearProperties();
11258 return 0;
11259 }
11244 if (i != 0) 11260 if (i != 0)
11245 keyString.append(','); 11261 keyString.append(',');
11246 keyString.append(String::number(key)); 11262 keyString.append(String::number(key));
11247 keyString.append('%'); 11263 keyString.append('%');
11248 } 11264 }
11249 11265
11250 RefPtr<StyleKeyframe> keyframe = StyleKeyframe::create(); 11266 RefPtr<StyleKeyframe> keyframe = StyleKeyframe::create();
11251 keyframe->setKeyText(keyString.toString()); 11267 keyframe->setKeyText(keyString.toString());
11252 keyframe->setProperties(createStylePropertySet()); 11268 keyframe->setProperties(createStylePropertySet());
11253 11269
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
11677 { 11693 {
11678 // The tokenizer checks for the construct of an+b. 11694 // The tokenizer checks for the construct of an+b.
11679 // However, since the {ident} rule precedes the {nth} rule, some of those 11695 // However, since the {ident} rule precedes the {nth} rule, some of those
11680 // tokens are identified as string literal. Furthermore we need to accept 11696 // tokens are identified as string literal. Furthermore we need to accept
11681 // "odd" and "even" which does not match to an+b. 11697 // "odd" and "even" which does not match to an+b.
11682 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 11698 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11683 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 11699 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11684 } 11700 }
11685 11701
11686 } 11702 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSGrammar.y.in ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698