OLD | NEW |
---|---|
(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 "config.h" | |
32 | |
Steve Block
2013/11/04 23:05:02
Superfluous blank line
mithro-old
2013/11/05 01:53:09
Done.
| |
33 #include "core/platform/animation/TimingFunctionTestHelper.h" | |
34 | |
35 #include <ostream> // NOLINT | |
36 | |
37 namespace WebCore { | |
38 | |
39 void PrintTo(const LinearTimingFunction& timefunction, ::std::ostream* os) | |
Steve Block
2013/11/04 23:05:02
s/timeFunction/timingFunction
mithro-old
2013/11/05 01:53:09
Done.
| |
40 { | |
41 *os << "LinearTimingFunction@" << &timefunction; | |
42 } | |
43 | |
44 void PrintTo(const CubicBezierTimingFunction& timefunction, ::std::ostream* os) | |
Steve Block
2013/11/04 23:05:02
Function and method names start with a lower case
mithro-old
2013/11/05 01:53:09
Don't get to control the name of this method. Set
| |
45 { | |
46 *os << "CubicBezierTimingFunction@" << &timefunction << "("; | |
47 switch (timefunction.subType()) { | |
48 case CubicBezierTimingFunction::Ease: | |
49 *os << "Ease"; | |
50 break; | |
51 case CubicBezierTimingFunction::EaseIn: | |
52 *os << "EaseIn"; | |
53 break; | |
54 case CubicBezierTimingFunction::EaseOut: | |
55 *os << "EaseOut"; | |
56 break; | |
57 case CubicBezierTimingFunction::EaseInOut: | |
58 *os << "EaseInOut"; | |
59 break; | |
60 case CubicBezierTimingFunction::Custom: | |
61 *os << "Custom"; | |
62 break; | |
63 default: | |
64 ASSERT_NOT_REACHED(); | |
65 } | |
66 *os << ", " << timefunction.x1(); | |
67 *os << ", " << timefunction.y1(); | |
68 *os << ", " << timefunction.x2(); | |
69 *os << ", " << timefunction.y2(); | |
70 *os << ")"; | |
71 } | |
72 | |
73 void PrintTo(const StepsTimingFunction& timefunction, ::std::ostream* os) | |
74 { | |
75 *os << "StepsTimingFunction@" << &timefunction << "("; | |
76 switch (timefunction.subType()) { | |
77 case StepsTimingFunction::Start: | |
78 *os << "Start"; | |
79 break; | |
80 case StepsTimingFunction::End: | |
81 *os << "End"; | |
82 break; | |
83 case StepsTimingFunction::Custom: | |
84 *os << "Custom"; | |
85 break; | |
86 default: | |
87 ASSERT_NOT_REACHED(); | |
88 } | |
89 *os << ", " << timefunction.numberOfSteps(); | |
90 *os << ", " << (timefunction.stepAtStart() ? "true" : "false"); | |
91 *os << ")"; | |
92 } | |
93 | |
94 class ChainedTimingFunctionPrintTo { | |
Steve Block
2013/11/04 23:05:02
Is ChainedTimingFunctionPrinter a better name?
mithro-old
2013/11/05 01:53:09
Done.
| |
95 private: | |
96 static void PrintTo(const ChainedTimingFunction& timefunction, ::std::ostrea m* os) | |
97 { | |
98 // Forward declare the generic PrintTo function as ChainedTimingFunction needs to call it. | |
99 void PrintTo(const TimingFunction&, ::std::ostream*); | |
100 | |
101 *os << "ChainedTimingFunction@" << &timefunction << "("; | |
102 for (size_t i = 0; i < timefunction.m_segments.size(); i++) { | |
103 ChainedTimingFunction::Segment segment = timefunction.m_segments[i]; | |
104 PrintTo(*(segment.m_timingFunction.get()), os); | |
105 *os << "[" << segment.m_min << " -> " << segment.m_max << "]"; | |
106 if (i+1 != timefunction.m_segments.size()) { | |
107 *os << ", "; | |
108 } | |
109 } | |
110 *os << ")"; | |
111 } | |
112 | |
113 friend void PrintTo(const ChainedTimingFunction&, ::std::ostream*); | |
114 }; | |
115 | |
116 void PrintTo(const ChainedTimingFunction& timefunction, ::std::ostream* os) | |
Steve Block
2013/11/04 23:05:02
Do we need this wrapper? Can the generic PrintTo()
mithro-old
2013/11/05 01:53:09
Yes, otherwise when you try and print a ChainedTim
| |
117 { | |
118 ChainedTimingFunctionPrintTo::PrintTo(timefunction, os); | |
119 } | |
120 | |
121 // The generic PrintTo *must* come after the non-generic PrintTo otherwise it | |
122 // will end up calling itself. | |
123 void PrintTo(const TimingFunction& timefunction, ::std::ostream* os) | |
124 { | |
125 switch (timefunction.type()) { | |
126 case TimingFunction::LinearFunction: { | |
127 const LinearTimingFunction* linear = static_cast<const LinearTimingFunct ion*>(&timefunction); | |
128 PrintTo(*linear, os); | |
129 return; | |
130 } | |
131 case TimingFunction::CubicBezierFunction: { | |
132 const CubicBezierTimingFunction* cubic = static_cast<const CubicBezierTi mingFunction*>(&timefunction); | |
133 PrintTo(*cubic, os); | |
134 return; | |
135 } | |
136 case TimingFunction::StepsFunction: { | |
137 const StepsTimingFunction* step = static_cast<const StepsTimingFunction* >(&timefunction); | |
138 PrintTo(*step, os); | |
139 return; | |
140 } | |
141 case TimingFunction::ChainedFunction: { | |
142 const ChainedTimingFunction* chained = static_cast<const ChainedTimingFu nction*>(&timefunction); | |
143 PrintTo(*chained, os); | |
144 return; | |
145 } | |
146 default: | |
147 ASSERT_NOT_REACHED(); | |
148 } | |
149 } | |
150 | |
151 } // namespace WebCore | |
OLD | NEW |