Upstream version 8.37.180.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 WebCore {
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
31     virtual void trace(Visitor*) OVERRIDE;
32
33     class PropertySpecificKeyframe : public Keyframe::PropertySpecificKeyframe {
34     public:
35         PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue*, AnimationEffect::CompositeOperation);
36
37         CSSValue* value() const { return m_value.get(); }
38         virtual const PassRefPtrWillBeRawPtr<AnimatableValue> getAnimatableValue() const OVERRIDE FINAL {
39             return m_animatableValueCache.get();
40         }
41
42         virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const OVERRIDE FINAL;
43         virtual PassRefPtrWillBeRawPtr<Interpolation> createInterpolation(CSSPropertyID, WebCore::Keyframe::PropertySpecificKeyframe* end, Element*) const OVERRIDE FINAL;
44
45         virtual void trace(Visitor*) OVERRIDE;
46
47     private:
48         PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue*);
49
50         virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> cloneWithOffset(double offset) const;
51         virtual bool isStringPropertySpecificKeyframe() const OVERRIDE { return true; }
52
53         RefPtrWillBeMember<CSSValue> m_value;
54         mutable RefPtrWillBeMember<AnimatableValue> m_animatableValueCache;
55     };
56
57 private:
58     StringKeyframe()
59         : m_propertySet(MutableStylePropertySet::create())
60     { }
61
62     StringKeyframe(const StringKeyframe& copyFrom);
63
64     virtual PassRefPtrWillBeRawPtr<Keyframe> clone() const OVERRIDE;
65     virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> createPropertySpecificKeyframe(CSSPropertyID) const OVERRIDE;
66
67     virtual bool isStringKeyframe() const OVERRIDE { return true; }
68
69     RefPtrWillBeMember<MutableStylePropertySet> m_propertySet;
70 };
71
72 typedef StringKeyframe::PropertySpecificKeyframe StringPropertySpecificKeyframe;
73
74 DEFINE_TYPE_CASTS(StringKeyframe, Keyframe, value, value->isStringKeyframe(), value.isStringKeyframe());
75 DEFINE_TYPE_CASTS(StringPropertySpecificKeyframe, Keyframe::PropertySpecificKeyframe, value, value->isStringPropertySpecificKeyframe(), value.isStringPropertySpecificKeyframe());
76
77 }
78
79 #endif