OSDN Git Service

Merge Webkit at r70949: Initial merge by git.
[android-x86/external-webkit.git] / WebCore / svg / DeprecatedSVGAnimatedPropertyTraits.h
1 /*
2  * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3  * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
4  *
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.
9  *
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.
14  *
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.
19  */
20
21 #ifndef DeprecatedSVGAnimatedPropertyTraits_h
22 #define DeprecatedSVGAnimatedPropertyTraits_h
23
24 #if ENABLE(SVG)
25 #include "PlatformString.h"
26 #include "SVGNumberList.h"
27 #include "SVGPreserveAspectRatio.h"
28 #include "SVGTransformList.h"
29
30 namespace WebCore {
31
32 template<typename Type>
33 struct DeprecatedSVGAnimatedPropertyTraits : public Noncopyable { };
34
35 // SVGAnimatedNumber
36 template<>
37 struct DeprecatedSVGAnimatedPropertyTraits<float> : public Noncopyable {
38     typedef const float& PassType;
39     typedef float ReturnType;
40     typedef float StoredType;
41
42     static ReturnType null() { return 0.0f; }
43     static ReturnType toReturnType(const StoredType& type) { return type; }
44     static String toString(PassType type) { return String::number(type); }
45 };
46
47 // SVGAnimatedNumberList
48 template<>
49 struct DeprecatedSVGAnimatedPropertyTraits<SVGNumberList*> : public Noncopyable {
50     typedef SVGNumberList* PassType;
51     typedef SVGNumberList* ReturnType;
52     typedef RefPtr<SVGNumberList> StoredType;
53
54     static ReturnType null() { return 0; }
55     static ReturnType toReturnType(const StoredType& type) { return type.get(); }
56     static String toString(PassType type) { return type ? type->valueAsString() : String(); }
57 };
58
59 // SVGAnimatedPreserveAspectRatio
60 template<>
61 struct DeprecatedSVGAnimatedPropertyTraits<SVGPreserveAspectRatio> : public Noncopyable {
62     typedef const SVGPreserveAspectRatio& PassType;
63     typedef SVGPreserveAspectRatio ReturnType;
64     typedef SVGPreserveAspectRatio StoredType;
65
66     static ReturnType null() { return SVGPreserveAspectRatio(); }
67     static ReturnType toReturnType(const StoredType& type) { return type; }
68     static String toString(PassType type) { return type.valueAsString(); }
69 };
70
71 // SVGAnimatedString
72 template<>
73 struct DeprecatedSVGAnimatedPropertyTraits<String> : public Noncopyable {
74     typedef const String& PassType;
75     typedef String ReturnType;
76     typedef String StoredType;
77
78     static ReturnType null() { return String(); }
79     static ReturnType toReturnType(const StoredType& type) { return type; }
80     static String toString(PassType type) { return type; }
81 };
82
83 // SVGAnimatedTransformList
84 template<>
85 struct DeprecatedSVGAnimatedPropertyTraits<SVGTransformList*> : public Noncopyable {
86     typedef SVGTransformList* PassType;
87     typedef SVGTransformList* ReturnType;
88     typedef RefPtr<SVGTransformList> StoredType;
89
90     static ReturnType null() { return 0; }
91     static ReturnType toReturnType(const StoredType& type) { return type.get(); }
92     static String toString(PassType type) { return type ? type->valueAsString() : String(); }
93 };
94
95 }
96
97 #endif
98 #endif