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

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

Issue 182383011: Web Animations: Add Interpolation class. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@interpolableValue
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
« no previous file with comments | « Source/core/animation/Interpolation.h ('k') | Source/core/core.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « Source/core/animation/Interpolation.h ('k') | Source/core/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698