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;
30 RefPtrWillBeMember<MutableStylePropertySet> propertySetForInspector() const { return m_propertySet; }
32 virtual void trace(Visitor*) override;
34 class PropertySpecificKeyframe : public Keyframe::PropertySpecificKeyframe {
36 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue*, AnimationEffect::CompositeOperation);
38 CSSValue* value() const { return m_value.get(); }
39 virtual const PassRefPtrWillBeRawPtr<AnimatableValue> getAnimatableValue() const override final { return m_animatableValueCache.get(); }
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;
44 virtual void trace(Visitor*) override;
47 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue*);
49 virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> cloneWithOffset(double offset) const;
50 virtual bool isStringPropertySpecificKeyframe() const override { return true; }
52 RefPtrWillBeMember<CSSValue> m_value;
53 mutable RefPtrWillBeMember<AnimatableValue> m_animatableValueCache;
58 : m_propertySet(MutableStylePropertySet::create())
61 StringKeyframe(const StringKeyframe& copyFrom);
63 virtual PassRefPtrWillBeRawPtr<Keyframe> clone() const override;
64 virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> createPropertySpecificKeyframe(CSSPropertyID) const override;
66 virtual bool isStringKeyframe() const override { return true; }
68 RefPtrWillBeMember<MutableStylePropertySet> m_propertySet;
71 using StringPropertySpecificKeyframe = StringKeyframe::PropertySpecificKeyframe;
73 DEFINE_TYPE_CASTS(StringKeyframe, Keyframe, value, value->isStringKeyframe(), value.isStringKeyframe());
74 DEFINE_TYPE_CASTS(StringPropertySpecificKeyframe, Keyframe::PropertySpecificKeyframe, value, value->isStringPropertySpecificKeyframe(), value.isStringPropertySpecificKeyframe());