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..64d0ec80deb1d5589a4f55459c936f43bc1d9fcc 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)); |
|
apavlov
2013/06/18 09:59:50
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) |
|
apavlov
2013/06/18 09:59:50
Vector's copy ctor performs TypeOperations::uninit
|
| { |
| - keys.clear(); |
| + Vector<float> keys; |
| Vector<String> strings; |
| s.split(',', strings); |
| @@ -71,15 +103,18 @@ 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 keys; |
| + } |
| } |
| - if (key < 0) { |
| - keys.clear(); |
| - return; |
| - } |
| + |
| keys.append(key); |
| } |
| + |
| + return keys; |
| } |
| String StyleKeyframe::cssText() const |
| @@ -99,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"); |
| } |
| CSSKeyframeRule::CSSKeyframeRule(StyleKeyframe* keyframe, CSSKeyframesRule* parent) |