Chromium Code Reviews| 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 11261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11272 } | 11272 } |
| 11273 ++i; | 11273 ++i; |
| 11274 } | 11274 } |
| 11275 } | 11275 } |
| 11276 | 11276 |
| 11277 StyleKeyframe* CSSParser::createKeyframe(CSSParserValueList* keys) | 11277 StyleKeyframe* CSSParser::createKeyframe(CSSParserValueList* keys) |
| 11278 { | 11278 { |
| 11279 // Create a key string from the passed keys | 11279 // Create a key string from the passed keys |
| 11280 StringBuilder keyString; | 11280 StringBuilder keyString; |
| 11281 for (unsigned i = 0; i < keys->size(); ++i) { | 11281 for (unsigned i = 0; i < keys->size(); ++i) { |
| 11282 // Just as per the comment below, we ignore keyframes with | |
| 11283 // invalid key values (plain numbers or unknown identifiers) | |
| 11284 // marked as CSSPrimitiveValue::CSS_UNKNOWN during parsing. | |
| 11285 if (keys->valueAt(i)->unit == CSSPrimitiveValue::CSS_UNKNOWN) { | |
| 11286 clearProperties(); | |
| 11287 return 0; | |
| 11288 } | |
| 11289 | |
| 11290 ASSERT(keys->valueAt(i)->unit == CSSPrimitiveValue::CSS_NUMBER); | |
| 11282 float key = static_cast<float>(keys->valueAt(i)->fValue); | 11291 float key = static_cast<float>(keys->valueAt(i)->fValue); |
| 11292 if (key < 0 || key > 100) { | |
| 11293 // As per http://www.w3.org/TR/css3-animations/#keyframes, | |
| 11294 // "If a keyframe selector specifies negative percentage values | |
| 11295 // or values higher than 100%, then the keyframe will be ignored." | |
| 11296 clearProperties(); | |
| 11297 return 0; | |
| 11298 } | |
|
Mike Lawther (Google)
2013/04/17 22:26:37
Nice catch! I can't see where these cases are test
apavlov
2013/04/18 04:33:49
Argh, indeed...I added this check after I had writ
| |
| 11283 if (i != 0) | 11299 if (i != 0) |
| 11284 keyString.append(','); | 11300 keyString.append(','); |
| 11285 keyString.append(String::number(key)); | 11301 keyString.append(String::number(key)); |
| 11286 keyString.append('%'); | 11302 keyString.append('%'); |
| 11287 } | 11303 } |
| 11288 | 11304 |
| 11289 RefPtr<StyleKeyframe> keyframe = StyleKeyframe::create(); | 11305 RefPtr<StyleKeyframe> keyframe = StyleKeyframe::create(); |
| 11290 keyframe->setKeyText(keyString.toString()); | 11306 keyframe->setKeyText(keyString.toString()); |
| 11291 keyframe->setProperties(createStylePropertySet()); | 11307 keyframe->setProperties(createStylePropertySet()); |
| 11292 | 11308 |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11716 { | 11732 { |
| 11717 // The tokenizer checks for the construct of an+b. | 11733 // The tokenizer checks for the construct of an+b. |
| 11718 // However, since the {ident} rule precedes the {nth} rule, some of those | 11734 // However, since the {ident} rule precedes the {nth} rule, some of those |
| 11719 // tokens are identified as string literal. Furthermore we need to accept | 11735 // tokens are identified as string literal. Furthermore we need to accept |
| 11720 // "odd" and "even" which does not match to an+b. | 11736 // "odd" and "even" which does not match to an+b. |
| 11721 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 11737 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
| 11722 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 11738 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
| 11723 } | 11739 } |
| 11724 | 11740 |
| 11725 } | 11741 } |
| OLD | NEW |