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 WebKitCSSKeyframesRule_h |
| 27 | #define WebKitCSSKeyframesRule_h |
| 28 | |
| 29 | #include "CSSRule.h" |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 30 | #include "StyleRule.h" |
barraclough@apple.com | d218c2d | 2010-08-10 00:38:14 +0000 | [diff] [blame] | 31 | #include <wtf/Forward.h> |
barraclough@apple.com | bbb3cd4 | 2010-08-10 17:45:41 +0000 | [diff] [blame] | 32 | #include <wtf/text/AtomicString.h> |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 33 | |
| 34 | namespace WebCore { |
| 35 | |
| 36 | class CSSRuleList; |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 37 | class StyleKeyframe; |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 38 | class WebKitCSSKeyframeRule; |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 39 | |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 40 | class StyleRuleKeyframes : public StyleRuleBase { |
| 41 | public: |
akling@apple.com | 8c487df | 2013-10-20 10:49:10 +0000 | [diff] [blame] | 42 | static PassRef<StyleRuleKeyframes> create() { return adoptRef(*new StyleRuleKeyframes()); } |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 43 | |
| 44 | ~StyleRuleKeyframes(); |
| 45 | |
andersca@apple.com | c3523f8 | 2013-10-18 23:41:24 +0000 | [diff] [blame] | 46 | const Vector<RefPtr<StyleKeyframe>>& keyframes() const { return m_keyframes; } |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 47 | |
| 48 | void parserAppendKeyframe(PassRefPtr<StyleKeyframe>); |
| 49 | void wrapperAppendKeyframe(PassRefPtr<StyleKeyframe>); |
| 50 | void wrapperRemoveKeyframe(unsigned); |
| 51 | |
| 52 | String name() const { return m_name; } |
| 53 | void setName(const String& name) { m_name = AtomicString(name); } |
| 54 | |
| 55 | int findKeyframeIndex(const String& key) const; |
| 56 | |
akling@apple.com | 8c487df | 2013-10-20 10:49:10 +0000 | [diff] [blame] | 57 | PassRef<StyleRuleKeyframes> copy() const { return adoptRef(*new StyleRuleKeyframes(*this)); } |
antti@apple.com | ca0770b | 2012-04-24 21:56:48 +0000 | [diff] [blame] | 58 | |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 59 | private: |
| 60 | StyleRuleKeyframes(); |
antti@apple.com | ca0770b | 2012-04-24 21:56:48 +0000 | [diff] [blame] | 61 | StyleRuleKeyframes(const StyleRuleKeyframes&); |
| 62 | |
andersca@apple.com | c3523f8 | 2013-10-18 23:41:24 +0000 | [diff] [blame] | 63 | Vector<RefPtr<StyleKeyframe>> m_keyframes; |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 64 | AtomicString m_name; |
| 65 | }; |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 66 | |
| 67 | class WebKitCSSKeyframesRule : public CSSRule { |
| 68 | public: |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 69 | static PassRefPtr<WebKitCSSKeyframesRule> create(StyleRuleKeyframes* rule, CSSStyleSheet* sheet) { return adoptRef(new WebKitCSSKeyframesRule(rule, sheet)); } |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 70 | |
akling@apple.com | c713db3 | 2012-11-22 03:45:40 +0000 | [diff] [blame] | 71 | virtual ~WebKitCSSKeyframesRule(); |
| 72 | |
| 73 | virtual CSSRule::Type type() const OVERRIDE { return WEBKIT_KEYFRAMES_RULE; } |
| 74 | virtual String cssText() const OVERRIDE; |
| 75 | virtual void reattach(StyleRuleBase*) OVERRIDE; |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 76 | |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 77 | String name() const { return m_keyframesRule->name(); } |
simon.fraser@apple.com | a2a27b5 | 2008-10-22 19:35:52 +0000 | [diff] [blame] | 78 | void setName(const String&); |
apavlov@chromium.org | f684aec | 2011-10-19 13:31:03 +0000 | [diff] [blame] | 79 | |
antti@apple.com | aeb5fd9 | 2012-03-25 20:58:17 +0000 | [diff] [blame] | 80 | CSSRuleList* cssRules(); |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 81 | |
| 82 | void insertRule(const String& rule); |
| 83 | void deleteRule(const String& key); |
| 84 | WebKitCSSKeyframeRule* findRule(const String& key); |
| 85 | |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 86 | // For IndexedGetter and CSSRuleList. |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 87 | unsigned length() const; |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 88 | WebKitCSSKeyframeRule* item(unsigned index) const; |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 89 | |
| 90 | private: |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 91 | WebKitCSSKeyframesRule(StyleRuleKeyframes*, CSSStyleSheet* parent); |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 92 | |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 93 | RefPtr<StyleRuleKeyframes> m_keyframesRule; |
andersca@apple.com | c3523f8 | 2013-10-18 23:41:24 +0000 | [diff] [blame] | 94 | mutable Vector<RefPtr<WebKitCSSKeyframeRule>> m_childRuleCSSOMWrappers; |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 95 | mutable OwnPtr<CSSRuleList> m_ruleListCSSOMWrapper; |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | } // namespace WebCore |
| 99 | |
| 100 | #endif // WebKitCSSKeyframesRule_h |