dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 1 | /* |
akling@apple.com | c713db3 | 2012-11-22 03:45:40 +0000 | [diff] [blame] | 2 | * Copyright (C) 2007, 2008, 2012 Apple Inc. All rights reserved. |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
apavlov@chromium.org | f684aec | 2011-10-19 13:31:03 +0000 | [diff] [blame] | 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 24 | */ |
| 25 | |
| 26 | #ifndef WebKitCSSKeyframeRule_h |
| 27 | #define WebKitCSSKeyframeRule_h |
| 28 | |
| 29 | #include "CSSRule.h" |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 30 | |
| 31 | namespace WebCore { |
| 32 | |
akling@apple.com | 179f7df | 2013-02-25 15:49:25 +0000 | [diff] [blame] | 33 | class CSSStyleDeclaration; |
akling@apple.com | b977e61 | 2013-04-14 15:19:59 +0000 | [diff] [blame] | 34 | class MutableStylePropertySet; |
akling@apple.com | 179f7df | 2013-02-25 15:49:25 +0000 | [diff] [blame] | 35 | class StylePropertySet; |
antti@apple.com | 745b790 | 2012-03-31 18:02:35 +0000 | [diff] [blame] | 36 | class StyleRuleCSSStyleDeclaration; |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 37 | class WebKitCSSKeyframesRule; |
| 38 | |
| 39 | class StyleKeyframe : public RefCounted<StyleKeyframe> { |
zoltan@webkit.org | 2eb7bec | 2012-09-14 09:12:48 +0000 | [diff] [blame] | 40 | WTF_MAKE_FAST_ALLOCATED; |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 41 | public: |
| 42 | static PassRefPtr<StyleKeyframe> create() |
| 43 | { |
| 44 | return adoptRef(new StyleKeyframe()); |
| 45 | } |
akling@apple.com | 179f7df | 2013-02-25 15:49:25 +0000 | [diff] [blame] | 46 | ~StyleKeyframe(); |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 47 | |
| 48 | String keyText() const { return m_key; } |
| 49 | void setKeyText(const String& s) { m_key = s; } |
| 50 | |
| 51 | void getKeys(Vector<float>& keys) const { parseKeyString(m_key, keys); } |
| 52 | |
commit-queue@webkit.org | 42eb4e1 | 2012-07-18 15:15:22 +0000 | [diff] [blame] | 53 | const StylePropertySet* properties() const { return m_properties.get(); } |
akling@apple.com | b977e61 | 2013-04-14 15:19:59 +0000 | [diff] [blame] | 54 | MutableStylePropertySet* mutableProperties(); |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 55 | void setProperties(PassRefPtr<StylePropertySet>); |
| 56 | |
| 57 | String cssText() const; |
| 58 | |
akling@apple.com | 179f7df | 2013-02-25 15:49:25 +0000 | [diff] [blame] | 59 | private: |
| 60 | StyleKeyframe(); |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 61 | |
| 62 | static void parseKeyString(const String&, Vector<float>& keys); |
| 63 | |
| 64 | RefPtr<StylePropertySet> m_properties; |
| 65 | // FIXME: This should be a parsed vector of floats. |
| 66 | // comma separated list of keys |
| 67 | String m_key; |
| 68 | }; |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 69 | |
| 70 | class WebKitCSSKeyframeRule : public CSSRule { |
| 71 | public: |
akling@apple.com | c713db3 | 2012-11-22 03:45:40 +0000 | [diff] [blame] | 72 | virtual ~WebKitCSSKeyframeRule(); |
| 73 | |
| 74 | virtual CSSRule::Type type() const OVERRIDE { return WEBKIT_KEYFRAME_RULE; } |
| 75 | virtual String cssText() const OVERRIDE { return m_keyframe->cssText(); } |
| 76 | virtual void reattach(StyleRuleBase*) OVERRIDE; |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 77 | |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 78 | String keyText() const { return m_keyframe->keyText(); } |
| 79 | void setKeyText(const String& s) { m_keyframe->setKeyText(s); } |
apavlov@chromium.org | f684aec | 2011-10-19 13:31:03 +0000 | [diff] [blame] | 80 | |
akling@apple.com | ca80984 | 2013-05-03 20:27:39 +0000 | [diff] [blame] | 81 | CSSStyleDeclaration* style(); |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 82 | |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 83 | private: |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 84 | WebKitCSSKeyframeRule(StyleKeyframe*, WebKitCSSKeyframesRule* parent); |
apavlov@chromium.org | f684aec | 2011-10-19 13:31:03 +0000 | [diff] [blame] | 85 | |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 86 | RefPtr<StyleKeyframe> m_keyframe; |
antti@apple.com | 745b790 | 2012-03-31 18:02:35 +0000 | [diff] [blame] | 87 | mutable RefPtr<StyleRuleCSSStyleDeclaration> m_propertiesCSSOMWrapper; |
| 88 | |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 89 | friend class WebKitCSSKeyframesRule; |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | } // namespace WebCore |
| 93 | |
| 94 | #endif // WebKitCSSKeyframeRule_h |