Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / animation / animatable / AnimatableValueKeyframe.cpp
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/animation/animatable/AnimatableValueKeyframe.h"
7
8 #include "core/animation/LegacyStyleInterpolation.h"
9
10 namespace blink {
11
12 AnimatableValueKeyframe::AnimatableValueKeyframe(const AnimatableValueKeyframe& copyFrom)
13     : Keyframe(copyFrom.m_offset, copyFrom.m_composite, copyFrom.m_easing)
14 {
15     for (PropertyValueMap::const_iterator iter = copyFrom.m_propertyValues.begin(); iter != copyFrom.m_propertyValues.end(); ++iter)
16         setPropertyValue(iter->key, iter->value.get());
17 }
18
19 PropertySet AnimatableValueKeyframe::properties() const
20 {
21     // This is not used in time-critical code, so we probably don't need to
22     // worry about caching this result.
23     PropertySet properties;
24     for (PropertyValueMap::const_iterator iter = m_propertyValues.begin(); iter != m_propertyValues.end(); ++iter)
25         properties.add(*iter.keys());
26     return properties;
27 }
28
29 PassRefPtrWillBeRawPtr<Keyframe> AnimatableValueKeyframe::clone() const
30 {
31     return adoptRefWillBeNoop(new AnimatableValueKeyframe(*this));
32 }
33
34 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> AnimatableValueKeyframe::createPropertySpecificKeyframe(CSSPropertyID property) const
35 {
36     return adoptPtrWillBeNoop(new PropertySpecificKeyframe(offset(), &easing(), propertyValue(property), composite()));
37 }
38
39 void AnimatableValueKeyframe::trace(Visitor* visitor)
40 {
41 #if ENABLE(OILPAN)
42     visitor->trace(m_propertyValues);
43 #endif
44     Keyframe::trace(visitor);
45 }
46
47 AnimatableValueKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, const AnimatableValue* value, AnimationEffect::CompositeOperation op)
48     : Keyframe::PropertySpecificKeyframe(offset, easing, op)
49     , m_value(const_cast<AnimatableValue*>(value))
50 { }
51
52 AnimatableValueKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, PassRefPtrWillBeRawPtr<AnimatableValue> value)
53     : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect::CompositeReplace)
54     , m_value(value)
55 {
56     ASSERT(!isNull(m_offset));
57 }
58
59 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> AnimatableValueKeyframe::PropertySpecificKeyframe::cloneWithOffset(double offset) const
60 {
61     Keyframe::PropertySpecificKeyframe* theClone = new PropertySpecificKeyframe(offset, m_easing, m_value);
62     return adoptPtrWillBeNoop(theClone);
63 }
64
65 PassRefPtrWillBeRawPtr<Interpolation> AnimatableValueKeyframe::PropertySpecificKeyframe::createInterpolation(CSSPropertyID property, Keyframe::PropertySpecificKeyframe* end, Element*) const
66 {
67     AnimatableValuePropertySpecificKeyframe* to = toAnimatableValuePropertySpecificKeyframe(end);
68     return LegacyStyleInterpolation::create(value(), to->value(), property);
69 }
70
71 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> AnimatableValueKeyframe::PropertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const
72 {
73     return adoptPtrWillBeNoop(new AnimatableValueKeyframe::PropertySpecificKeyframe(offset, easing, AnimatableValue::neutralValue(), AnimationEffect::CompositeAdd));
74 }
75
76 void AnimatableValueKeyframe::PropertySpecificKeyframe::trace(Visitor* visitor)
77 {
78     visitor->trace(m_value);
79     Keyframe::PropertySpecificKeyframe::trace(visitor);
80 }
81
82 }