// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef SKY_ENGINE_CORE_ANIMATION_ANIMATABLE_ANIMATABLEVALUEKEYFRAME_H_ #define SKY_ENGINE_CORE_ANIMATION_ANIMATABLE_ANIMATABLEVALUEKEYFRAME_H_ #include "sky/engine/core/animation/Keyframe.h" #include "sky/engine/core/animation/animatable/AnimatableValue.h" namespace blink { class AnimatableValueKeyframe : public Keyframe { public: static PassRefPtr create() { return adoptRef(new AnimatableValueKeyframe); } void setPropertyValue(CSSPropertyID property, PassRefPtr value) { m_propertyValues.add(property, value); } void clearPropertyValue(CSSPropertyID property) { m_propertyValues.remove(property); } AnimatableValue* propertyValue(CSSPropertyID property) const { ASSERT(m_propertyValues.contains(property)); return m_propertyValues.get(property); } virtual PropertySet properties() const override; class PropertySpecificKeyframe : public Keyframe::PropertySpecificKeyframe { public: PropertySpecificKeyframe(double offset, PassRefPtr easing, const AnimatableValue*, AnimationEffect::CompositeOperation); AnimatableValue* value() const { return m_value.get(); } virtual const PassRefPtr getAnimatableValue() const override final { return m_value; } virtual PassOwnPtr neutralKeyframe(double offset, PassRefPtr easing) const override final; virtual PassRefPtr createInterpolation(CSSPropertyID, blink::Keyframe::PropertySpecificKeyframe* end, Element*) const override final; private: PropertySpecificKeyframe(double offset, PassRefPtr easing, PassRefPtr); virtual PassOwnPtr cloneWithOffset(double offset) const override; virtual bool isAnimatableValuePropertySpecificKeyframe() const override { return true; } RefPtr m_value; }; private: AnimatableValueKeyframe() { } AnimatableValueKeyframe(const AnimatableValueKeyframe& copyFrom); virtual PassRefPtr clone() const override; virtual PassOwnPtr createPropertySpecificKeyframe(CSSPropertyID) const override; virtual bool isAnimatableValueKeyframe() const override { return true; } typedef HashMap > PropertyValueMap; PropertyValueMap m_propertyValues; }; typedef AnimatableValueKeyframe::PropertySpecificKeyframe AnimatableValuePropertySpecificKeyframe; DEFINE_TYPE_CASTS(AnimatableValueKeyframe, Keyframe, value, value->isAnimatableValueKeyframe(), value.isAnimatableValueKeyframe()); DEFINE_TYPE_CASTS(AnimatableValuePropertySpecificKeyframe, Keyframe::PropertySpecificKeyframe, value, value->isAnimatableValuePropertySpecificKeyframe(), value.isAnimatableValuePropertySpecificKeyframe()); } #endif // SKY_ENGINE_CORE_ANIMATION_ANIMATABLE_ANIMATABLEVALUEKEYFRAME_H_