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

Side by Side Diff: Source/core/animation/Interpolation.h

Issue 215883005: Web Animations: Introduce String based KeyframeEffectModel (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef Interpolation_h 5 #ifndef Interpolation_h
6 #define Interpolation_h 6 #define Interpolation_h
7 7
8 #include "CSSPropertyNames.h" 8 #include "CSSPropertyNames.h"
9 #include "core/animation/InterpolableValue.h" 9 #include "core/animation/InterpolableValue.h"
10 #include "heap/Handle.h" 10 #include "heap/Handle.h"
(...skipping 27 matching lines...) Expand all
38 mutable int m_cachedIteration; 38 mutable int m_cachedIteration;
39 mutable OwnPtr<InterpolableValue> m_cachedValue; 39 mutable OwnPtr<InterpolableValue> m_cachedValue;
40 40
41 Interpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<InterpolableVa lue> end); 41 Interpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<InterpolableVa lue> end);
42 42
43 private: 43 private:
44 InterpolableValue* getCachedValueForTesting() const { return m_cachedValue.g et(); } 44 InterpolableValue* getCachedValueForTesting() const { return m_cachedValue.g et(); }
45 45
46 friend class AnimationInterpolableValueTest; 46 friend class AnimationInterpolableValueTest;
47 friend class AnimationInterpolationEffectTest; 47 friend class AnimationInterpolationEffectTest;
48
49 }; 48 };
50 49
51 class StyleInterpolation : public Interpolation { 50 class StyleInterpolation : public Interpolation {
52 public: 51 public:
53 // 1) convert m_cachedValue into an X 52 // 1) convert m_cachedValue into an X
54 // 2) shove X into StyleResolverState 53 // 2) shove X into StyleResolverState
55 // X can be: 54 // X can be:
56 // (1) a CSSValue (and applied via StyleBuilder::applyProperty) 55 // (1) a CSSValue (and applied via StyleBuilder::applyProperty)
57 // (2) an AnimatableValue (and applied via // AnimatedStyleBuilder::applyPro perty) 56 // (2) an AnimatableValue (and applied via // AnimatedStyleBuilder::applyPro perty)
58 // (3) a custom value that is inserted directly into the StyleResolverState. 57 // (3) a custom value that is inserted directly into the StyleResolverState.
59 virtual void apply(StyleResolverState&) const = 0; 58 virtual void apply(StyleResolverState&) const = 0;
60 59
61 virtual bool isStyleInterpolation() const OVERRIDE FINAL { return true; } 60 virtual bool isStyleInterpolation() const OVERRIDE FINAL { return true; }
61 // FIXME: This method exists for two reasons:
62 // * tests use it to extract values without applying them
63 // * interrupted compositor transitions use it to generate a new set of
64 // keyframes representing the retargeted transition.
65 // Once KeyframeEffectModel objects can be generated from
66 // InterpolationEffect objects, we can use this approach in both cases,
67 // and remove this method.
68 virtual PassRefPtr<AnimatableValue> currentValue() const
69 {
70 ASSERT_NOT_REACHED();
71 return nullptr;
72 }
alancutter (OOO until 2018) 2014/04/01 03:12:48 Adding currentValue() to StyleInterpolation is lik
shans 2014/04/01 04:01:27 Done.
62 73
63 CSSPropertyID id() const { return m_id; } 74 CSSPropertyID id() const { return m_id; }
64 75
65 virtual void trace(Visitor*) OVERRIDE; 76 virtual void trace(Visitor*) OVERRIDE;
66 77
67 protected: 78 protected:
68 CSSPropertyID m_id; 79 CSSPropertyID m_id;
69 80
70 StyleInterpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Interpola bleValue> end, CSSPropertyID id) 81 StyleInterpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Interpola bleValue> end, CSSPropertyID id)
71 : Interpolation(start, end) 82 : Interpolation(start, end)
72 , m_id(id) 83 , m_id(id)
73 { 84 {
74 } 85 }
75 }; 86 };
76 87
77 class LegacyStyleInterpolation : public StyleInterpolation { 88 class LegacyStyleInterpolation : public StyleInterpolation {
78 public: 89 public:
79 static PassRefPtrWillBeRawPtr<LegacyStyleInterpolation> create(PassRefPtrWil lBeRawPtr<AnimatableValue> start, PassRefPtrWillBeRawPtr<AnimatableValue> end, C SSPropertyID id) 90 static PassRefPtrWillBeRawPtr<LegacyStyleInterpolation> create(PassRefPtrWil lBeRawPtr<AnimatableValue> start, PassRefPtrWillBeRawPtr<AnimatableValue> end, C SSPropertyID id)
80 { 91 {
81 return adoptRefWillBeNoop(new LegacyStyleInterpolation(InterpolableAnima tableValue::create(start), InterpolableAnimatableValue::create(end), id)); 92 return adoptRefWillBeNoop(new LegacyStyleInterpolation(InterpolableAnima tableValue::create(start), InterpolableAnimatableValue::create(end), id));
82 } 93 }
83 94
84 virtual void apply(StyleResolverState&) const; 95 virtual void apply(StyleResolverState&) const;
85 96
86 virtual bool isLegacyStyleInterpolation() const OVERRIDE FINAL { return true ; } 97 virtual bool isLegacyStyleInterpolation() const OVERRIDE FINAL { return true ; }
87 AnimatableValue* currentValue() const 98 PassRefPtr<AnimatableValue> currentValue() const
88 { 99 {
89 InterpolableAnimatableValue* value = static_cast<InterpolableAnimatableV alue*>(m_cachedValue.get()); 100 InterpolableAnimatableValue* value = static_cast<InterpolableAnimatableV alue*>(m_cachedValue.get());
90 return value->value(); 101 return value->value();
91 } 102 }
92 103
93 virtual void trace(Visitor*) OVERRIDE; 104 virtual void trace(Visitor*) OVERRIDE;
94 105
95 private: 106 private:
96 LegacyStyleInterpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Int erpolableValue> end, CSSPropertyID id) 107 LegacyStyleInterpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Int erpolableValue> end, CSSPropertyID id)
97 : StyleInterpolation(start, end, id) 108 : StyleInterpolation(start, end, id)
98 { 109 {
99 } 110 }
100 }; 111 };
101 112
102 DEFINE_TYPE_CASTS(StyleInterpolation, Interpolation, value, value->isStyleInterp olation(), value.isStyleInterpolation()); 113 DEFINE_TYPE_CASTS(StyleInterpolation, Interpolation, value, value->isStyleInterp olation(), value.isStyleInterpolation());
103 DEFINE_TYPE_CASTS(LegacyStyleInterpolation, Interpolation, value, value->isLegac yStyleInterpolation(), value.isLegacyStyleInterpolation()); 114 DEFINE_TYPE_CASTS(LegacyStyleInterpolation, Interpolation, value, value->isLegac yStyleInterpolation(), value.isLegacyStyleInterpolation());
104 115
105 } 116 }
106 #endif 117 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698