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 "core/animation/animatable/AnimatableValueTestHelper.h" | |
32 | |
33 namespace blink { | |
34 | |
35 bool operator==(const AnimatableValue& a, const AnimatableValue& b) { | |
36 return a.equals(b); | |
37 } | |
38 | |
39 void PrintTo(const AnimatableClipPathOperation& animValue, ::std::ostream* os) { | |
40 *os << "AnimatableClipPathOperation@" << &animValue; | |
41 } | |
42 | |
43 void PrintTo(const AnimatableColor& animColor, ::std::ostream* os) { | |
44 *os << "AnimatableColor(" << animColor.getColor().serialized().utf8().data() | |
45 << ", " << animColor.visitedLinkColor().serialized().utf8().data() << ")"; | |
46 } | |
47 | |
48 void PrintTo(const AnimatableImage& animImage, ::std::ostream* os) { | |
49 PrintTo(*(animImage.toCSSValue()), os, "AnimatableImage"); | |
50 } | |
51 | |
52 void PrintTo(const AnimatableNeutral& animValue, ::std::ostream* os) { | |
53 *os << "AnimatableNeutral@" << &animValue; | |
54 } | |
55 | |
56 void PrintTo(const AnimatablePath& animValue, ::std::ostream* os) { | |
57 *os << "AnimatablePath@" << &animValue; | |
58 } | |
59 | |
60 void PrintTo(const AnimatableRepeatable& animValue, ::std::ostream* os) { | |
61 *os << "AnimatableRepeatable("; | |
62 | |
63 const Vector<RefPtr<AnimatableValue>> v = animValue.values(); | |
64 for (Vector<RefPtr<AnimatableValue>>::const_iterator it = v.begin(); | |
65 it != v.end(); ++it) { | |
66 PrintTo(*(it->get()), os); | |
67 if (it + 1 != v.end()) | |
68 *os << ", "; | |
69 } | |
70 *os << ")"; | |
71 } | |
72 | |
73 void PrintTo(const AnimatableShapeValue& animValue, ::std::ostream* os) { | |
74 *os << "AnimatableShapeValue@" << &animValue; | |
75 } | |
76 | |
77 void PrintTo(const AnimatableStrokeDasharrayList& animValue, | |
78 ::std::ostream* os) { | |
79 *os << "AnimatableStrokeDasharrayList("; | |
80 RefPtr<SVGDashArray> list = animValue.toSVGDashArray(1); | |
81 size_t length = list->size(); | |
82 for (size_t i = 0; i < length; ++i) { | |
83 const Length& dashLength = list->at(i); | |
84 PixelsAndPercent pixelsAndPercent = dashLength.getPixelsAndPercent(); | |
85 *os << pixelsAndPercent.pixels << '+'; | |
86 *os << pixelsAndPercent.percent << '%'; | |
87 | |
88 if (i != length - 1) | |
89 *os << ", "; | |
90 } | |
91 *os << ")"; | |
92 } | |
93 | |
94 void PrintTo(const AnimatableTransform& animTransform, ::std::ostream* os) { | |
95 TransformOperations ops = animTransform.transformOperations(); | |
96 | |
97 *os << "AnimatableTransform("; | |
98 // FIXME: TransformOperations should really have it's own pretty-printer | |
99 // then we could just call that. | |
100 // FIXME: Output useful names not just the raw matrixes. | |
101 for (unsigned i = 0; i < ops.size(); i++) { | |
102 const TransformOperation* op = ops.at(i); | |
103 | |
104 TransformationMatrix matrix; | |
105 op->apply(matrix, FloatSize(1.0, 1.0)); | |
106 | |
107 *os << "["; | |
108 if (matrix.isAffine()) { | |
109 *os << matrix.a(); | |
110 *os << " " << matrix.b(); | |
111 *os << " " << matrix.c(); | |
112 *os << " " << matrix.d(); | |
113 *os << " " << matrix.e(); | |
114 *os << " " << matrix.f(); | |
115 } else { | |
116 *os << matrix.m11(); | |
117 *os << " " << matrix.m12(); | |
118 *os << " " << matrix.m13(); | |
119 *os << " " << matrix.m14(); | |
120 *os << " "; | |
121 *os << " " << matrix.m21(); | |
122 *os << " " << matrix.m22(); | |
123 *os << " " << matrix.m23(); | |
124 *os << " " << matrix.m24(); | |
125 *os << " "; | |
126 *os << " " << matrix.m31(); | |
127 *os << " " << matrix.m32(); | |
128 *os << " " << matrix.m33(); | |
129 *os << " " << matrix.m34(); | |
130 *os << " "; | |
131 *os << " " << matrix.m41(); | |
132 *os << " " << matrix.m42(); | |
133 *os << " " << matrix.m43(); | |
134 *os << " " << matrix.m44(); | |
135 } | |
136 *os << "]"; | |
137 if (i < ops.size() - 1) | |
138 *os << ", "; | |
139 } | |
140 *os << ")"; | |
141 } | |
142 | |
143 void PrintTo(const AnimatableUnknown& animUnknown, ::std::ostream* os) { | |
144 PrintTo(*(animUnknown.toCSSValue()), os, "AnimatableUnknown"); | |
145 } | |
146 | |
147 void PrintTo(const AnimatableVisibility& animVisibility, ::std::ostream* os) { | |
148 *os << "AnimatableVisibility("; | |
149 switch (animVisibility.visibility()) { | |
150 case EVisibility::kVisible: | |
151 *os << "EVisibility::kVisible"; | |
152 break; | |
153 case EVisibility::kHidden: | |
154 *os << "EVisibility::kHidden"; | |
155 break; | |
156 case EVisibility::kCollapse: | |
157 *os << "EVisibility::kCollapse"; | |
158 break; | |
159 default: | |
160 *os << "Unknown Visibility - update switch in " | |
161 "AnimatableValueTestHelper.h"; | |
162 } | |
163 *os << ")"; | |
164 } | |
165 | |
166 void PrintTo(const AnimatableValue& animValue, ::std::ostream* os) { | |
167 if (animValue.isClipPathOperation()) | |
168 PrintTo(toAnimatableClipPathOperation(animValue), os); | |
169 else if (animValue.isColor()) | |
170 PrintTo(toAnimatableColor(animValue), os); | |
171 else if (animValue.isImage()) | |
172 PrintTo(toAnimatableImage(animValue), os); | |
173 else if (animValue.isNeutral()) | |
174 PrintTo(static_cast<const AnimatableNeutral&>(animValue), os); | |
175 else if (animValue.isRepeatable()) | |
176 PrintTo(toAnimatableRepeatable(animValue), os); | |
177 else if (animValue.isSVGPaint()) | |
178 PrintTo(toAnimatableSVGPaint(animValue), os); | |
179 else if (animValue.isShapeValue()) | |
180 PrintTo(toAnimatableShapeValue(animValue), os); | |
181 else if (animValue.isStrokeDasharrayList()) | |
182 PrintTo(toAnimatableStrokeDasharrayList(animValue), os); | |
183 else if (animValue.isTransform()) | |
184 PrintTo(toAnimatableTransform(animValue), os); | |
185 else if (animValue.isUnknown()) | |
186 PrintTo(toAnimatableUnknown(animValue), os); | |
187 else if (animValue.isVisibility()) | |
188 PrintTo(toAnimatableVisibility(animValue), os); | |
189 else | |
190 *os << "Unknown AnimatableValue - update ifelse chain in " | |
191 "AnimatableValueTestHelper.h"; | |
192 } | |
193 | |
194 } // namespace blink | |
OLD | NEW |