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

Unified Diff: Source/core/css/CSSKeyframeRule.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/CSSKeyframeRule.h ('k') | Source/core/css/CSSParser.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSKeyframeRule.cpp
diff --git a/Source/core/css/CSSKeyframeRule.cpp b/Source/core/css/CSSKeyframeRule.cpp
index 12f8ec3596c63d7ff5d27ffefc0a57dea8db4f4f..103f6d65d99e99f466b58d130c0f8712d54efd0b 100644
--- a/Source/core/css/CSSKeyframeRule.cpp
+++ b/Source/core/css/CSSKeyframeRule.cpp
@@ -53,6 +53,39 @@ 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));
+ keyString.append('%');
+ }
+ m_keyText = keyString.toString();
+ }
+ return m_keyText;
+}
+
+void StyleKeyframe::setKeyText(const String& s)
+{
+ parseKeyString(s, m_keys);
+
+ 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)
{
@@ -71,13 +104,14 @@ void StyleKeyframe::parseKeyString(const String& s, Vector<float>& keys)
key = 1;
else if (cur.endsWith('%')) {
float k = cur.substring(0, cur.length() - 1).toFloat();
- if (k >= 0 && k <= 100)
+ if (k >= 0 && k <= 100) {
key = k / 100;
+ } else {
+ keys.clear();
+ return;
+ }
}
- if (key < 0) {
- keys.clear();
- return;
- }
+
keys.append(key);
}
}
@@ -99,7 +133,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");
}
CSSKeyframeRule::CSSKeyframeRule(StyleKeyframe* keyframe, CSSKeyframesRule* parent)
« no previous file with comments | « Source/core/css/CSSKeyframeRule.h ('k') | Source/core/css/CSSParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698