Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / animation / StringKeyframe.h
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 #ifndef StringKeyframe_h
6 #define StringKeyframe_h
7
8 #include "core/animation/Keyframe.h"
9 #include "core/css/StylePropertySet.h"
10
11 namespace blink {
12
13 class StyleSheetContents;
14
15 class StringKeyframe : public Keyframe {
16 public:
17     static PassRefPtrWillBeRawPtr<StringKeyframe> create()
18     {
19         return adoptRefWillBeNoop(new StringKeyframe);
20     }
21     void setPropertyValue(CSSPropertyID, const String& value, StyleSheetContents*);
22     void clearPropertyValue(CSSPropertyID property) { m_propertySet->removeProperty(property); }
23     CSSValue* propertyValue(CSSPropertyID property) const
24     {
25         int index = m_propertySet->findPropertyIndex(property);
26         RELEASE_ASSERT(index >= 0);
27         return m_propertySet->propertyAt(static_cast<unsigned>(index)).value();
28     }
29     virtual PropertySet properties() const override;
30     RefPtrWillBeMember<MutableStylePropertySet> propertySetForInspector() const { return m_propertySet; }
31
32     virtual void trace(Visitor*) override;
33
34     class PropertySpecificKeyframe : public Keyframe::PropertySpecificKeyframe {
35     public:
36         PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue*, AnimationEffect::CompositeOperation);
37
38         CSSValue* value() const { return m_value.get(); }
39         virtual const PassRefPtrWillBeRawPtr<AnimatableValue> getAnimatableValue() const override final { return m_animatableValueCache.get(); }
40
41         virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const override final;
42         virtual PassRefPtrWillBeRawPtr<Interpolation> createInterpolation(CSSPropertyID, blink::Keyframe::PropertySpecificKeyframe* end, Element*) const override final;
43
44         virtual void trace(Visitor*) override;
45
46     private:
47         PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue*);
48
49         virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> cloneWithOffset(double offset) const;
50         virtual bool isStringPropertySpecificKeyframe() const override { return true; }
51
52         RefPtrWillBeMember<CSSValue> m_value;
53         mutable RefPtrWillBeMember<AnimatableValue> m_animatableValueCache;
54     };
55
56 private:
57     StringKeyframe()
58         : m_propertySet(MutableStylePropertySet::create())
59     { }
60
61     StringKeyframe(const StringKeyframe& copyFrom);
62
63     virtual PassRefPtrWillBeRawPtr<Keyframe> clone() const override;
64     virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> createPropertySpecificKeyframe(CSSPropertyID) const override;
65
66     virtual bool isStringKeyframe() const override { return true; }
67
68     RefPtrWillBeMember<MutableStylePropertySet> m_propertySet;
69 };
70
71 using StringPropertySpecificKeyframe = StringKeyframe::PropertySpecificKeyframe;
72
73 DEFINE_TYPE_CASTS(StringKeyframe, Keyframe, value, value->isStringKeyframe(), value.isStringKeyframe());
74 DEFINE_TYPE_CASTS(StringPropertySpecificKeyframe, Keyframe::PropertySpecificKeyframe, value, value->isStringPropertySpecificKeyframe(), value.isStringPropertySpecificKeyframe());
75
76 }
77
78 #endif