blob: e6baa0c0c76c64f57094e0f734d66148e3559324 [file] [log] [blame]
dino@apple.coma001d322008-08-05 23:01:41 +00001/*
akling@apple.comc713db32012-11-22 03:45:40 +00002 * Copyright (C) 2007, 2008, 2012 Apple Inc. All rights reserved.
dino@apple.coma001d322008-08-05 23:01:41 +00003 *
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.orgf684aec2011-10-19 13:31:03 +000023 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dino@apple.coma001d322008-08-05 23:01:41 +000024 */
25
26#ifndef WebKitCSSKeyframesRule_h
27#define WebKitCSSKeyframesRule_h
28
29#include "CSSRule.h"
antti@apple.comd09a7922012-04-02 19:50:34 +000030#include "StyleRule.h"
barraclough@apple.comd218c2d2010-08-10 00:38:14 +000031#include <wtf/Forward.h>
barraclough@apple.combbb3cd42010-08-10 17:45:41 +000032#include <wtf/text/AtomicString.h>
dino@apple.coma001d322008-08-05 23:01:41 +000033
34namespace WebCore {
35
36class CSSRuleList;
antti@apple.com64288372012-03-29 10:17:19 +000037class StyleKeyframe;
dino@apple.coma001d322008-08-05 23:01:41 +000038class WebKitCSSKeyframeRule;
dino@apple.coma001d322008-08-05 23:01:41 +000039
antti@apple.comd09a7922012-04-02 19:50:34 +000040class StyleRuleKeyframes : public StyleRuleBase {
41public:
akling@apple.com8c487df2013-10-20 10:49:10 +000042 static PassRef<StyleRuleKeyframes> create() { return adoptRef(*new StyleRuleKeyframes()); }
antti@apple.comd09a7922012-04-02 19:50:34 +000043
44 ~StyleRuleKeyframes();
45
andersca@apple.comc3523f82013-10-18 23:41:24 +000046 const Vector<RefPtr<StyleKeyframe>>& keyframes() const { return m_keyframes; }
antti@apple.comd09a7922012-04-02 19:50:34 +000047
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.com8c487df2013-10-20 10:49:10 +000057 PassRef<StyleRuleKeyframes> copy() const { return adoptRef(*new StyleRuleKeyframes(*this)); }
antti@apple.comca0770b2012-04-24 21:56:48 +000058
antti@apple.comd09a7922012-04-02 19:50:34 +000059private:
60 StyleRuleKeyframes();
antti@apple.comca0770b2012-04-24 21:56:48 +000061 StyleRuleKeyframes(const StyleRuleKeyframes&);
62
andersca@apple.comc3523f82013-10-18 23:41:24 +000063 Vector<RefPtr<StyleKeyframe>> m_keyframes;
antti@apple.comd09a7922012-04-02 19:50:34 +000064 AtomicString m_name;
65};
dino@apple.coma001d322008-08-05 23:01:41 +000066
67class WebKitCSSKeyframesRule : public CSSRule {
68public:
antti@apple.comd09a7922012-04-02 19:50:34 +000069 static PassRefPtr<WebKitCSSKeyframesRule> create(StyleRuleKeyframes* rule, CSSStyleSheet* sheet) { return adoptRef(new WebKitCSSKeyframesRule(rule, sheet)); }
dino@apple.coma001d322008-08-05 23:01:41 +000070
akling@apple.comc713db32012-11-22 03:45:40 +000071 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.coma001d322008-08-05 23:01:41 +000076
antti@apple.comd09a7922012-04-02 19:50:34 +000077 String name() const { return m_keyframesRule->name(); }
simon.fraser@apple.coma2a27b52008-10-22 19:35:52 +000078 void setName(const String&);
apavlov@chromium.orgf684aec2011-10-19 13:31:03 +000079
antti@apple.comaeb5fd92012-03-25 20:58:17 +000080 CSSRuleList* cssRules();
dino@apple.coma001d322008-08-05 23:01:41 +000081
82 void insertRule(const String& rule);
83 void deleteRule(const String& key);
84 WebKitCSSKeyframeRule* findRule(const String& key);
85
antti@apple.com64288372012-03-29 10:17:19 +000086 // For IndexedGetter and CSSRuleList.
antti@apple.comd09a7922012-04-02 19:50:34 +000087 unsigned length() const;
antti@apple.com64288372012-03-29 10:17:19 +000088 WebKitCSSKeyframeRule* item(unsigned index) const;
dino@apple.coma001d322008-08-05 23:01:41 +000089
90private:
antti@apple.comd09a7922012-04-02 19:50:34 +000091 WebKitCSSKeyframesRule(StyleRuleKeyframes*, CSSStyleSheet* parent);
dino@apple.coma001d322008-08-05 23:01:41 +000092
antti@apple.comd09a7922012-04-02 19:50:34 +000093 RefPtr<StyleRuleKeyframes> m_keyframesRule;
andersca@apple.comc3523f82013-10-18 23:41:24 +000094 mutable Vector<RefPtr<WebKitCSSKeyframeRule>> m_childRuleCSSOMWrappers;
antti@apple.com64288372012-03-29 10:17:19 +000095 mutable OwnPtr<CSSRuleList> m_ruleListCSSOMWrapper;
dino@apple.coma001d322008-08-05 23:01:41 +000096};
97
98} // namespace WebCore
99
100#endif // WebKitCSSKeyframesRule_h