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

Unified Diff: Source/core/css/WebKitCSSKeyframeRule.cpp

Issue 13943004: Avoid reparsing keyframe selectors (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/WebKitCSSKeyframeRule.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/WebKitCSSKeyframeRule.cpp
diff --git a/Source/core/css/WebKitCSSKeyframeRule.cpp b/Source/core/css/WebKitCSSKeyframeRule.cpp
index f58474fe84d9fd34a2ad60262adeb93d1dddbe5b..f1860451a1b8f245f216ca2b6202e52a58b85257 100644
--- a/Source/core/css/WebKitCSSKeyframeRule.cpp
+++ b/Source/core/css/WebKitCSSKeyframeRule.cpp
@@ -53,10 +53,42 @@ void StyleKeyframe::setProperties(PassRefPtr<StylePropertySet> properties)
m_properties = properties;
}
+String StyleKeyframe::keyText() const
+{
+ size_t keyCount = m_keys.size();
+ if (m_keyText.isEmpty() && keyCount > 0) {
+ StringBuilder keyString;
+ for (size_t i = 0; i < keyCount; ++i) {
+ float key = m_keys[i];
+ if (i)
+ keyString.append(',');
+ keyString.append(String::number(key*100));
apavlov 2013/04/22 13:30:23 Whitespace around '*'
+ keyString.append('%');
+ }
+ m_keyText = keyString.toString();
+ }
+ return m_keyText;
+}
+
+void StyleKeyframe::setKeyText(const String& s)
+{
+ m_keys = parseKeyString(m_keyText);
+ if (m_keys.size())
+ m_keyText = s;
+ else
+ m_keyText = String();
+}
+
+void StyleKeyframe::setKeys(const Vector<float>& keys)
+{
+ m_keyText = String();
+ m_keys = keys;
+}
+
/* static */
-void StyleKeyframe::parseKeyString(const String& s, Vector<float>& keys)
+Vector<float> StyleKeyframe::parseKeyString(const String& s)
{
- keys.clear();
+ Vector<float> keys;
Vector<String> strings;
s.split(',', strings);
@@ -73,14 +105,16 @@ void StyleKeyframe::parseKeyString(const String& s, Vector<float>& keys)
float k = cur.substring(0, cur.length() - 1).toFloat();
if (k >= 0 && k <= 100)
key = k/100;
+ else {
+ keys.clear();
+ return keys;
+ }
}
- if (key < 0) {
- keys.clear();
- return;
- }
- else
- keys.append(key);
+
+ keys.append(key);
}
+
+ return keys;
}
String StyleKeyframe::cssText() const
@@ -100,7 +134,7 @@ void StyleKeyframe::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
info.addMember(m_properties, "properties");
- info.addMember(m_key, "key");
+ info.addMember(m_keyText, "keyText");
}
WebKitCSSKeyframeRule::WebKitCSSKeyframeRule(StyleKeyframe* keyframe, WebKitCSSKeyframesRule* parent)
« no previous file with comments | « Source/core/css/WebKitCSSKeyframeRule.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698