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 | |
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, bool recursiveGuard) | |
40 { | |
41 *os << "LinearTimingFunction@" << &timefunction; | |
42 } | |
43 | |
44 void PrintTo(const CubicBezierTimingFunction& timefunction, ::std::ostream* os, bool recursiveGuard) | |
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, bool r ecursiveGuard) | |
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 void PrintTo(const ChainedTimingFunction& timefunction, ::std::ostream* os, bool recursiveGuard) | |
95 { | |
96 // Forward declare the generic PrintTo function as ChainedTimingFunction nee ds to call it. | |
97 void PrintTo(const TimingFunction&, ::std::ostream*, bool); | |
98 | |
99 *os << "ChainedTimingFunction@" << &timefunction << "("; | |
100 for (size_t i = 0; i < timefunction.m_segments.size(); i++) { | |
101 ChainedTimingFunction::Segment segment = timefunction.m_segments[i]; | |
102 PrintTo(*(segment.m_timingFunction.get()), os, false); | |
103 *os << "[" << segment.m_min << " -> " << segment.m_max << "]"; | |
104 if (i+1 != timefunction.m_segments.size()) { | |
105 *os << ", "; | |
106 } | |
107 } | |
108 *os << ")"; | |
109 } | |
110 | |
111 // The generic PrintTo *must* come after the non-generic PrintTo otherwise it | |
112 // will end up calling itself. | |
113 void PrintTo(const TimingFunction& timefunction, ::std::ostream* os, bool recurs iveGuard) | |
114 { | |
115 // This guards against the generic PrintTo accidentally calling itself. | |
116 ASSERT(!recursiveGuard); | |
Steve Block
2013/11/03 09:18:32
I don't really like the idea of adding a param to
mithro-old
2013/11/03 09:58:24
I can remove it if you feel strongly about it. Sin
Steve Block
2013/11/03 23:29:44
ASSERT()s are only compiled in debug builds, and r
| |
117 | |
118 switch (timefunction.type()) { | |
119 case TimingFunction::LinearFunction: { | |
120 const LinearTimingFunction* linear = static_cast<const LinearTimingFunct ion*>(&timefunction); | |
121 PrintTo(*linear, os, true); | |
122 return; | |
123 } | |
124 case TimingFunction::CubicBezierFunction: { | |
125 const CubicBezierTimingFunction* cubic = static_cast<const CubicBezierTi mingFunction*>(&timefunction); | |
126 PrintTo(*cubic, os, true); | |
127 return; | |
128 } | |
129 case TimingFunction::StepsFunction: { | |
130 const StepsTimingFunction* step = static_cast<const StepsTimingFunction* >(&timefunction); | |
131 PrintTo(*step, os, true); | |
132 return; | |
133 } | |
134 case TimingFunction::ChainedFunction: { | |
135 const ChainedTimingFunction* chained = static_cast<const ChainedTimingFu nction*>(&timefunction); | |
136 PrintTo(*chained, os, true); | |
137 return; | |
138 } | |
139 default: | |
140 ASSERT_NOT_REACHED(); | |
141 } | |
142 | |
143 } | |
144 | |
145 } // namespace WebCore | |
OLD | NEW |