// 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_STRINGKEYFRAME_H_ #define SKY_ENGINE_CORE_ANIMATION_STRINGKEYFRAME_H_ #include "sky/engine/core/animation/Keyframe.h" #include "sky/engine/core/css/StylePropertySet.h" namespace blink { class StyleSheetContents; class StringKeyframe : public Keyframe { public: static PassRefPtr create() { return adoptRef(new StringKeyframe); } void setPropertyValue(CSSPropertyID, const String& value, StyleSheetContents*); void clearPropertyValue(CSSPropertyID property) { m_propertySet->removeProperty(property); } CSSValue* propertyValue(CSSPropertyID property) const { int index = m_propertySet->findPropertyIndex(property); RELEASE_ASSERT(index >= 0); return m_propertySet->propertyAt(static_cast(index)).value(); } virtual PropertySet properties() const override; class PropertySpecificKeyframe : public Keyframe::PropertySpecificKeyframe { public: PropertySpecificKeyframe(double offset, PassRefPtr easing, CSSValue*, AnimationEffect::CompositeOperation); CSSValue* value() const { return m_value.get(); } virtual const PassRefPtr getAnimatableValue() const override final { return m_animatableValueCache.get(); } 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, CSSValue*); virtual PassOwnPtr cloneWithOffset(double offset) const; virtual bool isStringPropertySpecificKeyframe() const override { return true; } RefPtr m_value; mutable RefPtr m_animatableValueCache; }; private: StringKeyframe() : m_propertySet(MutableStylePropertySet::create()) { } StringKeyframe(const StringKeyframe& copyFrom); virtual PassRefPtr clone() const override; virtual PassOwnPtr createPropertySpecificKeyframe(CSSPropertyID) const override; virtual bool isStringKeyframe() const override { return true; } RefPtr m_propertySet; }; typedef StringKeyframe::PropertySpecificKeyframe StringPropertySpecificKeyframe; DEFINE_TYPE_CASTS(StringKeyframe, Keyframe, value, value->isStringKeyframe(), value.isStringKeyframe()); DEFINE_TYPE_CASTS(StringPropertySpecificKeyframe, Keyframe::PropertySpecificKeyframe, value, value->isStringPropertySpecificKeyframe(), value.isStringPropertySpecificKeyframe()); } #endif // SKY_ENGINE_CORE_ANIMATION_STRINGKEYFRAME_H_