2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
23 #include "core/svg/properties/SVGPropertyHelper.h"
24 #include "platform/geometry/FloatRect.h"
25 #include "wtf/Allocator.h"
31 class SVGRect
: public SVGPropertyHelper
<SVGRect
> {
33 typedef SVGRectTearOff TearOffType
;
35 static PassRefPtrWillBeRawPtr
<SVGRect
> create()
37 return adoptRefWillBeNoop(new SVGRect());
40 static PassRefPtrWillBeRawPtr
<SVGRect
> createInvalid()
42 RefPtrWillBeRawPtr
<SVGRect
> rect
= adoptRefWillBeNoop(new SVGRect());
44 return rect
.release();
47 static PassRefPtrWillBeRawPtr
<SVGRect
> create(const FloatRect
& rect
)
49 return adoptRefWillBeNoop(new SVGRect(rect
));
52 PassRefPtrWillBeRawPtr
<SVGRect
> clone() const;
54 const FloatRect
& value() const { return m_value
; }
55 void setValue(const FloatRect
& v
) { m_value
= v
; }
57 float x() const { return m_value
.x(); }
58 float y() const { return m_value
.y(); }
59 float width() const { return m_value
.width(); }
60 float height() const { return m_value
.height(); }
61 void setX(float f
) { m_value
.setX(f
); }
62 void setY(float f
) { m_value
.setY(f
); }
63 void setWidth(float f
) { m_value
.setWidth(f
); }
64 void setHeight(float f
) { m_value
.setHeight(f
); }
66 String
valueAsString() const override
;
67 void setValueAsString(const String
&, ExceptionState
&);
69 void add(PassRefPtrWillBeRawPtr
<SVGPropertyBase
>, SVGElement
*) override
;
70 void calculateAnimatedValue(SVGAnimationElement
*, float percentage
, unsigned repeatCount
, PassRefPtrWillBeRawPtr
<SVGPropertyBase
> from
, PassRefPtrWillBeRawPtr
<SVGPropertyBase
> to
, PassRefPtrWillBeRawPtr
<SVGPropertyBase
> toAtEndOfDurationValue
, SVGElement
* contextElement
) override
;
71 float calculateDistance(PassRefPtrWillBeRawPtr
<SVGPropertyBase
> to
, SVGElement
* contextElement
) override
;
73 bool isValid() const { return m_isValid
; }
76 static AnimatedPropertyType
classType() { return AnimatedRect
; }
80 SVGRect(const FloatRect
&);
82 template<typename CharType
>
83 void parse(const CharType
*& ptr
, const CharType
* end
, ExceptionState
&);
89 inline PassRefPtrWillBeRawPtr
<SVGRect
> toSVGRect(PassRefPtrWillBeRawPtr
<SVGPropertyBase
> passBase
)
91 RefPtrWillBeRawPtr
<SVGPropertyBase
> base
= passBase
;
92 ASSERT(base
->type() == SVGRect::classType());
93 return static_pointer_cast
<SVGRect
>(base
.release());