Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Unified Diff: Source/core/animation/KeyframeEffectModel.h

Issue 216603008: Revert "Web Animations: Introduce String based KeyframeEffectModel" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/animation/Keyframe.h ('k') | Source/core/animation/KeyframeEffectModel.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/KeyframeEffectModel.h
diff --git a/Source/core/animation/KeyframeEffectModel.h b/Source/core/animation/KeyframeEffectModel.h
index bb1bfbe7074ff2a3df03e8a0c0c3916ab931c5ee..207665eb54dac217385470aabb8ab29c4250bcb3 100644
--- a/Source/core/animation/KeyframeEffectModel.h
+++ b/Source/core/animation/KeyframeEffectModel.h
@@ -31,11 +31,9 @@
#ifndef KeyframeEffectModel_h
#define KeyframeEffectModel_h
-#include "core/animation/AnimatableValueKeyframe.h"
+#include "core/animation/AnimatableValue.h"
#include "core/animation/AnimationEffect.h"
#include "core/animation/InterpolationEffect.h"
-#include "core/animation/StringKeyframe.h"
-#include "core/animation/TimedItem.h"
#include "heap/Handle.h"
#include "platform/animation/TimingFunction.h"
#include "wtf/HashMap.h"
@@ -47,36 +45,109 @@
namespace WebCore {
+typedef HashSet<CSSPropertyID> PropertySet;
+
class KeyframeEffectModelTest;
-class KeyframeEffectModelBase : public AnimationEffect {
+// Represents the keyframes set through the API.
+class Keyframe : public RefCountedWillBeGarbageCollectedFinalized<Keyframe> {
+public:
+ static PassRefPtrWillBeRawPtr<Keyframe> create()
+ {
+ return adoptRefWillBeNoop(new Keyframe);
+ }
+ static bool compareOffsets(const RefPtrWillBeRawPtr<Keyframe>& a, const RefPtrWillBeRawPtr<Keyframe>& b)
+ {
+ return a->offset() < b->offset();
+ }
+ void setOffset(double offset) { m_offset = offset; }
+ double offset() const { return m_offset; }
+ void setComposite(AnimationEffect::CompositeOperation composite) { m_composite = composite; }
+ AnimationEffect::CompositeOperation composite() const { return m_composite; }
+ void setEasing(PassRefPtr<TimingFunction>);
+ TimingFunction* easing() const { return m_easing.get(); }
+ void setPropertyValue(CSSPropertyID, const AnimatableValue*);
+ void clearPropertyValue(CSSPropertyID);
+ const AnimatableValue* propertyValue(CSSPropertyID) const;
+ PropertySet properties() const;
+ PassRefPtrWillBeRawPtr<Keyframe> clone() const { return adoptRefWillBeNoop(new Keyframe(*this)); }
+ PassRefPtrWillBeRawPtr<Keyframe> cloneWithOffset(double offset) const;
+
+ void trace(Visitor*);
+
+private:
+ Keyframe();
+ Keyframe(const Keyframe&);
+ double m_offset;
+ AnimationEffect::CompositeOperation m_composite;
+ RefPtr<TimingFunction> m_easing;
+ typedef WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<AnimatableValue> > PropertyValueMap;
+ PropertyValueMap m_propertyValues;
+};
+
+class KeyframeEffectModel FINAL : public AnimationEffect {
public:
+ class PropertySpecificKeyframe;
+ typedef WillBeHeapVector<RefPtrWillBeMember<Keyframe> > KeyframeVector;
+ typedef WillBeHeapVector<OwnPtrWillBeMember<PropertySpecificKeyframe> > PropertySpecificKeyframeVector;
// FIXME: Implement accumulation.
+ static PassRefPtrWillBeRawPtr<KeyframeEffectModel> create(const KeyframeVector& keyframes)
+ {
+ return adoptRefWillBeNoop(new KeyframeEffectModel(keyframes));
+ }
+
+ virtual bool affects(CSSPropertyID property) OVERRIDE
+ {
+ ensureKeyframeGroups();
+ return m_keyframeGroups->contains(property);
+ }
- typedef Vector<OwnPtr<Keyframe::PropertySpecificKeyframe> > PropertySpecificKeyframeVector;
- class PropertySpecificKeyframeGroup {
+ // AnimationEffect implementation.
+ virtual PassOwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > sample(int iteration, double fraction, double iterationDuration) const OVERRIDE;
+
+ // FIXME: Implement setFrames()
+ const KeyframeVector& getFrames() const { return m_keyframes; }
+
+ virtual bool isKeyframeEffectModel() const OVERRIDE { return true; }
+
+ bool isReplaceOnly();
+
+ PropertySet properties() const;
+
+ class PropertySpecificKeyframe : public NoBaseWillBeGarbageCollectedFinalized<PropertySpecificKeyframe> {
public:
- void appendKeyframe(PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe>);
- const PropertySpecificKeyframeVector& keyframes() const { return m_keyframes; }
+ PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, const AnimatableValue*, CompositeOperation);
+ double offset() const { return m_offset; }
+ TimingFunction* easing() const { return m_easing.get(); }
+ const AnimatableValue* value() const { return m_value.get(); }
+ AnimationEffect::CompositeOperation composite() const { return m_composite; }
+ PassOwnPtrWillBeRawPtr<PropertySpecificKeyframe> cloneWithOffset(double offset) const;
void trace(Visitor*);
private:
- void removeRedundantKeyframes();
- void addSyntheticKeyframeIfRequired(const KeyframeEffectModelBase* context);
-
- PropertySpecificKeyframeVector m_keyframes;
-
- friend class KeyframeEffectModelBase;
+ // Used by cloneWithOffset().
+ PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, PassRefPtrWillBeRawPtr<AnimatableValue>, CompositeOperation);
+ double m_offset;
+ RefPtr<TimingFunction> m_easing;
+ RefPtrWillBeMember<AnimatableValue> m_value;
+ AnimationEffect::CompositeOperation m_composite;
};
- bool isReplaceOnly();
+ class PropertySpecificKeyframeGroup : public NoBaseWillBeGarbageCollectedFinalized<PropertySpecificKeyframeGroup> {
+ public:
+ void appendKeyframe(PassOwnPtrWillBeRawPtr<PropertySpecificKeyframe>);
+ const PropertySpecificKeyframeVector& keyframes() const { return m_keyframes; }
- PropertySet properties() const;
+ void trace(Visitor*);
- typedef WillBeHeapVector<RefPtrWillBeMember<Keyframe> > KeyframeVector;
- const KeyframeVector& getFrames() const { return m_keyframes; }
- // FIXME: Implement setFrames()
+ private:
+ PropertySpecificKeyframeVector m_keyframes;
+ void removeRedundantKeyframes();
+ void addSyntheticKeyframeIfRequired();
+
+ friend class KeyframeEffectModel;
+ };
const PropertySpecificKeyframeVector& getPropertySpecificKeyframes(CSSPropertyID id) const
{
@@ -84,17 +155,11 @@ public:
return m_keyframeGroups->get(id)->keyframes();
}
- // AnimationEffect implementation.
- virtual PassOwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > sample(int iteration, double fraction, double iterationDuration) const OVERRIDE;
-
- virtual bool isKeyframeEffectModel() const OVERRIDE { return true; }
-
- virtual bool isAnimatableValueKeyframeEffectModel() const { return false; }
- virtual bool isStringKeyframeEffectModel() const { return false; }
-
virtual void trace(Visitor*) OVERRIDE;
-protected:
+private:
+ KeyframeEffectModel(const KeyframeVector& keyframes);
+
static KeyframeVector normalizedKeyframes(const KeyframeVector& keyframes);
// Lazily computes the groups of property-specific keyframes.
@@ -107,57 +172,13 @@ protected:
// property-specific lists.
typedef WillBeHeapHashMap<CSSPropertyID, OwnPtrWillBeMember<PropertySpecificKeyframeGroup> > KeyframeGroupMap;
mutable OwnPtrWillBeMember<KeyframeGroupMap> m_keyframeGroups;
- mutable RefPtr<InterpolationEffect> m_interpolationEffect;
- friend class KeyframeEffectModelTest;
-
- bool affects(CSSPropertyID property)
- {
- ensureKeyframeGroups();
- return m_keyframeGroups->contains(property);
- }
-};
-
-template <class Keyframe>
-class KeyframeEffectModel FINAL : public KeyframeEffectModelBase {
-public:
- typedef WillBeHeapVector<RefPtrWillBeMember<Keyframe> > KeyframeVector;
- static PassRefPtrWillBeRawPtr<KeyframeEffectModel<Keyframe> > create(const KeyframeVector& keyframes) { return adoptRefWillBeNoop(new KeyframeEffectModel(keyframes)); }
-
-private:
- KeyframeEffectModel(const KeyframeVector& keyframes)
- {
- m_keyframes.appendVector(keyframes);
- }
-
- virtual bool isAnimatableValueKeyframeEffectModel() const { return false; }
- virtual bool isStringKeyframeEffectModel() const { return false; }
+ mutable RefPtrWillBeMember<InterpolationEffect> m_interpolationEffect;
+ friend class KeyframeEffectModelTest;
};
-typedef KeyframeEffectModelBase::KeyframeVector KeyframeVector;
-typedef KeyframeEffectModelBase::PropertySpecificKeyframeVector PropertySpecificKeyframeVector;
-
-typedef KeyframeEffectModel<AnimatableValueKeyframe> AnimatableValueKeyframeEffectModel;
-typedef AnimatableValueKeyframeEffectModel::KeyframeVector AnimatableValueKeyframeVector;
-typedef AnimatableValueKeyframeEffectModel::PropertySpecificKeyframeVector AnimatableValuePropertySpecificKeyframeVector;
-
-typedef KeyframeEffectModel<StringKeyframe> StringKeyframeEffectModel;
-typedef StringKeyframeEffectModel::KeyframeVector StringKeyframeVector;
-typedef StringKeyframeEffectModel::PropertySpecificKeyframeVector StringPropertySpecificKeyframeVector;
-
-DEFINE_TYPE_CASTS(KeyframeEffectModelBase, AnimationEffect, value, value->isKeyframeEffectModel(), value.isKeyframeEffectModel());
-DEFINE_TYPE_CASTS(AnimatableValueKeyframeEffectModel, KeyframeEffectModelBase, value, value->isAnimatableValueKeyframeEffectModel(), value.isAnimatableValueKeyframeEffectModel());
-
-inline const AnimatableValueKeyframeEffectModel* toAnimatableValueKeyframeEffectModel(const AnimationEffect* base)
-{
- return toAnimatableValueKeyframeEffectModel(toKeyframeEffectModelBase(base));
-}
-
-inline AnimatableValueKeyframeEffectModel* toAnimatableValueKeyframeEffectModel(AnimationEffect* base)
-{
- return toAnimatableValueKeyframeEffectModel(toKeyframeEffectModelBase(base));
-}
+DEFINE_TYPE_CASTS(KeyframeEffectModel, AnimationEffect, value, value->isKeyframeEffectModel(), value.isKeyframeEffectModel());
} // namespace WebCore
« no previous file with comments | « Source/core/animation/Keyframe.h ('k') | Source/core/animation/KeyframeEffectModel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698