2 * Copyright (c) 2013, Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
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.
33 #include "core/animation/AnimatableValueTestHelper.h"
39 bool operator==(const AnimatableValue& a, const AnimatableValue& b)
44 void PrintTo(const AnimatableClipPathOperation& animValue, ::std::ostream* os)
46 *os << "AnimatableClipPathOperation@" << &animValue;
49 void PrintTo(const AnimatableColor& animColor, ::std::ostream* os)
51 *os << "AnimatableColor("
52 << animColor.color().serialized().utf8().data() << ", "
53 << animColor.visitedLinkColor().serialized().utf8().data() << ")";
56 void PrintTo(const AnimatableDouble& animDouble, ::std::ostream* os)
58 PrintTo(*(animDouble.toCSSValue().get()), os, "AnimatableDouble");
61 void PrintTo(const AnimatableImage& animImage, ::std::ostream* os)
63 PrintTo(*(animImage.toCSSValue().get()), os, "AnimatableImage");
66 void PrintTo(const AnimatableLength& animLength, ::std::ostream* os)
68 PrintTo(*(animLength.toCSSValue().get()), os, "AnimatableLength");
71 void PrintTo(const AnimatableLengthBox& animLengthBox, ::std::ostream* os)
73 *os << "AnimatableLengthBox(";
74 PrintTo(*(animLengthBox.left()), os);
76 PrintTo(*(animLengthBox.right()), os);
78 PrintTo(*(animLengthBox.top()), os);
80 PrintTo(*(animLengthBox.bottom()), os);
84 void PrintTo(const AnimatableLengthPoint& animLengthPoint, ::std::ostream* os)
86 *os << "AnimatableLengthPoint(";
87 PrintTo(*(animLengthPoint.x()), os);
89 PrintTo(*(animLengthPoint.y()), os);
93 void PrintTo(const AnimatableLengthSize& animLengthSize, ::std::ostream* os)
95 *os << "AnimatableLengthSize(";
96 PrintTo(*(animLengthSize.width()), os);
98 PrintTo(*(animLengthSize.height()), os);
102 void PrintTo(const AnimatableNeutral& animValue, ::std::ostream* os)
104 *os << "AnimatableNeutral@" << &animValue;
107 void PrintTo(const AnimatableRepeatable& animValue, ::std::ostream* os)
109 *os << "AnimatableRepeatable(";
111 const Vector<RefPtr<AnimatableValue> > v = animValue.values();
112 for (Vector<RefPtr<AnimatableValue> >::const_iterator it = v.begin(); it != v.end(); ++it) {
113 PrintTo(*(it->get()), os);
120 void PrintTo(const AnimatableSVGLength& animSVGLength, ::std::ostream* os)
122 *os << "AnimatableSVGLength("
123 << animSVGLength.toSVGLength()->valueAsString().utf8().data() << ")";
126 void PrintTo(const AnimatableSVGPaint& animSVGPaint, ::std::ostream* os)
128 *os << "AnimatableSVGPaint(";
129 if (animSVGPaint.paintType() == SVGPaint::SVG_PAINTTYPE_RGBCOLOR)
130 *os << animSVGPaint.color().serialized().utf8().data();
131 else if (animSVGPaint.paintType() == SVGPaint::SVG_PAINTTYPE_URI)
132 *os << "url(" << animSVGPaint.uri().utf8().data() << ")";
134 *os << animSVGPaint.paintType();
138 void PrintTo(const AnimatableShapeValue& animValue, ::std::ostream* os)
140 *os << "AnimatableShapeValue@" << &animValue;
143 void PrintTo(const AnimatableStrokeDasharrayList& animValue, ::std::ostream* os)
145 *os << "AnimatableStrokeDasharrayList(";
146 RefPtr<SVGLengthList> list = animValue.toSVGLengthList();
147 size_t length = list->numberOfItems();
148 for (size_t i = 0; i < length; ++i) {
149 *os << list->at(i)->valueAsString().utf8().data();
156 void PrintTo(const AnimatableTransform& animTransform, ::std::ostream* os)
158 TransformOperations ops = animTransform.transformOperations();
160 *os << "AnimatableTransform(";
161 // FIXME: TransformOperations should really have it's own pretty-printer
162 // then we could just call that.
163 // FIXME: Output useful names not just the raw matrixes.
164 for (unsigned i = 0; i < ops.size(); i++) {
165 const TransformOperation* op = ops.at(i);
167 TransformationMatrix matrix;
168 op->apply(matrix, FloatSize(1.0, 1.0));
171 if (matrix.isAffine()) {
173 *os << " " << matrix.b();
174 *os << " " << matrix.c();
175 *os << " " << matrix.d();
176 *os << " " << matrix.e();
177 *os << " " << matrix.f();
180 *os << " " << matrix.m12();
181 *os << " " << matrix.m13();
182 *os << " " << matrix.m14();
184 *os << " " << matrix.m21();
185 *os << " " << matrix.m22();
186 *os << " " << matrix.m23();
187 *os << " " << matrix.m24();
189 *os << " " << matrix.m31();
190 *os << " " << matrix.m32();
191 *os << " " << matrix.m33();
192 *os << " " << matrix.m34();
194 *os << " " << matrix.m41();
195 *os << " " << matrix.m42();
196 *os << " " << matrix.m43();
197 *os << " " << matrix.m44();
200 if (i < ops.size() - 1)
206 void PrintTo(const AnimatableUnknown& animUnknown, ::std::ostream* os)
208 PrintTo(*(animUnknown.toCSSValue().get()), os, "AnimatableUnknown");
211 void PrintTo(const AnimatableVisibility& animVisibility, ::std::ostream* os)
213 *os << "AnimatableVisibility(";
214 switch (animVisibility.visibility()) {
225 *os << "Unknown Visbilility - update switch in AnimatableValueTestHelper.h";
230 void PrintTo(const AnimatableValue& animValue, ::std::ostream* os)
232 if (animValue.isClipPathOperation())
233 PrintTo(*(toAnimatableClipPathOperation(&animValue)), os);
234 else if (animValue.isColor())
235 PrintTo(*(toAnimatableColor(&animValue)), os);
236 else if (animValue.isDouble())
237 PrintTo(*(toAnimatableDouble(&animValue)), os);
238 else if (animValue.isImage())
239 PrintTo(*(toAnimatableImage(&animValue)), os);
240 else if (animValue.isLength())
241 PrintTo(*(toAnimatableLength(&animValue)), os);
242 else if (animValue.isLengthBox())
243 PrintTo(*(toAnimatableLengthBox(&animValue)), os);
244 else if (animValue.isLengthPoint())
245 PrintTo(*(toAnimatableLengthPoint(&animValue)), os);
246 else if (animValue.isLengthSize())
247 PrintTo(*(toAnimatableLengthSize(&animValue)), os);
248 else if (animValue.isNeutral())
249 PrintTo(*(static_cast<const AnimatableNeutral*>(&animValue)), os);
250 else if (animValue.isRepeatable())
251 PrintTo(*(toAnimatableRepeatable(&animValue)), os);
252 else if (animValue.isSVGLength())
253 PrintTo(*(toAnimatableSVGLength(&animValue)), os);
254 else if (animValue.isSVGPaint())
255 PrintTo(*(toAnimatableSVGPaint(&animValue)), os);
256 else if (animValue.isShapeValue())
257 PrintTo(*(toAnimatableShapeValue(&animValue)), os);
258 else if (animValue.isStrokeDasharrayList())
259 PrintTo(*(toAnimatableStrokeDasharrayList(&animValue)), os);
260 else if (animValue.isTransform())
261 PrintTo(*(toAnimatableTransform(&animValue)), os);
262 else if (animValue.isUnknown())
263 PrintTo(*(toAnimatableUnknown(&animValue)), os);
264 else if (animValue.isVisibility())
265 PrintTo(*(toAnimatableVisibility(&animValue)), os);
267 *os << "Unknown AnimatableValue - update ifelse chain in AnimatableValueTestHelper.h";
270 } // namespace WebCore