• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3  *           (C) 2000 Antti Koivisto (koivisto@kde.org)
4  *           (C) 2000 Dirk Mueller (mueller@kde.org)
5  * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
6  * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB.  If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  */
24 
25 #ifndef KeyframeList_h
26 #define KeyframeList_h
27 
28 #include <wtf/Vector.h>
29 #include <wtf/HashSet.h>
30 #include <wtf/RefPtr.h>
31 #include <wtf/text/AtomicString.h>
32 
33 namespace WebCore {
34 
35 class RenderObject;
36 class RenderStyle;
37 
38 class KeyframeValue {
39 public:
KeyframeValue(float key,PassRefPtr<RenderStyle> style)40     KeyframeValue(float key, PassRefPtr<RenderStyle> style)
41         : m_key(key)
42         , m_style(style)
43     {
44     }
45 
addProperty(int prop)46     void addProperty(int prop) { m_properties.add(prop); }
containsProperty(int prop)47     bool containsProperty(int prop) const { return m_properties.contains(prop); }
properties()48     const HashSet<int>& properties() const { return m_properties; }
49 
key()50     float key() const { return m_key; }
setKey(float key)51     void setKey(float key) { m_key = key; }
52 
style()53     const RenderStyle* style() const { return m_style.get(); }
setStyle(PassRefPtr<RenderStyle> style)54     void setStyle(PassRefPtr<RenderStyle> style) { m_style = style; }
55 
56 private:
57     float m_key;
58     HashSet<int> m_properties; // The properties specified in this keyframe.
59     RefPtr<RenderStyle> m_style;
60 };
61 
62 class KeyframeList {
63 public:
KeyframeList(RenderObject * renderer,const AtomicString & animationName)64     KeyframeList(RenderObject* renderer, const AtomicString& animationName)
65         : m_animationName(animationName)
66         , m_renderer(renderer)
67     {
68         insert(KeyframeValue(0, 0));
69         insert(KeyframeValue(1, 0));
70     }
71     ~KeyframeList();
72 
73     bool operator==(const KeyframeList& o) const;
74     bool operator!=(const KeyframeList& o) const { return !(*this == o); }
75 
animationName()76     const AtomicString& animationName() const { return m_animationName; }
77 
78     void insert(const KeyframeValue& keyframe);
79 
addProperty(int prop)80     void addProperty(int prop) { m_properties.add(prop); }
containsProperty(int prop)81     bool containsProperty(int prop) const { return m_properties.contains(prop); }
beginProperties()82     HashSet<int>::const_iterator beginProperties() const { return m_properties.begin(); }
endProperties()83     HashSet<int>::const_iterator endProperties() const { return m_properties.end(); }
84 
85     void clear();
isEmpty()86     bool isEmpty() const { return m_keyframes.isEmpty(); }
size()87     size_t size() const { return m_keyframes.size(); }
88     const KeyframeValue& operator[](size_t index) const { return m_keyframes[index]; }
89 
90 private:
91     AtomicString m_animationName;
92     Vector<KeyframeValue> m_keyframes; // kept sorted by key
93     HashSet<int> m_properties; // the properties being animated
94     RenderObject* m_renderer;
95 };
96 
97 } // namespace WebCore
98 
99 #endif // KeyframeList_h
100