OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 #include "core/animation/Interpolation.h" | |
7 | |
8 namespace WebCore { | |
9 | |
10 void Interpolation::interpolate(double fraction) const | |
11 { | |
12 if (m_cachedFraction != fraction) { | |
13 m_cachedValue = m_start->interpolate(*m_end, fraction); | |
14 m_cachedFraction = fraction; | |
15 } | |
16 } | |
17 | |
18 namespace { | |
19 | |
20 bool typesMatch(const InterpolableValue* start, const InterpolableValue* end) | |
21 { | |
22 if (start->isNumber()) | |
23 return end->isNumber(); | |
24 if (start->isBool()) | |
25 return end->isBool(); | |
26 const InterpolableList* startList = toInterpolableList(start); | |
27 const InterpolableList* endList = toInterpolableList(end); | |
Timothy Loh
2014/03/06 02:54:49
Probably need to explicitly check for end->isList(
shans
2014/03/06 04:42:57
Done.
| |
28 if (startList->length() != endList->length()) | |
29 return false; | |
30 for (size_t i = 0; i < startList->length(); ++i) { | |
31 if (!typesMatch(startList->get(i), endList->get(i))) | |
32 return false; | |
33 } | |
34 return true; | |
35 } | |
36 | |
37 } | |
38 | |
39 Interpolation::Interpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Int erpolableValue> end) | |
alancutter (OOO until 2018)
2014/03/05 04:30:43
Constructors are usually at the top of source file
shans
2014/03/06 04:42:57
Done.
| |
40 : m_start(start) | |
41 , m_end(end) | |
42 , m_cachedFraction(0) | |
43 , m_cachedValue(m_start->clone()) | |
44 { | |
45 ASSERT(typesMatch(m_start.get(), m_end.get())); | |
dstockwell
2014/03/06 02:12:19
I thought this was going to be a release assert to
shans
2014/03/06 04:42:57
Done.
| |
46 } | |
47 | |
48 } | |
OLD | NEW |