| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 #ifndef SVGRect_h | 20 #ifndef SVGRect_h |
| 21 #define SVGRect_h | 21 #define SVGRect_h |
| 22 | 22 |
| 23 #include "core/svg/properties/NewSVGProperty.h" | 23 #include "core/svg/properties/SVGProperty.h" |
| 24 #include "platform/geometry/FloatRect.h" | 24 #include "platform/geometry/FloatRect.h" |
| 25 | 25 |
| 26 namespace WebCore { | 26 namespace WebCore { |
| 27 | 27 |
| 28 class SVGRectTearOff; | 28 class SVGRectTearOff; |
| 29 | 29 |
| 30 class SVGRect : public NewSVGPropertyBase { | 30 class SVGRect : public SVGPropertyBase { |
| 31 public: | 31 public: |
| 32 typedef SVGRectTearOff TearOffType; | 32 typedef SVGRectTearOff TearOffType; |
| 33 | 33 |
| 34 struct InvalidSVGRectTag { }; | 34 struct InvalidSVGRectTag { }; |
| 35 | 35 |
| 36 static PassRefPtr<SVGRect> create() | 36 static PassRefPtr<SVGRect> create() |
| 37 { | 37 { |
| 38 return adoptRef(new SVGRect()); | 38 return adoptRef(new SVGRect()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 static PassRefPtr<SVGRect> create(InvalidSVGRectTag) | 41 static PassRefPtr<SVGRect> create(InvalidSVGRectTag) |
| 42 { | 42 { |
| 43 return adoptRef(new SVGRect(InvalidSVGRectTag())); | 43 return adoptRef(new SVGRect(InvalidSVGRectTag())); |
| 44 } | 44 } |
| 45 | 45 |
| 46 static PassRefPtr<SVGRect> create(const FloatRect& rect) | 46 static PassRefPtr<SVGRect> create(const FloatRect& rect) |
| 47 { | 47 { |
| 48 return adoptRef(new SVGRect(rect)); | 48 return adoptRef(new SVGRect(rect)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 PassRefPtr<SVGRect> clone() const; | 51 PassRefPtr<SVGRect> clone() const; |
| 52 virtual PassRefPtr<NewSVGPropertyBase> cloneForAnimation(const String&) cons
t OVERRIDE; | 52 virtual PassRefPtr<SVGPropertyBase> cloneForAnimation(const String&) const O
VERRIDE; |
| 53 | 53 |
| 54 const FloatRect& value() const { return m_value; } | 54 const FloatRect& value() const { return m_value; } |
| 55 void setValue(const FloatRect& v) { m_value = v; } | 55 void setValue(const FloatRect& v) { m_value = v; } |
| 56 | 56 |
| 57 float x() const { return m_value.x(); } | 57 float x() const { return m_value.x(); } |
| 58 float y() const { return m_value.y(); } | 58 float y() const { return m_value.y(); } |
| 59 float width() const { return m_value.width(); } | 59 float width() const { return m_value.width(); } |
| 60 float height() const { return m_value.height(); } | 60 float height() const { return m_value.height(); } |
| 61 void setX(float f) { m_value.setX(f); } | 61 void setX(float f) { m_value.setX(f); } |
| 62 void setY(float f) { m_value.setY(f); } | 62 void setY(float f) { m_value.setY(f); } |
| 63 void setWidth(float f) { m_value.setWidth(f); } | 63 void setWidth(float f) { m_value.setWidth(f); } |
| 64 void setHeight(float f) { m_value.setHeight(f); } | 64 void setHeight(float f) { m_value.setHeight(f); } |
| 65 | 65 |
| 66 bool operator==(const SVGRect&) const; | 66 bool operator==(const SVGRect&) const; |
| 67 bool operator!=(const SVGRect& other) const { return !operator==(other); } | 67 bool operator!=(const SVGRect& other) const { return !operator==(other); } |
| 68 | 68 |
| 69 virtual String valueAsString() const OVERRIDE; | 69 virtual String valueAsString() const OVERRIDE; |
| 70 void setValueAsString(const String&, ExceptionState&); | 70 void setValueAsString(const String&, ExceptionState&); |
| 71 | 71 |
| 72 virtual void add(PassRefPtr<NewSVGPropertyBase>, SVGElement*) OVERRIDE; | 72 virtual void add(PassRefPtr<SVGPropertyBase>, SVGElement*) OVERRIDE; |
| 73 virtual void calculateAnimatedValue(SVGAnimationElement*, float percentage,
unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> from, PassRefPtr<NewSVGProp
ertyBase> to, PassRefPtr<NewSVGPropertyBase> toAtEndOfDurationValue, SVGElement*
contextElement) OVERRIDE; | 73 virtual void calculateAnimatedValue(SVGAnimationElement*, float percentage,
unsigned repeatCount, PassRefPtr<SVGPropertyBase> from, PassRefPtr<SVGPropertyBa
se> to, PassRefPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextE
lement) OVERRIDE; |
| 74 virtual float calculateDistance(PassRefPtr<NewSVGPropertyBase> to, SVGElemen
t* contextElement) OVERRIDE; | 74 virtual float calculateDistance(PassRefPtr<SVGPropertyBase> to, SVGElement*
contextElement) OVERRIDE; |
| 75 | 75 |
| 76 bool isValid() const { return m_isValid; } | 76 bool isValid() const { return m_isValid; } |
| 77 void setInvalid(); | 77 void setInvalid(); |
| 78 | 78 |
| 79 static AnimatedPropertyType classType() { return AnimatedRect; } | 79 static AnimatedPropertyType classType() { return AnimatedRect; } |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 SVGRect(); | 82 SVGRect(); |
| 83 SVGRect(InvalidSVGRectTag); | 83 SVGRect(InvalidSVGRectTag); |
| 84 SVGRect(const FloatRect&); | 84 SVGRect(const FloatRect&); |
| 85 | 85 |
| 86 template<typename CharType> | 86 template<typename CharType> |
| 87 void parse(const CharType*& ptr, const CharType* end, ExceptionState&); | 87 void parse(const CharType*& ptr, const CharType* end, ExceptionState&); |
| 88 | 88 |
| 89 bool m_isValid; | 89 bool m_isValid; |
| 90 FloatRect m_value; | 90 FloatRect m_value; |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 inline PassRefPtr<SVGRect> toSVGRect(PassRefPtr<NewSVGPropertyBase> passBase) | 93 inline PassRefPtr<SVGRect> toSVGRect(PassRefPtr<SVGPropertyBase> passBase) |
| 94 { | 94 { |
| 95 RefPtr<NewSVGPropertyBase> base = passBase; | 95 RefPtr<SVGPropertyBase> base = passBase; |
| 96 ASSERT(base->type() == SVGRect::classType()); | 96 ASSERT(base->type() == SVGRect::classType()); |
| 97 return static_pointer_cast<SVGRect>(base.release()); | 97 return static_pointer_cast<SVGRect>(base.release()); |
| 98 } | 98 } |
| 99 | 99 |
| 100 } // namespace WebCore | 100 } // namespace WebCore |
| 101 | 101 |
| 102 #endif // SVGRect_h | 102 #endif // SVGRect_h |
| OLD | NEW |