SVGAnimatedPropertyTraits.h [plain text]
#ifndef SVGAnimatedPropertyTraits_h
#define SVGAnimatedPropertyTraits_h
#if ENABLE(SVG)
#include "FloatRect.h"
#include "PlatformString.h"
#include "SVGAngle.h"
#include "SVGLength.h"
#include "SVGLengthList.h"
#include "SVGNumberList.h"
#include "SVGPreserveAspectRatio.h"
#include "SVGTransformList.h"
namespace WebCore {
template<typename Type>
struct SVGAnimatedPropertyTraits : public Noncopyable { };
template<>
struct SVGAnimatedPropertyTraits<SVGAngle> : public Noncopyable {
typedef const SVGAngle& PassType;
typedef SVGAngle ReturnType;
typedef SVGAngle StoredType;
static ReturnType null() { return SVGAngle(); }
static ReturnType toReturnType(const StoredType& type) { return type; }
static String toString(PassType type) { return type.valueAsString(); }
};
template<>
struct SVGAnimatedPropertyTraits<bool> : public Noncopyable {
typedef const bool& PassType;
typedef bool ReturnType;
typedef bool StoredType;
static ReturnType null() { return false; }
static ReturnType toReturnType(const StoredType& type) { return type; }
static String toString(PassType type) { return type ? "true" : "false"; }
};
template<>
struct SVGAnimatedPropertyTraits<int> : public Noncopyable {
typedef const int& PassType;
typedef int ReturnType;
typedef int StoredType;
static ReturnType null() { return 0; }
static ReturnType toReturnType(const StoredType& type) { return type; }
static String toString(PassType type) { return String::number(type); }
};
template<>
struct SVGAnimatedPropertyTraits<long> : public Noncopyable {
typedef const long& PassType;
typedef long ReturnType;
typedef long StoredType;
static ReturnType null() { return 0l; }
static ReturnType toReturnType(const StoredType& type) { return type; }
static String toString(PassType type) { return String::number(type); }
};
template<>
struct SVGAnimatedPropertyTraits<SVGLength> : public Noncopyable {
typedef const SVGLength& PassType;
typedef SVGLength ReturnType;
typedef SVGLength StoredType;
static ReturnType null() { return SVGLength(); }
static ReturnType toReturnType(const StoredType& type) { return type; }
static String toString(PassType type) { return type.valueAsString(); }
};
template<>
struct SVGAnimatedPropertyTraits<SVGLengthList*> : public Noncopyable {
typedef SVGLengthList* PassType;
typedef SVGLengthList* ReturnType;
typedef RefPtr<SVGLengthList> StoredType;
static ReturnType null() { return 0; }
static ReturnType toReturnType(const StoredType& type) { return type.get(); }
static String toString(PassType type) { return type ? type->valueAsString() : String(); }
};
template<>
struct SVGAnimatedPropertyTraits<float> : public Noncopyable {
typedef const float& PassType;
typedef float ReturnType;
typedef float StoredType;
static ReturnType null() { return 0.0f; }
static ReturnType toReturnType(const StoredType& type) { return type; }
static String toString(PassType type) { return String::number(type); }
};
template<>
struct SVGAnimatedPropertyTraits<SVGNumberList*> : public Noncopyable {
typedef SVGNumberList* PassType;
typedef SVGNumberList* ReturnType;
typedef RefPtr<SVGNumberList> StoredType;
static ReturnType null() { return 0; }
static ReturnType toReturnType(const StoredType& type) { return type.get(); }
static String toString(PassType type) { return type ? type->valueAsString() : String(); }
};
template<>
struct SVGAnimatedPropertyTraits<SVGPreserveAspectRatio> : public Noncopyable {
typedef const SVGPreserveAspectRatio& PassType;
typedef SVGPreserveAspectRatio ReturnType;
typedef SVGPreserveAspectRatio StoredType;
static ReturnType null() { return SVGPreserveAspectRatio(); }
static ReturnType toReturnType(const StoredType& type) { return type; }
static String toString(PassType type) { return type.valueAsString(); }
};
template<>
struct SVGAnimatedPropertyTraits<FloatRect> : public Noncopyable {
typedef const FloatRect& PassType;
typedef FloatRect ReturnType;
typedef FloatRect StoredType;
static ReturnType null() { return FloatRect(); }
static ReturnType toReturnType(const StoredType& type) { return type; }
static String toString(PassType type) { return String::format("%f %f %f %f", type.x(), type.y(), type.width(), type.height()); }
};
template<>
struct SVGAnimatedPropertyTraits<String> : public Noncopyable {
typedef const String& PassType;
typedef String ReturnType;
typedef String StoredType;
static ReturnType null() { return String(); }
static ReturnType toReturnType(const StoredType& type) { return type; }
static String toString(PassType type) { return type; }
};
template<>
struct SVGAnimatedPropertyTraits<SVGTransformList*> : public Noncopyable {
typedef SVGTransformList* PassType;
typedef SVGTransformList* ReturnType;
typedef RefPtr<SVGTransformList> StoredType;
static ReturnType null() { return 0; }
static ReturnType toReturnType(const StoredType& type) { return type.get(); }
static String toString(PassType type) { return type ? type->valueAsString() : String(); }
};
}
#endif
#endif