Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: Source/core/svg/SVGRect.h

Issue 132233010: [SVG] SVGAnimatedRect migration to new SVG property impl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebsaed Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/SVGPatternElement.cpp ('k') | Source/core/svg/SVGRect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/SVGPropertyTraits.h" 23 #include "core/svg/properties/NewSVGProperty.h"
24 #include "platform/geometry/FloatRect.h" 24 #include "platform/geometry/FloatRect.h"
25 #include "wtf/text/StringBuilder.h"
26 25
27 namespace WebCore { 26 namespace WebCore {
28 27
29 class SVGRect : public FloatRect { 28 class SVGRectTearOff;
29
30 class SVGRect : public NewSVGPropertyBase {
30 public: 31 public:
32 typedef SVGRectTearOff TearOffType;
33
31 struct InvalidSVGRectTag { }; 34 struct InvalidSVGRectTag { };
32 35
33 SVGRect() 36 static PassRefPtr<SVGRect> create()
34 : m_isValid(true) { } 37 {
35 SVGRect(InvalidSVGRectTag) 38 return adoptRef(new SVGRect());
36 : m_isValid(false) { } 39 }
37 SVGRect(const FloatRect& rect) 40
38 : FloatRect(rect), m_isValid(true) { } 41 static PassRefPtr<SVGRect> create(InvalidSVGRectTag)
39 SVGRect(const FloatPoint& location, const FloatSize& size) 42 {
40 : FloatRect(location, size), m_isValid(true) { } 43 return adoptRef(new SVGRect(InvalidSVGRectTag()));
41 SVGRect(float x, float y, float width, float height) 44 }
42 : FloatRect(x, y, width, height), m_isValid(true) { } 45
43 SVGRect(const IntRect& intRect) 46 static PassRefPtr<SVGRect> create(const FloatRect& rect)
44 : FloatRect(intRect), m_isValid(true) { } 47 {
45 SVGRect(const LayoutRect& layoutRect) 48 return adoptRef(new SVGRect(rect));
46 : FloatRect(layoutRect), m_isValid(true) { } 49 }
47 SVGRect(const SkRect& skRect) 50
48 : FloatRect(skRect), m_isValid(true) { } 51 PassRefPtr<SVGRect> clone() const;
52 virtual PassRefPtr<NewSVGPropertyBase> cloneForAnimation(const String&) cons t OVERRIDE;
53
54 const FloatRect& value() const { return m_value; }
55 void setValue(const FloatRect& v) { m_value = v; }
56
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); }
65
66 bool operator==(const SVGRect&) const;
67 bool operator!=(const SVGRect& other) const { return !operator==(other); }
68
69 virtual String valueAsString() const OVERRIDE;
70 void setValueAsString(const String&, ExceptionState&);
71
72 virtual void add(PassRefPtr<NewSVGPropertyBase>, SVGElement*) OVERRIDE;
73 virtual void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> from, PassRefPtr<NewSVGProp ertyBase> to, PassRefPtr<NewSVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement) OVERRIDE;
74 virtual float calculateDistance(PassRefPtr<NewSVGPropertyBase> to, SVGElemen t* contextElement) OVERRIDE;
49 75
50 bool isValid() const { return m_isValid; } 76 bool isValid() const { return m_isValid; }
77 void setInvalid();
78
79 static AnimatedPropertyType classType() { return AnimatedRect; }
51 80
52 private: 81 private:
82 SVGRect();
83 SVGRect(InvalidSVGRectTag);
84 SVGRect(const FloatRect&);
85
86 template<typename CharType>
87 void parse(const CharType*& ptr, const CharType* end, ExceptionState&);
88
53 bool m_isValid; 89 bool m_isValid;
90 FloatRect m_value;
54 }; 91 };
55 92
56 template<> 93 inline PassRefPtr<SVGRect> toSVGRect(PassRefPtr<NewSVGPropertyBase> passBase)
57 struct SVGPropertyTraits<SVGRect> { 94 {
58 static SVGRect initialValue() { return SVGRect(SVGRect::InvalidSVGRectTag()) ; } 95 RefPtr<NewSVGPropertyBase> base = passBase;
59 static String toString(const SVGRect& type) 96 ASSERT(base->type() == SVGRect::classType());
60 { 97 return static_pointer_cast<SVGRect>(base.release());
61 StringBuilder builder; 98 }
62 builder.append(String::number(type.x()));
63 builder.append(' ');
64 builder.append(String::number(type.y()));
65 builder.append(' ');
66 builder.append(String::number(type.width()));
67 builder.append(' ');
68 builder.append(String::number(type.height()));
69 return builder.toString();
70 }
71 };
72 99
73 } // namespace WebCore 100 } // namespace WebCore
74 101
75 #endif // SVGRect_h 102 #endif // SVGRect_h
OLDNEW
« no previous file with comments | « Source/core/svg/SVGPatternElement.cpp ('k') | Source/core/svg/SVGRect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698