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.
8 #include "core/CSSPropertyNames.h"
9 #include "core/animation/AnimationEffect.h"
10 #include "core/animation/AnimationNode.h"
11 #include "core/animation/animatable/AnimatableValue.h"
15 using PropertySet
= HashSet
<CSSPropertyID
>;
19 // FIXME: Make Keyframe immutable
20 class Keyframe
: public RefCountedWillBeGarbageCollectedFinalized
<Keyframe
> {
22 virtual ~Keyframe() { }
24 void setOffset(double offset
) { m_offset
= offset
; }
25 double offset() const { return m_offset
; }
27 void setComposite(AnimationEffect::CompositeOperation composite
) { m_composite
= composite
; }
28 AnimationEffect::CompositeOperation
composite() const { return m_composite
; }
30 void setEasing(PassRefPtr
<TimingFunction
> easing
) { m_easing
= easing
; }
31 TimingFunction
& easing() const { return *m_easing
; }
33 static bool compareOffsets(const RefPtrWillBeMember
<Keyframe
>& a
, const RefPtrWillBeMember
<Keyframe
>& b
)
35 return a
->offset() < b
->offset();
38 virtual PropertySet
properties() const = 0;
40 virtual PassRefPtrWillBeRawPtr
<Keyframe
> clone() const = 0;
41 PassRefPtrWillBeRawPtr
<Keyframe
> cloneWithOffset(double offset
) const
43 RefPtrWillBeRawPtr
<Keyframe
> theClone
= clone();
44 theClone
->setOffset(offset
);
45 return theClone
.release();
48 virtual bool isAnimatableValueKeyframe() const { return false; }
49 virtual bool isStringKeyframe() const { return false; }
51 DEFINE_INLINE_VIRTUAL_TRACE() { }
53 class PropertySpecificKeyframe
: public NoBaseWillBeGarbageCollectedFinalized
<PropertySpecificKeyframe
> {
55 virtual ~PropertySpecificKeyframe() { }
56 double offset() const { return m_offset
; }
57 TimingFunction
& easing() const { return *m_easing
; }
58 AnimationEffect::CompositeOperation
composite() const { return m_composite
; }
59 virtual PassOwnPtrWillBeRawPtr
<PropertySpecificKeyframe
> cloneWithOffset(double offset
) const = 0;
61 virtual const PassRefPtrWillBeRawPtr
<AnimatableValue
> getAnimatableValue() const = 0;
63 virtual bool isAnimatableValuePropertySpecificKeyframe() const { return false; }
64 virtual bool isStringPropertySpecificKeyframe() const { return false; }
66 virtual PassOwnPtrWillBeRawPtr
<PropertySpecificKeyframe
> neutralKeyframe(double offset
, PassRefPtr
<TimingFunction
> easing
) const = 0;
67 virtual PassRefPtrWillBeRawPtr
<Interpolation
> maybeCreateInterpolation(CSSPropertyID
, blink::Keyframe::PropertySpecificKeyframe
& end
, Element
*) const = 0;
69 DEFINE_INLINE_VIRTUAL_TRACE() { }
72 PropertySpecificKeyframe(double offset
, PassRefPtr
<TimingFunction
> easing
, AnimationEffect::CompositeOperation
);
75 RefPtr
<TimingFunction
> m_easing
;
76 AnimationEffect::CompositeOperation m_composite
;
79 virtual PassOwnPtrWillBeRawPtr
<PropertySpecificKeyframe
> createPropertySpecificKeyframe(CSSPropertyID
) const = 0;
83 : m_offset(nullValue())
84 , m_composite(AnimationEffect::CompositeReplace
)
85 , m_easing(LinearTimingFunction::shared())
88 Keyframe(double offset
, AnimationEffect::CompositeOperation composite
, PassRefPtr
<TimingFunction
> easing
)
90 , m_composite(composite
)
96 AnimationEffect::CompositeOperation m_composite
;
97 RefPtr
<TimingFunction
> m_easing
;