Home | History | Annotate | Download | only in animation
      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 AnimatableValueKeyframe_h
      6 #define AnimatableValueKeyframe_h
      7 
      8 #include "core/animation/AnimatableValue.h"
      9 #include "core/animation/Keyframe.h"
     10 
     11 namespace WebCore {
     12 
     13 class AnimatableValueKeyframe : public Keyframe {
     14 public:
     15     static PassRefPtrWillBeRawPtr<AnimatableValueKeyframe> create()
     16     {
     17         return adoptRefWillBeNoop(new AnimatableValueKeyframe);
     18     }
     19     void setPropertyValue(CSSPropertyID property, PassRefPtrWillBeRawPtr<AnimatableValue> value)
     20     {
     21         m_propertyValues.add(property, value);
     22     }
     23     void clearPropertyValue(CSSPropertyID property) { m_propertyValues.remove(property); }
     24     AnimatableValue* propertyValue(CSSPropertyID property) const
     25     {
     26         ASSERT(m_propertyValues.contains(property));
     27         return m_propertyValues.get(property);
     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, const AnimatableValue*, AnimationEffect::CompositeOperation);
     36 
     37         AnimatableValue* value() const { return m_value.get(); }
     38         virtual const PassRefPtrWillBeRawPtr<AnimatableValue> getAnimatableValue() const OVERRIDE FINAL { return m_value; }
     39 
     40         virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const OVERRIDE FINAL;
     41         virtual PassRefPtrWillBeRawPtr<Interpolation> createInterpolation(CSSPropertyID, WebCore::Keyframe::PropertySpecificKeyframe* end, Element*) const OVERRIDE FINAL;
     42 
     43         virtual void trace(Visitor*) OVERRIDE;
     44 
     45     private:
     46         PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, PassRefPtrWillBeRawPtr<AnimatableValue>);
     47 
     48         virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> cloneWithOffset(double offset) const OVERRIDE;
     49         virtual bool isAnimatableValuePropertySpecificKeyframe() const OVERRIDE { return true; }
     50 
     51         RefPtrWillBeMember<AnimatableValue> m_value;
     52     };
     53 
     54 private:
     55     AnimatableValueKeyframe() { }
     56 
     57     AnimatableValueKeyframe(const AnimatableValueKeyframe& copyFrom);
     58 
     59     virtual PassRefPtrWillBeRawPtr<Keyframe> clone() const OVERRIDE;
     60     virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> createPropertySpecificKeyframe(CSSPropertyID) const OVERRIDE;
     61 
     62     virtual bool isAnimatableValueKeyframe() const OVERRIDE { return true; }
     63 
     64     typedef HashMap<CSSPropertyID, RefPtrWillBeMember<AnimatableValue> > PropertyValueMap;
     65     PropertyValueMap m_propertyValues;
     66 };
     67 
     68 typedef AnimatableValueKeyframe::PropertySpecificKeyframe AnimatableValuePropertySpecificKeyframe;
     69 
     70 DEFINE_TYPE_CASTS(AnimatableValueKeyframe, Keyframe, value, value->isAnimatableValueKeyframe(), value.isAnimatableValueKeyframe());
     71 DEFINE_TYPE_CASTS(AnimatableValuePropertySpecificKeyframe, Keyframe::PropertySpecificKeyframe, value, value->isAnimatableValuePropertySpecificKeyframe(), value.isAnimatableValuePropertySpecificKeyframe());
     72 
     73 }
     74 
     75 #endif
     76