| Index: Source/core/animation/StringKeyframe.h
|
| diff --git a/Source/core/animation/StringKeyframe.h b/Source/core/animation/StringKeyframe.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..db83920522e2076639e2b1aa158355982e84dc3c
|
| --- /dev/null
|
| +++ b/Source/core/animation/StringKeyframe.h
|
| @@ -0,0 +1,96 @@
|
| +// 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 StringKeyframe_h
|
| +#define StringKeyframe_h
|
| +
|
| +#include "core/animation/AnimatableValue.h"
|
| +#include "core/animation/Keyframe.h"
|
| +
|
| +namespace WebCore {
|
| +
|
| +class StringKeyframe : public Keyframe {
|
| +public:
|
| + static PassRefPtr<StringKeyframe> create() { return adoptRef(new StringKeyframe); }
|
| + void setPropertyValue(CSSPropertyID property, const String& value)
|
| + {
|
| + m_propertyValues.add(property, value);
|
| + }
|
| + void clearPropertyValue(CSSPropertyID property) { m_propertyValues.remove(property); }
|
| + String 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
|
| + // 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 String& value, AnimationEffect::CompositeOperation op)
|
| + : Keyframe::PropertySpecificKeyframe(offset, easing, op)
|
| + , m_value(value)
|
| + {
|
| + }
|
| +
|
| + const String& value() const { return m_value; }
|
| +
|
| + 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, const String& value)
|
| + : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect::CompositeReplace)
|
| + , m_value(value)
|
| + {
|
| + ASSERT(!isNull(m_offset));
|
| + }
|
| +
|
| + virtual PassOwnPtr<Keyframe::PropertySpecificKeyframe> cloneWithOffset(double offset) const
|
| + {
|
| + Keyframe::PropertySpecificKeyframe *theClone = new PropertySpecificKeyframe(offset, m_easing, m_value);
|
| + return adoptPtr(theClone);
|
| + }
|
| + virtual bool isStringPropertySpecificKeyframe() const OVERRIDE { return true; }
|
| +
|
| + String m_value;
|
| + };
|
| +
|
| +private:
|
| + StringKeyframe()
|
| + : Keyframe()
|
| + {
|
| + }
|
| + StringKeyframe(const StringKeyframe& 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);
|
| + }
|
| +
|
| + virtual PassRefPtrWillBeRawPtr<Keyframe> clone() const OVERRIDE
|
| + {
|
| + return adoptRefWillBeNoop(new StringKeyframe(*this));
|
| + }
|
| + virtual PassOwnPtr<Keyframe::PropertySpecificKeyframe> createPropertySpecificKeyframe(CSSPropertyID property) const
|
| + {
|
| + return adoptPtr(new PropertySpecificKeyframe(offset(), easing(), propertyValue(property), composite()));
|
| + }
|
| + virtual bool isStringKeyframe() const OVERRIDE { return true; }
|
| +
|
| + typedef HashMap<CSSPropertyID, String> PropertyValueMap;
|
| + PropertyValueMap m_propertyValues;
|
| +};
|
| +
|
| +typedef StringKeyframe::PropertySpecificKeyframe StringPropertySpecificKeyframe;
|
| +
|
| +}
|
| +
|
| +#endif
|
|
|