2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #ifndef SVGPropertyTraits_h
22 #define SVGPropertyTraits_h
25 #include "FloatRect.h"
27 #include "SVGLength.h"
28 #include "SVGLengthList.h"
29 #include "SVGPreserveAspectRatio.h"
30 #include <wtf/text/StringBuilder.h>
34 template<typename PropertyType>
35 struct SVGPropertyTraits { };
38 struct SVGPropertyTraits<SVGAngle> {
39 static SVGAngle initialValue() { return SVGAngle(); }
40 static String toString(const SVGAngle& type) { return type.valueAsString(); }
44 struct SVGPropertyTraits<bool> {
45 static bool initialValue() { return false; }
46 static String toString(bool type) { return type ? "true" : "false"; }
50 struct SVGPropertyTraits<int> {
51 static int initialValue() { return 0; }
52 static String toString(int type) { return String::number(type); }
56 struct SVGPropertyTraits<long> {
57 static long initialValue() { return 0; }
58 static String toString(long type) { return String::number(type); }
62 struct SVGPropertyTraits<SVGLength> {
63 static SVGLength initialValue() { return SVGLength(); }
64 static String toString(const SVGLength& type) { return type.valueAsString(); }
68 struct SVGPropertyTraits<SVGLengthList> {
69 typedef SVGLength ListItemType;
71 static SVGLengthList initialValue() { return SVGLengthList(); }
72 static String toString(const SVGLengthList& type) { return type.valueAsString(); }
76 struct SVGPropertyTraits<float> {
77 static float initialValue() { return 0; }
78 static String toString(float type) { return String::number(type); }
82 struct SVGPropertyTraits<SVGPreserveAspectRatio> {
83 static SVGPreserveAspectRatio initialValue() { return SVGPreserveAspectRatio(); }
84 static String toString(const SVGPreserveAspectRatio& type) { return type.valueAsString(); }
88 struct SVGPropertyTraits<FloatRect> {
89 static FloatRect initialValue() { return FloatRect(); }
90 static String toString(const FloatRect& type)
92 StringBuilder builder;
93 builder.append(String::number(type.x()));
95 builder.append(String::number(type.y()));
97 builder.append(String::number(type.width()));
99 builder.append(String::number(type.height()));
101 return builder.toString();
106 struct SVGPropertyTraits<String> {
107 static String initialValue() { return String(); }
108 static String toString(const String& type) { return type; }