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

Side by Side Diff: sky/engine/core/animation/animatable/AnimatableLength.cpp

Issue 1229273004: Remove Animations and Transitions. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 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
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29 */
30
31 #include "sky/engine/core/animation/animatable/AnimatableLength.h"
32
33 #include "sky/engine/platform/CalculationValue.h"
34 #include "sky/engine/platform/animation/AnimationUtilities.h"
35
36 namespace blink {
37
38 namespace {
39
40 double clampNumber(double value, ValueRange range)
41 {
42 if (range == ValueRangeNonNegative)
43 return std::max(value, 0.0);
44 ASSERT(range == ValueRangeAll);
45 return value;
46 }
47
48 } // namespace
49
50 AnimatableLength::AnimatableLength(const Length& length)
51 {
52 PixelsAndPercent pixelsAndPercent = length.pixelsAndPercent();
53 m_pixels = pixelsAndPercent.pixels;
54 m_percent = pixelsAndPercent.percent;
55 m_hasPixels = length.type() != Percent;
56 m_hasPercent = !length.isFixed();
57 }
58
59 Length AnimatableLength::length(ValueRange range) const
60 {
61 if (!m_hasPercent)
62 return Length(clampNumber(m_pixels, range), Fixed);
63 if (!m_hasPixels)
64 return Length(clampNumber(m_percent, range), Percent);
65 return Length(CalculationValue::create(PixelsAndPercent(m_pixels, m_percent) , range));
66 }
67
68 PassRefPtr<AnimatableValue> AnimatableLength::interpolateTo(const AnimatableValu e* value, double fraction) const
69 {
70 const AnimatableLength* length = toAnimatableLength(value);
71 return create(blend(m_pixels, length->m_pixels, fraction), blend(m_percent, length->m_percent, fraction),
72 m_hasPixels || length->m_hasPixels, m_hasPercent || length->m_hasPercent );
73 }
74
75 bool AnimatableLength::equalTo(const AnimatableValue* value) const
76 {
77 const AnimatableLength* length = toAnimatableLength(value);
78 return m_pixels == length->m_pixels && m_percent == length->m_percent && m_h asPixels == length->m_hasPixels && m_hasPercent == length->m_hasPercent;
79 }
80
81 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/animation/animatable/AnimatableLength.h ('k') | sky/engine/core/animation/animatable/AnimatableLengthBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698