11e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)/* 21e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * Copyright (c) 2013, Google Inc. All rights reserved. 31e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * 41e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * Redistribution and use in source and binary forms, with or without 51e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * modification, are permitted provided that the following conditions are 61e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * met: 71e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * 81e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * * Redistributions of source code must retain the above copyright 91e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * notice, this list of conditions and the following disclaimer. 101e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * * Redistributions in binary form must reproduce the above 111e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer 121e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * in the documentation and/or other materials provided with the 131e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * distribution. 141e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * * Neither the name of Google Inc. nor the names of its 151e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * contributors may be used to endorse or promote products derived from 161e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * this software without specific prior written permission. 171e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * 181e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 191e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 201e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 211e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 221e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 231e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 241e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 251e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 261e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 271e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 281e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 291e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) */ 301e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 311e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "config.h" 321e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 33197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "core/animation/animatable/AnimatableValueTestHelper.h" 341e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 35c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink { 361e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 371e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)bool operator==(const AnimatableValue& a, const AnimatableValue& b) 381e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){ 391e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) return a.equals(b); 401e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)} 411e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 421e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)void PrintTo(const AnimatableClipPathOperation& animValue, ::std::ostream* os) 431e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){ 441e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << "AnimatableClipPathOperation@" << &animValue; 451e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)} 461e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 471e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)void PrintTo(const AnimatableColor& animColor, ::std::ostream* os) 481e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){ 491e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << "AnimatableColor(" 501e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) << animColor.color().serialized().utf8().data() << ", " 511e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) << animColor.visitedLinkColor().serialized().utf8().data() << ")"; 521e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)} 531e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 541e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)void PrintTo(const AnimatableImage& animImage, ::std::ostream* os) 551e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){ 5643e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) PrintTo(*(animImage.toCSSValue()), os, "AnimatableImage"); 571e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)} 581e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 591e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)void PrintTo(const AnimatableNeutral& animValue, ::std::ostream* os) 601e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){ 611e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << "AnimatableNeutral@" << &animValue; 621e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)} 631e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 641e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)void PrintTo(const AnimatableRepeatable& animValue, ::std::ostream* os) 651e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){ 661e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << "AnimatableRepeatable("; 671e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 6807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> > v = animValue.values(); 6907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch for (WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >::const_iterator it = v.begin(); it != v.end(); ++it) { 701e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) PrintTo(*(it->get()), os); 711e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) if (it+1 != v.end()) 721e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << ", "; 731e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) } 741e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << ")"; 751e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)} 761e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 771e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)void PrintTo(const AnimatableSVGLength& animSVGLength, ::std::ostream* os) 781e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){ 791e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << "AnimatableSVGLength(" 8009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) << animSVGLength.toSVGLength()->valueAsString().utf8().data() << ")"; 811e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)} 821e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 831e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)void PrintTo(const AnimatableShapeValue& animValue, ::std::ostream* os) 841e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){ 851e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << "AnimatableShapeValue@" << &animValue; 861e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)} 871e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 881e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)void PrintTo(const AnimatableStrokeDasharrayList& animValue, ::std::ostream* os) 891e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){ 901e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << "AnimatableStrokeDasharrayList("; 9109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) RefPtr<SVGLengthList> list = animValue.toSVGLengthList(); 92d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) size_t length = list->length(); 9309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) for (size_t i = 0; i < length; ++i) { 9409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) *os << list->at(i)->valueAsString().utf8().data(); 9509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) if (i != length-1) 961e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << ", "; 971e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) } 981e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << ")"; 991e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)} 1001e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 1011e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)void PrintTo(const AnimatableTransform& animTransform, ::std::ostream* os) 1021e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){ 1031e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) TransformOperations ops = animTransform.transformOperations(); 1041e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 1051e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << "AnimatableTransform("; 1061e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) // FIXME: TransformOperations should really have it's own pretty-printer 1071e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) // then we could just call that. 1081e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) // FIXME: Output useful names not just the raw matrixes. 1091e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) for (unsigned i = 0; i < ops.size(); i++) { 1101e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) const TransformOperation* op = ops.at(i); 1111e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 1121e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) TransformationMatrix matrix; 1131e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) op->apply(matrix, FloatSize(1.0, 1.0)); 1141e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 1151e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << "["; 1161e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) if (matrix.isAffine()) { 1171e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << matrix.a(); 1181e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.b(); 1191e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.c(); 1201e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.d(); 1211e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.e(); 1221e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.f(); 1231e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) } else { 1241e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << matrix.m11(); 1251e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.m12(); 1261e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.m13(); 1271e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.m14(); 1281e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " "; 1291e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.m21(); 1301e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.m22(); 1311e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.m23(); 1321e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.m24(); 1331e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " "; 1341e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.m31(); 1351e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.m32(); 1361e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.m33(); 1371e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.m34(); 1381e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " "; 1391e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.m41(); 1401e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.m42(); 1411e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.m43(); 1421e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << " " << matrix.m44(); 1431e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) } 1441e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << "]"; 1451e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) if (i < ops.size() - 1) 1461e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << ", "; 1471e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) } 1481e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << ")"; 1491e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)} 1501e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 1511e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)void PrintTo(const AnimatableUnknown& animUnknown, ::std::ostream* os) 1521e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){ 1531e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) PrintTo(*(animUnknown.toCSSValue().get()), os, "AnimatableUnknown"); 1541e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)} 1551e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 1561e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)void PrintTo(const AnimatableVisibility& animVisibility, ::std::ostream* os) 1571e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){ 1581e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << "AnimatableVisibility("; 1591e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) switch (animVisibility.visibility()) { 1601e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) case VISIBLE: 1611e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << "VISIBLE"; 1621e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) break; 1631e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) case HIDDEN: 1641e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << "HIDDEN"; 1651e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) break; 1661e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) case COLLAPSE: 1671e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << "COLLAPSE"; 1681e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) break; 1691e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) default: 1701e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << "Unknown Visbilility - update switch in AnimatableValueTestHelper.h"; 1711e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) } 1721e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << ")"; 1731e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)} 1741e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 1751e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)void PrintTo(const AnimatableValue& animValue, ::std::ostream* os) 1761e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles){ 1771e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) if (animValue.isClipPathOperation()) 178197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch PrintTo(toAnimatableClipPathOperation(animValue), os); 1791e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) else if (animValue.isColor()) 180197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch PrintTo(toAnimatableColor(animValue), os); 1811e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) else if (animValue.isImage()) 182197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch PrintTo(toAnimatableImage(animValue), os); 1831e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) else if (animValue.isNeutral()) 184197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch PrintTo(static_cast<const AnimatableNeutral&>(animValue), os); 1851e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) else if (animValue.isRepeatable()) 186197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch PrintTo(toAnimatableRepeatable(animValue), os); 1871e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) else if (animValue.isSVGLength()) 188197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch PrintTo(toAnimatableSVGLength(animValue), os); 1891e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) else if (animValue.isSVGPaint()) 190197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch PrintTo(toAnimatableSVGPaint(animValue), os); 1911e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) else if (animValue.isShapeValue()) 192197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch PrintTo(toAnimatableShapeValue(animValue), os); 1931e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) else if (animValue.isStrokeDasharrayList()) 194197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch PrintTo(toAnimatableStrokeDasharrayList(animValue), os); 1951e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) else if (animValue.isTransform()) 196197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch PrintTo(toAnimatableTransform(animValue), os); 1971e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) else if (animValue.isUnknown()) 198197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch PrintTo(toAnimatableUnknown(animValue), os); 1991e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) else if (animValue.isVisibility()) 200197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch PrintTo(toAnimatableVisibility(animValue), os); 2011e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) else 2021e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) *os << "Unknown AnimatableValue - update ifelse chain in AnimatableValueTestHelper.h"; 2031e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)} 2041e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 205c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink 206