Chromium Code Reviews| Index: Source/core/animation/AnimatableValueKeyframe.h |
| diff --git a/Source/core/animation/AnimatableValueKeyframe.h b/Source/core/animation/AnimatableValueKeyframe.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..83d2f47fa8f8a2d9d059a409fbcf9a389fc5f18c |
| --- /dev/null |
| +++ b/Source/core/animation/AnimatableValueKeyframe.h |
| @@ -0,0 +1,100 @@ |
| +// 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 AnimatableValueKeyframe_h |
| +#define AnimatableValueKeyframe_h |
| + |
| +#include "core/animation/AnimatableValue.h" |
| +#include "core/animation/Keyframe.h" |
| + |
| +namespace WebCore { |
| + |
| +class AnimatableValueKeyframe : public Keyframe { |
| +public: |
| + static PassRefPtr<AnimatableValueKeyframe> create() { return adoptRef(new AnimatableValueKeyframe); } |
| + void setPropertyValue(CSSPropertyID property, PassRefPtr<AnimatableValue> 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 |
| + { |
| + // This is not used in time-critical code, so we probably don't need to |
|
dstockwell
2014/04/01 06:38:12
can these bodies not be in .cpp?
shans
2014/04/01 12:05:32
Done.
|
| + // worry about caching this result. |
| + PropertySet properties; |
| + for (typename PropertyValueMap::const_iterator iter = m_propertyValues.begin(); iter != m_propertyValues.end(); ++iter) |
| + properties.add(*iter.keys()); |
| + return properties; |
| + } |
| + |
| + class PropertySpecificKeyframe : public Keyframe::PropertySpecificKeyframe { |
| + public: |
| + PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, const AnimatableValue* value, AnimationEffect::CompositeOperation op) |
| + : Keyframe::PropertySpecificKeyframe(offset, easing, op) |
| + , m_value(PassRefPtr<AnimatableValue>(const_cast<AnimatableValue*>(value))) |
| + { |
| + } |
| + |
| + AnimatableValue* value() const { return m_value.get(); } |
| + |
| + virtual PassOwnPtr<Keyframe::PropertySpecificKeyframe> neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const OVERRIDE FINAL; |
| + virtual PassRefPtr<Interpolation> createInterpolation(CSSPropertyID, WebCore::Keyframe::PropertySpecificKeyframe *end) const OVERRIDE FINAL; |
| + |
| + private: |
| + PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, PassRefPtr<AnimatableValue> value) |
| + : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect::CompositeReplace) |
| + , m_value(value) |
| + { |
| + ASSERT(!isNull(m_offset)); |
| + } |
| + |
| + virtual PassOwnPtr<Keyframe::PropertySpecificKeyframe> cloneWithOffset(double offset) const OVERRIDE |
| + { |
| + Keyframe::PropertySpecificKeyframe *theClone = new PropertySpecificKeyframe(offset, m_easing, m_value); |
|
dstockwell
2014/04/01 06:38:12
...frame* theClone
shans
2014/04/01 12:05:32
Done.
|
| + return adoptPtr(theClone); |
| + } |
| + virtual bool isAnimatableValuePropertySpecificKeyframe() const OVERRIDE { return true; } |
| + |
| + RefPtr<AnimatableValue> m_value; |
| + }; |
| + |
| +private: |
| + AnimatableValueKeyframe() |
| + : Keyframe() |
| + { |
| + } |
| + AnimatableValueKeyframe(const AnimatableValueKeyframe& copyFrom) |
| + : Keyframe(copyFrom.m_offset, copyFrom.m_composite, copyFrom.m_easing) |
| + { |
| + for (typename PropertyValueMap::const_iterator iter = copyFrom.m_propertyValues.begin(); iter != copyFrom.m_propertyValues.end(); ++iter) |
| + setPropertyValue(iter->key, iter->value.get()); |
| + } |
| + |
| + virtual PassRefPtrWillBeRawPtr<Keyframe> clone() const OVERRIDE |
| + { |
| + return adoptRefWillBeNoop(new AnimatableValueKeyframe(*this)); |
| + } |
| + virtual PassOwnPtr<Keyframe::PropertySpecificKeyframe> createPropertySpecificKeyframe(CSSPropertyID property) const OVERRIDE |
| + { |
| + return adoptPtr(new PropertySpecificKeyframe(offset(), easing(), propertyValue(property), composite())); |
| + } |
| + virtual bool isAnimatableValueKeyframe() const OVERRIDE { return true; } |
| + |
| + typedef HashMap<CSSPropertyID, RefPtr<AnimatableValue> > PropertyValueMap; |
| + PropertyValueMap m_propertyValues; |
| +}; |
| + |
| +typedef AnimatableValueKeyframe::PropertySpecificKeyframe AnimatableValuePropertySpecificKeyframe; |
| + |
| +DEFINE_TYPE_CASTS(AnimatableValueKeyframe, Keyframe, value, value->isAnimatableValueKeyframe(), value.isAnimatableValueKeyframe()); |
| +DEFINE_TYPE_CASTS(AnimatableValuePropertySpecificKeyframe, PropertySpecificKeyframe, value, value->isAnimatableValuePropertySpecificKeyframe(), value.isAnimatableValuePropertySpecificKeyframe()); |
| + |
| +} |
| + |
| +#endif |