2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
23 #include "core/rendering/style/KeyframeList.h"
25 #include "core/animation/Animation.h"
26 #include "core/css/StylePropertySet.h"
27 #include "core/rendering/RenderObject.h"
31 void KeyframeValue::addProperties(const StylePropertySet* propertySet)
35 unsigned propertyCount = propertySet->propertyCount();
36 for (unsigned i = 0; i < propertyCount; ++i) {
37 CSSPropertyID property = propertySet->propertyAt(i).id();
38 // Timing-function within keyframes is special, because it is not animated; it just
39 // describes the timing function between this keyframe and the next.
40 if (property != CSSPropertyWebkitAnimationTimingFunction && property != CSSPropertyAnimationTimingFunction)
41 addProperty(property);
45 TimingFunction* KeyframeValue::timingFunction(const RenderStyle& keyframeStyle)
47 const CSSAnimationDataList* animations = keyframeStyle.animations();
48 ASSERT(animations && !animations->isEmpty());
49 return animations->animation(0)->timingFunction();
52 KeyframeList::~KeyframeList()
57 void KeyframeList::clear()
63 void KeyframeList::insert(const KeyframeValue& keyframe)
65 if (keyframe.key() < 0 || keyframe.key() > 1)
68 bool inserted = false;
69 bool replaced = false;
70 for (size_t i = 0; i < m_keyframes.size(); ++i) {
71 if (m_keyframes[i].key() == keyframe.key()) {
72 m_keyframes[i] = keyframe;
77 if (m_keyframes[i].key() > keyframe.key()) {
79 m_keyframes.insert(i, keyframe);
85 if (!replaced && !inserted)
86 m_keyframes.append(keyframe);
89 // We have to rebuild the properties list from scratch.
91 for (Vector<KeyframeValue>::const_iterator it = m_keyframes.begin(); it != m_keyframes.end(); ++it) {
92 const KeyframeValue& currKeyframe = *it;
93 for (HashSet<CSSPropertyID>::const_iterator it = currKeyframe.properties().begin(); it != currKeyframe.properties().end(); ++it)
94 m_properties.add(*it);
97 for (HashSet<CSSPropertyID>::const_iterator it = keyframe.properties().begin(); it != keyframe.properties().end(); ++it)
98 m_properties.add(*it);
102 } // namespace WebCore