#ifndef SVGRect_h
#define SVGRect_h
#include "core/svg/properties/SVGProperty.h"
#include "platform/geometry/FloatRect.h"
namespace WebCore {
class SVGRectTearOff;
class SVGRect : public SVGPropertyBase {
public:
typedef SVGRectTearOff TearOffType;
struct InvalidSVGRectTag { };
static PassRefPtr<SVGRect> create()
{
return adoptRef(new SVGRect());
}
static PassRefPtr<SVGRect> create(InvalidSVGRectTag)
{
return adoptRef(new SVGRect(InvalidSVGRectTag()));
}
static PassRefPtr<SVGRect> create(const FloatRect& rect)
{
return adoptRef(new SVGRect(rect));
}
PassRefPtr<SVGRect> clone() const;
virtual PassRefPtr<SVGPropertyBase> cloneForAnimation(const String&) const OVERRIDE;
const FloatRect& value() const { return m_value; }
void setValue(const FloatRect& v) { m_value = v; }
float x() const { return m_value.x(); }
float y() const { return m_value.y(); }
float width() const { return m_value.width(); }
float height() const { return m_value.height(); }
void setX(float f) { m_value.setX(f); }
void setY(float f) { m_value.setY(f); }
void setWidth(float f) { m_value.setWidth(f); }
void setHeight(float f) { m_value.setHeight(f); }
bool operator==(const SVGRect&) const;
bool operator!=(const SVGRect& other) const { return !operator==(other); }
virtual String valueAsString() const OVERRIDE;
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;
bool isValid() const { return m_isValid; }
void setInvalid();
static AnimatedPropertyType classType() { return AnimatedRect; }
private:
SVGRect();
SVGRect(InvalidSVGRectTag);
SVGRect(const FloatRect&);
template<typename CharType>
void parse(const CharType*& ptr, const CharType* end, ExceptionState&);
bool m_isValid;
FloatRect m_value;
};
inline PassRefPtr<SVGRect> toSVGRect(PassRefPtr<SVGPropertyBase> passBase)
{
RefPtr<SVGPropertyBase> base = passBase;
ASSERT(base->type() == SVGRect::classType());
return static_pointer_cast<SVGRect>(base.release());
}
}
#endif