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

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

Issue 212213007: Oilpan: Move InterpolableValue's hierarchy to oilpan's heap (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 unified diff | Download patch | Annotate | Revision Log
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 #include "config.h" 5 #include "config.h"
6 #include "core/animation/Interpolation.h" 6 #include "core/animation/Interpolation.h"
7 7
8 #include "core/css/resolver/AnimatedStyleBuilder.h" 8 #include "core/css/resolver/AnimatedStyleBuilder.h"
9 #include "core/css/resolver/StyleResolverState.h" 9 #include "core/css/resolver/StyleResolverState.h"
10 10
11 namespace WebCore { 11 namespace WebCore {
12 12
13 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(Interpolation);
14
13 namespace { 15 namespace {
14 16
15 bool typesMatch(const InterpolableValue* start, const InterpolableValue* end) 17 bool typesMatch(const InterpolableValue* start, const InterpolableValue* end)
16 { 18 {
17 if (start->isNumber()) 19 if (start->isNumber())
18 return end->isNumber(); 20 return end->isNumber();
19 if (start->isBool()) 21 if (start->isBool())
20 return end->isBool(); 22 return end->isBool();
21 if (start->isAnimatableValue()) 23 if (start->isAnimatableValue())
22 return end->isAnimatableValue(); 24 return end->isAnimatableValue();
23 if (!(start->isList() && end->isList())) 25 if (!(start->isList() && end->isList()))
24 return false; 26 return false;
25 const InterpolableList* startList = toInterpolableList(start); 27 const InterpolableList* startList = toInterpolableList(start);
26 const InterpolableList* endList = toInterpolableList(end); 28 const InterpolableList* endList = toInterpolableList(end);
27 if (startList->length() != endList->length()) 29 if (startList->length() != endList->length())
28 return false; 30 return false;
29 for (size_t i = 0; i < startList->length(); ++i) { 31 for (size_t i = 0; i < startList->length(); ++i) {
30 if (!typesMatch(startList->get(i), endList->get(i))) 32 if (!typesMatch(startList->get(i), endList->get(i)))
31 return false; 33 return false;
32 } 34 }
33 return true; 35 return true;
34 } 36 }
35 37
36 } 38 }
37 39
38 Interpolation::Interpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Int erpolableValue> end) 40 Interpolation::Interpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, Pa ssOwnPtrWillBeRawPtr<InterpolableValue> end)
39 : m_start(start) 41 : m_start(start)
40 , m_end(end) 42 , m_end(end)
41 , m_cachedFraction(0) 43 , m_cachedFraction(0)
42 , m_cachedIteration(0) 44 , m_cachedIteration(0)
43 , m_cachedValue(m_start->clone()) 45 , m_cachedValue(m_start->clone())
44 { 46 {
45 RELEASE_ASSERT(typesMatch(m_start.get(), m_end.get())); 47 RELEASE_ASSERT(typesMatch(m_start.get(), m_end.get()));
46 } 48 }
47 49
48 void Interpolation::interpolate(int iteration, double fraction) const 50 void Interpolation::interpolate(int iteration, double fraction) const
49 { 51 {
50 if (m_cachedFraction != fraction || m_cachedIteration != iteration) { 52 if (m_cachedFraction != fraction || m_cachedIteration != iteration) {
51 m_cachedValue = m_start->interpolate(*m_end, fraction); 53 m_cachedValue = m_start->interpolate(*m_end, fraction);
52 m_cachedIteration = iteration; 54 m_cachedIteration = iteration;
53 m_cachedFraction = fraction; 55 m_cachedFraction = fraction;
54 } 56 }
55 } 57 }
56 58
59 void Interpolation::trace(Visitor* visitor)
60 {
61 visitor->trace(m_start);
62 visitor->trace(m_end);
63 visitor->trace(m_cachedValue);
64 }
65
57 void StyleInterpolation::trace(Visitor* visitor) 66 void StyleInterpolation::trace(Visitor* visitor)
58 { 67 {
59 Interpolation::trace(visitor); 68 Interpolation::trace(visitor);
60 } 69 }
61 70
62 void LegacyStyleInterpolation::apply(StyleResolverState& state) const 71 void LegacyStyleInterpolation::apply(StyleResolverState& state) const
63 { 72 {
64 AnimatableValue* value = currentValue(); 73 AnimatableValue* value = currentValue();
65 AnimatedStyleBuilder::applyProperty(m_id, state, value); 74 AnimatedStyleBuilder::applyProperty(m_id, state, value);
66 } 75 }
67 76
68 void LegacyStyleInterpolation::trace(Visitor* visitor) 77 void LegacyStyleInterpolation::trace(Visitor* visitor)
69 { 78 {
70 StyleInterpolation::trace(visitor); 79 StyleInterpolation::trace(visitor);
71 } 80 }
72 81
73 } 82 }
OLDNEW
« Source/core/animation/InterpolableValue.h ('K') | « Source/core/animation/Interpolation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698