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

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

Issue 13943004: Avoid reparsing keyframe selectors (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 5 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
« no previous file with comments | « Source/core/css/CSSKeyframeRule.cpp ('k') | Source/core/css/resolver/StyleResolver.cpp » ('j') | 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 11415 matching lines...) Expand 10 before | Expand all | Expand 10 after
11426 if (property.id() == CSSPropertyFontVariant && property.value()->isValue List()) { 11426 if (property.id() == CSSPropertyFontVariant && property.value()->isValue List()) {
11427 m_parsedProperties.remove(i); 11427 m_parsedProperties.remove(i);
11428 continue; 11428 continue;
11429 } 11429 }
11430 ++i; 11430 ++i;
11431 } 11431 }
11432 } 11432 }
11433 11433
11434 StyleKeyframe* CSSParser::createKeyframe(CSSParserValueList* keys) 11434 StyleKeyframe* CSSParser::createKeyframe(CSSParserValueList* keys)
11435 { 11435 {
11436 // Create a key string from the passed keys 11436 Vector<float> keyframeKeys;
11437 StringBuilder keyString; 11437 size_t keyCount = keys->size();
11438 for (unsigned i = 0; i < keys->size(); ++i) { 11438 for (size_t i = 0; i < keyCount; ++i) {
11439 ASSERT(keys->valueAt(i)->unit == CSSPrimitiveValue::CSS_NUMBER); 11439 ASSERT(keys->valueAt(i)->unit == CSSPrimitiveValue::CSS_NUMBER);
11440 float key = static_cast<float>(keys->valueAt(i)->fValue); 11440 float key = static_cast<float>(keys->valueAt(i)->fValue);
11441 if (key < 0 || key > 100) { 11441 if (key < 0 || key > 100) {
11442 // As per http://www.w3.org/TR/css3-animations/#keyframes, 11442 // As per http://www.w3.org/TR/css3-animations/#keyframes,
11443 // "If a keyframe selector specifies negative percentage values 11443 // "If a keyframe selector specifies negative percentage values
11444 // or values higher than 100%, then the keyframe will be ignored." 11444 // or values higher than 100%, then the keyframe will be ignored."
11445 clearProperties(); 11445 clearProperties();
11446 return 0; 11446 return 0;
11447 } 11447 }
11448 if (i != 0) 11448
11449 keyString.append(','); 11449 keyframeKeys.append(key / 100);
11450 keyString.append(String::number(key));
11451 keyString.append('%');
11452 } 11450 }
11453 11451
11454 RefPtr<StyleKeyframe> keyframe = StyleKeyframe::create(); 11452 RefPtr<StyleKeyframe> keyframe = StyleKeyframe::create();
11455 keyframe->setKeyText(keyString.toString()); 11453 keyframe->setKeys(keyframeKeys);
11456 keyframe->setProperties(createStylePropertySet()); 11454 keyframe->setProperties(createStylePropertySet());
11457 11455
11458 clearProperties(); 11456 clearProperties();
11459 11457
11460 StyleKeyframe* keyframePtr = keyframe.get(); 11458 StyleKeyframe* keyframePtr = keyframe.get();
11461 m_parsedKeyframes.append(keyframe.release()); 11459 m_parsedKeyframes.append(keyframe.release());
11462 return keyframePtr; 11460 return keyframePtr;
11463 } 11461 }
11464 11462
11465 void CSSParser::invalidBlockHit() 11463 void CSSParser::invalidBlockHit()
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
11878 { 11876 {
11879 // The tokenizer checks for the construct of an+b. 11877 // The tokenizer checks for the construct of an+b.
11880 // However, since the {ident} rule precedes the {nth} rule, some of those 11878 // However, since the {ident} rule precedes the {nth} rule, some of those
11881 // tokens are identified as string literal. Furthermore we need to accept 11879 // tokens are identified as string literal. Furthermore we need to accept
11882 // "odd" and "even" which does not match to an+b. 11880 // "odd" and "even" which does not match to an+b.
11883 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 11881 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11884 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 11882 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11885 } 11883 }
11886 11884
11887 } 11885 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSKeyframeRule.cpp ('k') | Source/core/css/resolver/StyleResolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698