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

Side by Side Diff: Source/core/animation/animatable/AnimatableColor.cpp

Issue 928103002: Remove some unused functions in core (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: git cl try Created 5 years, 10 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
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 14 matching lines...) Expand all
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/animatable/AnimatableColor.h" 32 #include "core/animation/animatable/AnimatableColor.h"
33 33
34 #include "platform/animation/AnimationUtilities.h" 34 #include "platform/animation/AnimationUtilities.h"
35 #include "wtf/MathExtras.h"
36
37 namespace {
38
39 double square(double x)
40 {
41 return x * x;
42 }
43
44 } // namespace
45 35
46 namespace blink { 36 namespace blink {
47 37
48 AnimatableColorImpl::AnimatableColorImpl(float red, float green, float blue, flo at alpha) 38 AnimatableColorImpl::AnimatableColorImpl(float red, float green, float blue, flo at alpha)
49 : m_alpha(clampTo(alpha, 0.0f, 1.0f)) 39 : m_alpha(clampTo(alpha, 0.0f, 1.0f))
50 , m_red(clampTo(red, 0.0f, 1.0f)) 40 , m_red(clampTo(red, 0.0f, 1.0f))
51 , m_green(clampTo(green, 0.0f, 1.0f)) 41 , m_green(clampTo(green, 0.0f, 1.0f))
52 , m_blue(clampTo(blue, 0.0f, 1.0f)) 42 , m_blue(clampTo(blue, 0.0f, 1.0f))
53 { 43 {
54 } 44 }
(...skipping 22 matching lines...) Expand all
77 } 67 }
78 68
79 bool AnimatableColorImpl::operator==(const AnimatableColorImpl& other) const 69 bool AnimatableColorImpl::operator==(const AnimatableColorImpl& other) const
80 { 70 {
81 return m_red == other.m_red 71 return m_red == other.m_red
82 && m_green == other.m_green 72 && m_green == other.m_green
83 && m_blue == other.m_blue 73 && m_blue == other.m_blue
84 && m_alpha == other.m_alpha; 74 && m_alpha == other.m_alpha;
85 } 75 }
86 76
87 double AnimatableColorImpl::distanceTo(const AnimatableColorImpl& other) const
88 {
89 return sqrt(square(m_red - other.m_red)
90 + square(m_green - other.m_green)
91 + square(m_blue - other.m_blue)
92 + square(m_alpha - other.m_alpha));
93 }
94
95 PassRefPtrWillBeRawPtr<AnimatableColor> AnimatableColor::create(const Animatable ColorImpl& color, const AnimatableColorImpl& visitedLinkColor) 77 PassRefPtrWillBeRawPtr<AnimatableColor> AnimatableColor::create(const Animatable ColorImpl& color, const AnimatableColorImpl& visitedLinkColor)
96 { 78 {
97 return adoptRefWillBeNoop(new AnimatableColor(color, visitedLinkColor)); 79 return adoptRefWillBeNoop(new AnimatableColor(color, visitedLinkColor));
98 } 80 }
99 81
100 PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableColor::interpolateTo(const Ani matableValue* value, double fraction) const 82 PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableColor::interpolateTo(const Ani matableValue* value, double fraction) const
101 { 83 {
102 const AnimatableColor* color = toAnimatableColor(value); 84 const AnimatableColor* color = toAnimatableColor(value);
103 return create(m_color.interpolateTo(color->m_color, fraction), 85 return create(m_color.interpolateTo(color->m_color, fraction),
104 m_visitedLinkColor.interpolateTo(color->m_visitedLinkColor, fraction)); 86 m_visitedLinkColor.interpolateTo(color->m_visitedLinkColor, fraction));
105 } 87 }
106 88
107 bool AnimatableColor::equalTo(const AnimatableValue* value) const 89 bool AnimatableColor::equalTo(const AnimatableValue* value) const
108 { 90 {
109 const AnimatableColor* color = toAnimatableColor(value); 91 const AnimatableColor* color = toAnimatableColor(value);
110 return m_color == color->m_color && m_visitedLinkColor == color->m_visitedLi nkColor; 92 return m_color == color->m_color && m_visitedLinkColor == color->m_visitedLi nkColor;
111 } 93 }
112 94
113 double AnimatableColor::distanceTo(const AnimatableValue* value) const
114 {
115 const AnimatableColor* color = toAnimatableColor(value);
116 return m_color.distanceTo(color->m_color);
117 }
118
119 } // namespace blink 95 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/animation/animatable/AnimatableColor.h ('k') | Source/core/animation/animatable/AnimatableColorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698