diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-07 11:21:11 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-07 11:21:11 +0200 |
commit | 2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 (patch) | |
tree | 988e8c5b116dd0466244ae2fe5af8ee9be926d76 /Source/WebCore/css/WebKitCSSKeyframeRule.cpp | |
parent | dd91e772430dc294e3bf478c119ef8d43c0a3358 (diff) | |
download | qtwebkit-2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47.tar.gz |
Imported WebKit commit 7e538425aa020340619e927792f3d895061fb54b (http://svn.webkit.org/repository/webkit/trunk@116286)
Diffstat (limited to 'Source/WebCore/css/WebKitCSSKeyframeRule.cpp')
-rw-r--r-- | Source/WebCore/css/WebKitCSSKeyframeRule.cpp | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/Source/WebCore/css/WebKitCSSKeyframeRule.cpp b/Source/WebCore/css/WebKitCSSKeyframeRule.cpp index 59f650ff0..7692086d0 100644 --- a/Source/WebCore/css/WebKitCSSKeyframeRule.cpp +++ b/Source/WebCore/css/WebKitCSSKeyframeRule.cpp @@ -26,39 +26,19 @@ #include "config.h" #include "WebKitCSSKeyframeRule.h" +#include "PropertySetCSSStyleDeclaration.h" #include "StylePropertySet.h" +#include "WebKitCSSKeyframesRule.h" namespace WebCore { - -WebKitCSSKeyframeRule::WebKitCSSKeyframeRule(CSSStyleSheet* parent) - : CSSRule(parent, CSSRule::WEBKIT_KEYFRAME_RULE) -{ -} - -WebKitCSSKeyframeRule::~WebKitCSSKeyframeRule() -{ - if (m_style) - m_style->clearParentRule(this); -} - -String WebKitCSSKeyframeRule::cssText() const -{ - String result = m_key; - - result += " { "; - result += m_style->asText(); - result += "}"; - - return result; -} - -void WebKitCSSKeyframeRule::setDeclaration(PassRefPtr<StylePropertySet> style) + +void StyleKeyframe::setProperties(PassRefPtr<StylePropertySet> properties) { - m_style = style; + m_properties = properties; } /* static */ -void WebKitCSSKeyframeRule::parseKeyString(const String& s, Vector<float>& keys) +void StyleKeyframe::parseKeyString(const String& s, Vector<float>& keys) { keys.clear(); Vector<String> strings; @@ -67,18 +47,17 @@ void WebKitCSSKeyframeRule::parseKeyString(const String& s, Vector<float>& keys) 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("%")) { + 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; @@ -88,4 +67,35 @@ void WebKitCSSKeyframeRule::parseKeyString(const String& s, Vector<float>& keys) } } +String StyleKeyframe::cssText() const +{ + String result = keyText(); + + result += " { "; + result += m_properties->asText(); + result += "}"; + + return result; +} + +WebKitCSSKeyframeRule::WebKitCSSKeyframeRule(StyleKeyframe* keyframe, WebKitCSSKeyframesRule* parent) + : CSSRule(0, CSSRule::WEBKIT_KEYFRAME_RULE) + , m_keyframe(keyframe) +{ + setParentRule(parent); +} + +WebKitCSSKeyframeRule::~WebKitCSSKeyframeRule() +{ + if (m_propertiesCSSOMWrapper) + m_propertiesCSSOMWrapper->clearParentRule(); +} + +CSSStyleDeclaration* WebKitCSSKeyframeRule::style() const +{ + if (!m_propertiesCSSOMWrapper) + m_propertiesCSSOMWrapper = StyleRuleCSSStyleDeclaration::create(m_keyframe->properties(), const_cast<WebKitCSSKeyframeRule*>(this)); + return m_propertiesCSSOMWrapper.get(); +} + } // namespace WebCore |