Index: Source/core/css/CSSKeyframeRule.cpp |
diff --git a/Source/core/css/CSSKeyframeRule.cpp b/Source/core/css/CSSKeyframeRule.cpp |
index 12f8ec3596c63d7ff5d27ffefc0a57dea8db4f4f..be7cb49437ec72b004a3f0205aa3f64f50dba709 100644 |
--- a/Source/core/css/CSSKeyframeRule.cpp |
+++ b/Source/core/css/CSSKeyframeRule.cpp |
@@ -27,8 +27,10 @@ |
#include "core/css/CSSKeyframeRule.h" |
#include "core/css/CSSKeyframesRule.h" |
+#include "core/css/CSSParser.h" |
#include "core/css/PropertySetCSSStyleDeclaration.h" |
#include "core/css/StylePropertySet.h" |
+#include "wtf/MemoryInstrumentationVector.h" |
#include "wtf/text/StringBuilder.h" |
namespace WebCore { |
@@ -41,6 +43,48 @@ StyleKeyframe::~StyleKeyframe() |
{ |
} |
+String StyleKeyframe::keyText() const |
+{ |
+ if (m_keyText.isNull()) { |
+ StringBuilder keyText; |
+ for (unsigned i = 0; i < m_keys->size(); ++i) { |
+ if (i) |
+ keyText.append(','); |
+ keyText.append(String::number(m_keys->at(i))); |
+ keyText.append('%'); |
+ } |
+ m_keyText = keyText.toString(); |
+ } |
+ return m_keyText; |
+} |
+ |
+void StyleKeyframe::setKeyText(const String& keyText) |
+{ |
+ // FIXME: Should we trim whitespace? |
+ // FIXME: Should we leave keyText unchanged when attempting to set to an |
+ // invalid string? |
+ m_keyText = keyText; |
+ m_keys.clear(); |
+} |
+ |
+const Vector<float>& StyleKeyframe::keys() const |
+{ |
+ if (!m_keys) { |
apavlov
2013/07/15 11:54:37
The braces are optional here
Steve Block
2013/08/14 00:44:05
No longer relevant
|
+ m_keys = CSSParser(CSSStrictMode).parseKeyframeKeyList(m_keyText); |
+ } |
+ // If an invalid key string was set, m_keys may be empty. |
+ ASSERT(m_keys); |
+ return *m_keys; |
+} |
+ |
+void StyleKeyframe::setKeys(PassOwnPtr<Vector<float> > keys) |
+{ |
+ ASSERT(keys && !keys->isEmpty()); |
+ m_keys = keys; |
+ m_keyText = String(); |
+ ASSERT(m_keyText.isNull()); |
+} |
+ |
MutableStylePropertySet* StyleKeyframe::mutableProperties() |
{ |
if (!m_properties->isMutable()) |
@@ -53,35 +97,6 @@ void StyleKeyframe::setProperties(PassRefPtr<StylePropertySet> properties) |
m_properties = properties; |
} |
-/* static */ |
-void StyleKeyframe::parseKeyString(const String& s, Vector<float>& keys) |
-{ |
- keys.clear(); |
- Vector<String> strings; |
- s.split(',', strings); |
- |
- for (size_t i = 0; i < strings.size(); ++i) { |
- float key = -1; |
- String cur = strings[i].stripWhiteSpace(); |
- |
- // For now the syntax MUST be 'xxx%' or 'from' or 'to', where xxx is a legal floating point number |
- if (cur == "from") |
- key = 0; |
- else if (cur == "to") |
- key = 1; |
- else if (cur.endsWith('%')) { |
- float k = cur.substring(0, cur.length() - 1).toFloat(); |
- if (k >= 0 && k <= 100) |
- key = k / 100; |
- } |
- if (key < 0) { |
- keys.clear(); |
- return; |
- } |
- keys.append(key); |
- } |
-} |
- |
String StyleKeyframe::cssText() const |
{ |
StringBuilder result; |
@@ -99,7 +114,8 @@ 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"); |
+ info.addMember(m_keys, "keys"); |
} |
CSSKeyframeRule::CSSKeyframeRule(StyleKeyframe* keyframe, CSSKeyframesRule* parent) |