#ifndef SVGNumber_h
#define SVGNumber_h
#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionStatePlaceholder.h"
#include "core/svg/properties/SVGProperty.h"
namespace WebCore {
class SVGNumberTearOff;
class SVGNumber : public SVGPropertyBase {
public:
typedef SVGNumberTearOff TearOffType;
typedef float PrimitiveType;
static PassRefPtr<SVGNumber> create(float value = 0.0f)
{
return adoptRef(new SVGNumber(value));
}
virtual PassRefPtr<SVGNumber> clone() const;
virtual PassRefPtr<SVGPropertyBase> cloneForAnimation(const String&) const OVERRIDE;
float value() const { return m_value; }
void setValue(float value) { m_value = value; }
virtual String valueAsString() const OVERRIDE;
virtual void setValueAsString(const String&, ExceptionState&);
virtual void add(PassRefPtr<SVGPropertyBase>, SVGElement*) OVERRIDE;
virtual void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase> from, PassRefPtr<SVGPropertyBase> to, PassRefPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement) OVERRIDE;
virtual float calculateDistance(PassRefPtr<SVGPropertyBase> to, SVGElement* contextElement) OVERRIDE;
static AnimatedPropertyType classType() { return AnimatedNumber; }
protected:
explicit SVGNumber(float);
template<typename CharType>
bool parse(const CharType*& ptr, const CharType* end);
float m_value;
};
inline PassRefPtr<SVGNumber> toSVGNumber(PassRefPtr<SVGPropertyBase> passBase)
{
RefPtr<SVGPropertyBase> base = passBase;
ASSERT(base->type() == SVGNumber::classType());
return static_pointer_cast<SVGNumber>(base.release());
}
class SVGNumberAcceptPercentage FINAL : public SVGNumber {
public:
static PassRefPtr<SVGNumberAcceptPercentage> create(float value = 0)
{
return adoptRef(new SVGNumberAcceptPercentage(value));
}
virtual PassRefPtr<SVGNumber> clone() const OVERRIDE;
virtual void setValueAsString(const String&, ExceptionState&) OVERRIDE;
private:
SVGNumberAcceptPercentage(float value);
};
}
#endif