2 * Copyright (C) 2007, 2008, 2012 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef CSSKeyframesRule_h
27 #define CSSKeyframesRule_h
29 #include "core/css/CSSRule.h"
30 #include "core/css/StyleRule.h"
31 #include "wtf/Forward.h"
32 #include "wtf/text/AtomicString.h"
37 class CSSKeyframeRule
;
38 class StyleRuleKeyframe
;
40 class StyleRuleKeyframes final
: public StyleRuleBase
{
42 static PassRefPtrWillBeRawPtr
<StyleRuleKeyframes
> create() { return adoptRefWillBeNoop(new StyleRuleKeyframes()); }
44 ~StyleRuleKeyframes();
46 const WillBeHeapVector
<RefPtrWillBeMember
<StyleRuleKeyframe
>>& keyframes() const { return m_keyframes
; }
48 void parserAppendKeyframe(PassRefPtrWillBeRawPtr
<StyleRuleKeyframe
>);
49 void wrapperAppendKeyframe(PassRefPtrWillBeRawPtr
<StyleRuleKeyframe
>);
50 void wrapperRemoveKeyframe(unsigned);
52 String
name() const { return m_name
; }
53 void setName(const String
& name
) { m_name
= AtomicString(name
); }
55 bool isVendorPrefixed() const { return m_isPrefixed
; }
56 void setVendorPrefixed(bool isPrefixed
) { m_isPrefixed
= isPrefixed
; }
58 int findKeyframeIndex(const String
& key
) const;
60 PassRefPtrWillBeRawPtr
<StyleRuleKeyframes
> copy() const { return adoptRefWillBeNoop(new StyleRuleKeyframes(*this)); }
62 DECLARE_TRACE_AFTER_DISPATCH();
64 void styleChanged() { m_version
++; }
65 unsigned version() const { return m_version
; }
69 explicit StyleRuleKeyframes(const StyleRuleKeyframes
&);
71 WillBeHeapVector
<RefPtrWillBeMember
<StyleRuleKeyframe
>> m_keyframes
;
73 unsigned m_version
: 31;
74 unsigned m_isPrefixed
: 1;
77 DEFINE_STYLE_RULE_TYPE_CASTS(Keyframes
);
79 class CSSKeyframesRule final
: public CSSRule
{
80 DEFINE_WRAPPERTYPEINFO();
82 static PassRefPtrWillBeRawPtr
<CSSKeyframesRule
> create(StyleRuleKeyframes
* rule
, CSSStyleSheet
* sheet
)
84 return adoptRefWillBeNoop(new CSSKeyframesRule(rule
, sheet
));
87 ~CSSKeyframesRule() override
;
89 String
cssText() const override
;
90 void reattach(StyleRuleBase
*) override
;
92 String
name() const { return m_keyframesRule
->name(); }
93 void setName(const String
&);
95 CSSRuleList
* cssRules() const override
;
97 void appendRule(const String
& rule
);
98 void deleteRule(const String
& key
);
99 CSSKeyframeRule
* findRule(const String
& key
);
101 // For IndexedGetter and CSSRuleList.
102 unsigned length() const;
103 CSSKeyframeRule
* item(unsigned index
) const;
104 CSSKeyframeRule
* anonymousIndexedGetter(unsigned index
) const;
106 bool isVendorPrefixed() const { return m_isPrefixed
; }
107 void setVendorPrefixed(bool isPrefixed
) { m_isPrefixed
= isPrefixed
; }
109 void styleChanged() { m_keyframesRule
->styleChanged(); }
111 DECLARE_VIRTUAL_TRACE();
114 CSSKeyframesRule(StyleRuleKeyframes
*, CSSStyleSheet
* parent
);
116 CSSRule::Type
type() const override
{ return KEYFRAMES_RULE
; }
118 RefPtrWillBeMember
<StyleRuleKeyframes
> m_keyframesRule
;
119 mutable WillBeHeapVector
<RefPtrWillBeMember
<CSSKeyframeRule
>> m_childRuleCSSOMWrappers
;
120 mutable OwnPtrWillBeMember
<CSSRuleList
> m_ruleListCSSOMWrapper
;
124 DEFINE_CSS_RULE_TYPE_CASTS(CSSKeyframesRule
, KEYFRAMES_RULE
);
128 #endif // CSSKeyframesRule_h