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

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

Issue 25082007: Web Animations CSS: Split AnimatableNumber into AnimatableDouble and AnimatableLength (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Review changes Created 7 years, 2 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 11 matching lines...) Expand all
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/animation/AnimatableVisibility.h" 32 #include "core/animation/AnimatableDouble.h"
33
34 #include "core/css/CSSPrimitiveValue.h"
35 #include "core/css/CSSValuePool.h"
36 #include "core/platform/animation/AnimationUtilities.h"
33 37
34 namespace WebCore { 38 namespace WebCore {
35 39
36 PassRefPtr<AnimatableValue> AnimatableVisibility::interpolateTo(const Animatable Value* value, double fraction) const 40 PassRefPtr<CSSValue> AnimatableDouble::toCSSValue() const
37 { 41 {
38 EVisibility from = m_visibility; 42 return cssValuePool().createValue(m_number, CSSPrimitiveValue::CSS_NUMBER);
39 EVisibility to = toAnimatableVisibility(value)->m_visibility; 43 }
40 if (from != VISIBLE && to != VISIBLE) 44
41 return defaultInterpolateTo(this, value, fraction); 45 PassRefPtr<AnimatableValue> AnimatableDouble::interpolateTo(const AnimatableValu e* value, double fraction) const
42 if (fraction <= 0) 46 {
47 const AnimatableDouble* other = toAnimatableDouble(value);
48 return AnimatableDouble::create(blend(m_number, other->m_number, fraction));
49 }
50
51 PassRefPtr<AnimatableValue> AnimatableDouble::addWith(const AnimatableValue* val ue) const
52 {
53 // Optimization for adding with 0.
54 if (!m_number)
55 return takeConstRef(value);
56 const AnimatableDouble* other = toAnimatableDouble(value);
57 if (!other->m_number)
43 return takeConstRef(this); 58 return takeConstRef(this);
44 if (fraction >= 1) 59
45 return takeConstRef(value); 60 return AnimatableDouble::create(m_number + other->m_number);
46 return takeConstRef(from == VISIBLE ? this : value);
47 } 61 }
48 62
49 } // namespace WebCore 63 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/animation/AnimatableDouble.h ('k') | Source/core/animation/AnimatableDoubleTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698