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"
37 bool operator==(const AnimatableValue& a, const AnimatableValue& b)
42 void PrintTo(const AnimatableClipPathOperation& animValue, ::std::ostream* os)
44 *os << "AnimatableClipPathOperation@" << &animValue;
47 void PrintTo(const AnimatableColor& animColor, ::std::ostream* os)
49 *os << "AnimatableColor("
50 << animColor.color().serialized().utf8().data() << ", "
51 << animColor.visitedLinkColor().serialized().utf8().data() << ")";
54 void PrintTo(const AnimatableImage& animImage, ::std::ostream* os)
56 PrintTo(*(animImage.toCSSValue()), os, "AnimatableImage");
59 void PrintTo(const AnimatableNeutral& animValue, ::std::ostream* os)
61 *os << "AnimatableNeutral@" << &animValue;
64 void PrintTo(const AnimatableRepeatable& animValue, ::std::ostream* os)
66 *os << "AnimatableRepeatable(";
68 const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> > v = animValue.values();
69 for (WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >::const_iterator it = v.begin(); it != v.end(); ++it) {
70 PrintTo(*(it->get()), os);
77 void PrintTo(const AnimatableSVGLength& animSVGLength, ::std::ostream* os)
79 *os << "AnimatableSVGLength("
80 << animSVGLength.toSVGLength()->valueAsString().utf8().data() << ")";
83 void PrintTo(const AnimatableShapeValue& animValue, ::std::ostream* os)
85 *os << "AnimatableShapeValue@" << &animValue;
88 void PrintTo(const AnimatableStrokeDasharrayList& animValue, ::std::ostream* os)
90 *os << "AnimatableStrokeDasharrayList(";
91 RefPtr<SVGLengthList> list = animValue.toSVGLengthList();
92 size_t length = list->length();
93 for (size_t i = 0; i < length; ++i) {
94 *os << list->at(i)->valueAsString().utf8().data();
101 void PrintTo(const AnimatableTransform& animTransform, ::std::ostream* os)
103 TransformOperations ops = animTransform.transformOperations();
105 *os << "AnimatableTransform(";
106 // FIXME: TransformOperations should really have it's own pretty-printer
107 // then we could just call that.
108 // FIXME: Output useful names not just the raw matrixes.
109 for (unsigned i = 0; i < ops.size(); i++) {
110 const TransformOperation* op = ops.at(i);
112 TransformationMatrix matrix;
113 op->apply(matrix, FloatSize(1.0, 1.0));
116 if (matrix.isAffine()) {
118 *os << " " << matrix.b();
119 *os << " " << matrix.c();
120 *os << " " << matrix.d();
121 *os << " " << matrix.e();
122 *os << " " << matrix.f();
125 *os << " " << matrix.m12();
126 *os << " " << matrix.m13();
127 *os << " " << matrix.m14();
129 *os << " " << matrix.m21();
130 *os << " " << matrix.m22();
131 *os << " " << matrix.m23();
132 *os << " " << matrix.m24();
134 *os << " " << matrix.m31();
135 *os << " " << matrix.m32();
136 *os << " " << matrix.m33();
137 *os << " " << matrix.m34();
139 *os << " " << matrix.m41();
140 *os << " " << matrix.m42();
141 *os << " " << matrix.m43();
142 *os << " " << matrix.m44();
145 if (i < ops.size() - 1)
151 void PrintTo(const AnimatableUnknown& animUnknown, ::std::ostream* os)
153 PrintTo(*(animUnknown.toCSSValue().get()), os, "AnimatableUnknown");
156 void PrintTo(const AnimatableVisibility& animVisibility, ::std::ostream* os)
158 *os << "AnimatableVisibility(";
159 switch (animVisibility.visibility()) {
170 *os << "Unknown Visbilility - update switch in AnimatableValueTestHelper.h";
175 void PrintTo(const AnimatableValue& animValue, ::std::ostream* os)
177 if (animValue.isClipPathOperation())
178 PrintTo(*(toAnimatableClipPathOperation(&animValue)), os);
179 else if (animValue.isColor())
180 PrintTo(*(toAnimatableColor(&animValue)), os);
181 else if (animValue.isImage())
182 PrintTo(*(toAnimatableImage(&animValue)), os);
183 else if (animValue.isNeutral())
184 PrintTo(*(static_cast<const AnimatableNeutral*>(&animValue)), os);
185 else if (animValue.isRepeatable())
186 PrintTo(*(toAnimatableRepeatable(&animValue)), os);
187 else if (animValue.isSVGLength())
188 PrintTo(*(toAnimatableSVGLength(&animValue)), os);
189 else if (animValue.isSVGPaint())
190 PrintTo(*(toAnimatableSVGPaint(&animValue)), os);
191 else if (animValue.isShapeValue())
192 PrintTo(*(toAnimatableShapeValue(&animValue)), os);
193 else if (animValue.isStrokeDasharrayList())
194 PrintTo(*(toAnimatableStrokeDasharrayList(&animValue)), os);
195 else if (animValue.isTransform())
196 PrintTo(*(toAnimatableTransform(&animValue)), os);
197 else if (animValue.isUnknown())
198 PrintTo(*(toAnimatableUnknown(&animValue)), os);
199 else if (animValue.isVisibility())
200 PrintTo(*(toAnimatableVisibility(&animValue)), os);
202 *os << "Unknown AnimatableValue - update ifelse chain in AnimatableValueTestHelper.h";
205 } // namespace WebCore