Chromium Code Reviews| Index: Source/core/css/CSSKeyframeRule.cpp |
| diff --git a/Source/core/css/CSSKeyframeRule.cpp b/Source/core/css/CSSKeyframeRule.cpp |
| index 12f8ec3596c63d7ff5d27ffefc0a57dea8db4f4f..a11ddea7ffc9e098918c3d1d213bfbe68b29a3e1 100644 |
| --- a/Source/core/css/CSSKeyframeRule.cpp |
| +++ b/Source/core/css/CSSKeyframeRule.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)); |
| + 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) |
| { |
| - keys.clear(); |
|
apavlov
2013/07/04 22:02:52
Hmm, just noticed. Why did this get removed? When
|
| Vector<String> strings; |
| s.split(',', strings); |
| @@ -71,13 +103,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 +132,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) |