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

Side by Side Diff: third_party/WebKit/Source/core/animation/LegacyStyleInterpolation.h

Issue 2649103007: Make PropertyHandle instances const references where possible (Closed)
Patch Set: Created 3 years, 10 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 LegacyStyleInterpolation_h 5 #ifndef LegacyStyleInterpolation_h
6 #define LegacyStyleInterpolation_h 6 #define LegacyStyleInterpolation_h
7 7
8 #include "core/CSSPropertyNames.h" 8 #include "core/CSSPropertyNames.h"
9 #include "core/CoreExport.h" 9 #include "core/CoreExport.h"
10 #include "core/animation/Interpolation.h" 10 #include "core/animation/Interpolation.h"
(...skipping 17 matching lines...) Expand all
28 } 28 }
29 29
30 // 1) convert m_cachedValue into an X 30 // 1) convert m_cachedValue into an X
31 // 2) shove X into StyleResolverState 31 // 2) shove X into StyleResolverState
32 // X can be: 32 // X can be:
33 // (1) a CSSValue (and applied via StyleBuilder::applyProperty) 33 // (1) a CSSValue (and applied via StyleBuilder::applyProperty)
34 // (2) an AnimatableValue (and applied via 34 // (2) an AnimatableValue (and applied via
35 // AnimatedStyleBuilder::applyProperty) 35 // AnimatedStyleBuilder::applyProperty)
36 // (3) a custom value that is inserted directly into the StyleResolverState. 36 // (3) a custom value that is inserted directly into the StyleResolverState.
37 void apply(StyleResolverState& state) const { 37 void apply(StyleResolverState& state) const {
38 AnimatedStyleBuilder::applyProperty(m_id, state, currentValue().get()); 38 AnimatedStyleBuilder::applyProperty(id(), state, currentValue().get());
39 } 39 }
40 40
41 bool isLegacyStyleInterpolation() const final { return true; } 41 bool isLegacyStyleInterpolation() const final { return true; }
42 42
43 PassRefPtr<AnimatableValue> currentValue() const { 43 PassRefPtr<AnimatableValue> currentValue() const {
44 return toInterpolableAnimatableValue(m_cachedValue.get())->value(); 44 return toInterpolableAnimatableValue(m_cachedValue.get())->value();
45 } 45 }
46 46
47 CSSPropertyID id() const { return m_id; } 47 CSSPropertyID id() const { return m_property.cssProperty(); }
48 48
49 PropertyHandle getProperty() const final { return PropertyHandle(id()); } 49 const PropertyHandle& getProperty() const final { return m_property; }
50 50
51 void interpolate(int iteration, double fraction) final; 51 void interpolate(int iteration, double fraction) final;
52 52
53 protected: 53 protected:
54 LegacyStyleInterpolation(std::unique_ptr<InterpolableValue> start, 54 LegacyStyleInterpolation(std::unique_ptr<InterpolableValue> start,
55 std::unique_ptr<InterpolableValue> end, 55 std::unique_ptr<InterpolableValue> end,
56 CSSPropertyID); 56 CSSPropertyID);
57 57
58 private: 58 private:
59 const std::unique_ptr<InterpolableValue> m_start; 59 const std::unique_ptr<InterpolableValue> m_start;
60 const std::unique_ptr<InterpolableValue> m_end; 60 const std::unique_ptr<InterpolableValue> m_end;
61 CSSPropertyID m_id; 61 PropertyHandle m_property;
62 62
63 mutable double m_cachedFraction; 63 mutable double m_cachedFraction;
64 mutable int m_cachedIteration; 64 mutable int m_cachedIteration;
65 mutable std::unique_ptr<InterpolableValue> m_cachedValue; 65 mutable std::unique_ptr<InterpolableValue> m_cachedValue;
66 66
67 InterpolableValue* getCachedValueForTesting() const { 67 InterpolableValue* getCachedValueForTesting() const {
68 return m_cachedValue.get(); 68 return m_cachedValue.get();
69 } 69 }
70 70
71 friend class AnimationInterpolableValueTest; 71 friend class AnimationInterpolableValueTest;
72 friend class AnimationInterpolationEffectTest; 72 friend class AnimationInterpolationEffectTest;
73 }; 73 };
74 74
75 DEFINE_TYPE_CASTS(LegacyStyleInterpolation, 75 DEFINE_TYPE_CASTS(LegacyStyleInterpolation,
76 Interpolation, 76 Interpolation,
77 value, 77 value,
78 value->isLegacyStyleInterpolation(), 78 value->isLegacyStyleInterpolation(),
79 value.isLegacyStyleInterpolation()); 79 value.isLegacyStyleInterpolation());
80 80
81 } // namespace blink 81 } // namespace blink
82 82
83 #endif 83 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698