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

Unified 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: Rebased to master Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/css/CSSParser.cpp
diff --git a/Source/core/css/CSSParser.cpp b/Source/core/css/CSSParser.cpp
index db234f0e895b73a5d06b67835c85481205114562..e6ead7d3ac52e5b1b9276277f88c0b32d9cb0af7 100644
--- a/Source/core/css/CSSParser.cpp
+++ b/Source/core/css/CSSParser.cpp
@@ -11350,9 +11350,17 @@ void CSSParser::deleteFontFaceOnlyValues()
StyleKeyframe* CSSParser::createKeyframe(CSSParserValueList* keys)
{
- // Create a key string from the passed keys
- StringBuilder keyString;
- for (unsigned i = 0; i < keys->size(); ++i) {
+ Vector<float> keyframeKeys;
+ unsigned keyCount = keys->size();
+ for (unsigned i = 0; i < keyCount; ++i) {
apavlov 2013/06/18 09:59:50 IIRC, Vector::size() returns a size_t, so while we
+ // Just as per the comment below, we ignore keyframes with
+ // invalid key values (plain numbers or unknown identifiers)
+ // marked as CSSPrimitiveValue::CSS_UNKNOWN during parsing.
+ if (keys->valueAt(i)->unit == CSSPrimitiveValue::CSS_UNKNOWN) {
+ clearProperties();
+ return 0;
+ }
+
ASSERT(keys->valueAt(i)->unit == CSSPrimitiveValue::CSS_NUMBER);
float key = static_cast<float>(keys->valueAt(i)->fValue);
if (key < 0 || key > 100) {
@@ -11362,14 +11370,12 @@ StyleKeyframe* CSSParser::createKeyframe(CSSParserValueList* keys)
clearProperties();
return 0;
}
- if (i != 0)
- keyString.append(',');
- keyString.append(String::number(key));
- keyString.append('%');
+
+ keyframeKeys.append(key / 100);
}
RefPtr<StyleKeyframe> keyframe = StyleKeyframe::create();
- keyframe->setKeyText(keyString.toString());
+ keyframe->setKeys(keyframeKeys);
keyframe->setProperties(createStylePropertySet());
clearProperties();

Powered by Google App Engine
This is Rietveld 408576698