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.
5 #ifndef StringKeyframe_h
6 #define StringKeyframe_h
8 #include "core/animation/Keyframe.h"
9 #include "core/css/StylePropertySet.h"
13 class StyleSheetContents;
15 class StringKeyframe : public Keyframe {
17 static PassRefPtrWillBeRawPtr<StringKeyframe> create()
19 return adoptRefWillBeNoop(new StringKeyframe);
21 void setPropertyValue(CSSPropertyID, const String& value, StyleSheetContents*);
22 void clearPropertyValue(CSSPropertyID property) { m_propertySet->removeProperty(property); }
23 CSSValue* propertyValue(CSSPropertyID property) const
25 int index = m_propertySet->findPropertyIndex(property);
26 RELEASE_ASSERT(index >= 0);
27 return m_propertySet->propertyAt(static_cast<unsigned>(index)).value();
29 virtual PropertySet properties() const OVERRIDE;
31 virtual void trace(Visitor*) OVERRIDE;
33 class PropertySpecificKeyframe : public Keyframe::PropertySpecificKeyframe {
35 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue*, AnimationEffect::CompositeOperation);
37 CSSValue* value() const { return m_value.get(); }
38 virtual const PassRefPtrWillBeRawPtr<AnimatableValue> getAnimatableValue() const OVERRIDE FINAL {
39 return m_animatableValueCache.get();
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;
45 virtual void trace(Visitor*) OVERRIDE;
48 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue*);
50 virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> cloneWithOffset(double offset) const;
51 virtual bool isStringPropertySpecificKeyframe() const OVERRIDE { return true; }
53 RefPtrWillBeMember<CSSValue> m_value;
54 mutable RefPtrWillBeMember<AnimatableValue> m_animatableValueCache;
59 : m_propertySet(MutableStylePropertySet::create())
62 StringKeyframe(const StringKeyframe& copyFrom);
64 virtual PassRefPtrWillBeRawPtr<Keyframe> clone() const OVERRIDE;
65 virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> createPropertySpecificKeyframe(CSSPropertyID) const OVERRIDE;
67 virtual bool isStringKeyframe() const OVERRIDE { return true; }
69 RefPtrWillBeMember<MutableStylePropertySet> m_propertySet;
72 typedef StringKeyframe::PropertySpecificKeyframe StringPropertySpecificKeyframe;
74 DEFINE_TYPE_CASTS(StringKeyframe, Keyframe, value, value->isStringKeyframe(), value.isStringKeyframe());
75 DEFINE_TYPE_CASTS(StringPropertySpecificKeyframe, Keyframe::PropertySpecificKeyframe, value, value->isStringPropertySpecificKeyframe(), value.isStringPropertySpecificKeyframe());