OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef SVGPathSegList_h | 31 #ifndef SVGPathSegList_h |
32 #define SVGPathSegList_h | 32 #define SVGPathSegList_h |
33 | 33 |
34 #include "core/svg/SVGPathByteStream.h" | 34 #include "core/svg/SVGPathByteStream.h" |
35 #include "core/svg/SVGPathSeg.h" | 35 #include "core/svg/SVGPathSeg.h" |
36 #include "core/svg/properties/NewSVGAnimatedProperty.h" | 36 #include "core/svg/properties/SVGAnimatedProperty.h" |
37 #include "core/svg/properties/NewSVGListPropertyHelper.h" | 37 #include "core/svg/properties/SVGListPropertyHelper.h" |
38 #include "wtf/WeakPtr.h" | 38 #include "wtf/WeakPtr.h" |
39 | 39 |
40 namespace WebCore { | 40 namespace WebCore { |
41 | 41 |
42 class SVGPathElement; | 42 class SVGPathElement; |
43 class SVGPathSegListTearOff; | 43 class SVGPathSegListTearOff; |
44 | 44 |
45 class SVGPathSegList : public NewSVGListPropertyHelper<SVGPathSegList, SVGPathSe
g> { | 45 class SVGPathSegList : public SVGListPropertyHelper<SVGPathSegList, SVGPathSeg>
{ |
46 public: | 46 public: |
47 typedef void PrimitiveType; | 47 typedef void PrimitiveType; |
48 typedef SVGPathSeg ItemPropertyType; | 48 typedef SVGPathSeg ItemPropertyType; |
49 typedef SVGPathSegListTearOff TearOffType; | 49 typedef SVGPathSegListTearOff TearOffType; |
50 typedef NewSVGListPropertyHelper<SVGPathSegList, SVGPathSeg> Base; | 50 typedef SVGListPropertyHelper<SVGPathSegList, SVGPathSeg> Base; |
51 | 51 |
52 static PassRefPtr<SVGPathSegList> create(SVGPathElement* contextElement, SVG
PathSegRole role = PathSegUndefinedRole) | 52 static PassRefPtr<SVGPathSegList> create(SVGPathElement* contextElement, SVG
PathSegRole role = PathSegUndefinedRole) |
53 { | 53 { |
54 return adoptRef(new SVGPathSegList(contextElement, role)); | 54 return adoptRef(new SVGPathSegList(contextElement, role)); |
55 } | 55 } |
56 | 56 |
57 virtual ~SVGPathSegList(); | 57 virtual ~SVGPathSegList(); |
58 | 58 |
59 const SVGPathByteStream* byteStream() const; | 59 const SVGPathByteStream* byteStream() const; |
60 void clearByteStream() { m_byteStream.clear(); } | 60 void clearByteStream() { m_byteStream.clear(); } |
61 | 61 |
62 // NewSVGListPropertyHelper methods with |m_byteStream| sync: | 62 // SVGListPropertyHelper methods with |m_byteStream| sync: |
63 | 63 |
64 ItemPropertyType* at(size_t index) | 64 ItemPropertyType* at(size_t index) |
65 { | 65 { |
66 updateListFromByteStream(); | 66 updateListFromByteStream(); |
67 return Base::at(index); | 67 return Base::at(index); |
68 } | 68 } |
69 | 69 |
70 size_t length() | 70 size_t length() |
71 { | 71 { |
72 updateListFromByteStream(); | 72 updateListFromByteStream(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 122 |
123 PassRefPtr<ItemPropertyType> removeItem(size_t index, ExceptionState& except
ionState) | 123 PassRefPtr<ItemPropertyType> removeItem(size_t index, ExceptionState& except
ionState) |
124 { | 124 { |
125 updateListFromByteStream(); | 125 updateListFromByteStream(); |
126 clearByteStream(); | 126 clearByteStream(); |
127 return Base::removeItem(index, exceptionState); | 127 return Base::removeItem(index, exceptionState); |
128 } | 128 } |
129 | 129 |
130 PassRefPtr<ItemPropertyType> appendItem(PassRefPtr<ItemPropertyType> passIte
m); | 130 PassRefPtr<ItemPropertyType> appendItem(PassRefPtr<ItemPropertyType> passIte
m); |
131 | 131 |
132 // NewSVGPropertyBase: | 132 // SVGPropertyBase: |
133 PassRefPtr<SVGPathSegList> clone(); | 133 PassRefPtr<SVGPathSegList> clone(); |
134 virtual PassRefPtr<NewSVGPropertyBase> cloneForAnimation(const String&) cons
t OVERRIDE; | 134 virtual PassRefPtr<SVGPropertyBase> cloneForAnimation(const String&) const O
VERRIDE; |
135 virtual String valueAsString() const OVERRIDE; | 135 virtual String valueAsString() const OVERRIDE; |
136 void setValueAsString(const String&, ExceptionState&); | 136 void setValueAsString(const String&, ExceptionState&); |
137 | 137 |
138 virtual void add(PassRefPtr<NewSVGPropertyBase>, SVGElement*) OVERRIDE; | 138 virtual void add(PassRefPtr<SVGPropertyBase>, SVGElement*) OVERRIDE; |
139 virtual void calculateAnimatedValue(SVGAnimationElement*, float percentage,
unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> fromValue, PassRefPtr<NewSV
GPropertyBase> toValue, PassRefPtr<NewSVGPropertyBase> toAtEndOfDurationValue, S
VGElement*) OVERRIDE; | 139 virtual void calculateAnimatedValue(SVGAnimationElement*, float percentage,
unsigned repeatCount, PassRefPtr<SVGPropertyBase> fromValue, PassRefPtr<SVGPrope
rtyBase> toValue, PassRefPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement
*) OVERRIDE; |
140 virtual float calculateDistance(PassRefPtr<NewSVGPropertyBase> to, SVGElemen
t*) OVERRIDE; | 140 virtual float calculateDistance(PassRefPtr<SVGPropertyBase> to, SVGElement*)
OVERRIDE; |
141 | 141 |
142 static AnimatedPropertyType classType() { return AnimatedPath; } | 142 static AnimatedPropertyType classType() { return AnimatedPath; } |
143 | 143 |
144 private: | 144 private: |
145 SVGPathSegList(SVGPathElement*, SVGPathSegRole); | 145 SVGPathSegList(SVGPathElement*, SVGPathSegRole); |
146 SVGPathSegList(SVGPathElement*, SVGPathSegRole, PassOwnPtr<SVGPathByteStream
>); | 146 SVGPathSegList(SVGPathElement*, SVGPathSegRole, PassOwnPtr<SVGPathByteStream
>); |
147 | 147 |
148 friend class SVGPathSegListBuilder; | 148 friend class SVGPathSegListBuilder; |
149 // This is only to be called from SVGPathSegListBuilder. | 149 // This is only to be called from SVGPathSegListBuilder. |
150 void appendWithoutByteStreamSync(PassRefPtr<ItemPropertyType> passNewItem) | 150 void appendWithoutByteStreamSync(PassRefPtr<ItemPropertyType> passNewItem) |
151 { | 151 { |
152 Base::append(passNewItem); | 152 Base::append(passNewItem); |
153 } | 153 } |
154 | 154 |
155 void updateListFromByteStream(); | 155 void updateListFromByteStream(); |
156 void invalidateList(); | 156 void invalidateList(); |
157 | 157 |
158 // FIXME: This pointer should be removed after SVGPathSeg has a tear-off. | 158 // FIXME: This pointer should be removed after SVGPathSeg has a tear-off. |
159 // FIXME: oilpan: This is raw-ptr to avoid reference cycles. | 159 // FIXME: oilpan: This is raw-ptr to avoid reference cycles. |
160 // SVGPathSegList is either owned by SVGAnimatedPath or | 160 // SVGPathSegList is either owned by SVGAnimatedPath or |
161 // SVGPathSegListTearOff. Both keep |contextElement| alive, | 161 // SVGPathSegListTearOff. Both keep |contextElement| alive, |
162 // so this ptr is always valid. | 162 // so this ptr is always valid. |
163 SVGPathElement* m_contextElement; | 163 SVGPathElement* m_contextElement; |
164 | 164 |
165 SVGPathSegRole m_role; | 165 SVGPathSegRole m_role; |
166 mutable OwnPtr<SVGPathByteStream> m_byteStream; | 166 mutable OwnPtr<SVGPathByteStream> m_byteStream; |
167 bool m_listSyncedToByteStream; | 167 bool m_listSyncedToByteStream; |
168 }; | 168 }; |
169 | 169 |
170 inline PassRefPtr<SVGPathSegList> toSVGPathSegList(PassRefPtr<NewSVGPropertyBase
> passBase) | 170 inline PassRefPtr<SVGPathSegList> toSVGPathSegList(PassRefPtr<SVGPropertyBase> p
assBase) |
171 { | 171 { |
172 RefPtr<NewSVGPropertyBase> base = passBase; | 172 RefPtr<SVGPropertyBase> base = passBase; |
173 ASSERT(base->type() == SVGPathSegList::classType()); | 173 ASSERT(base->type() == SVGPathSegList::classType()); |
174 return static_pointer_cast<SVGPathSegList>(base.release()); | 174 return static_pointer_cast<SVGPathSegList>(base.release()); |
175 } | 175 } |
176 | 176 |
177 } // namespace WebCore | 177 } // namespace WebCore |
178 | 178 |
179 #endif | 179 #endif |
OLD | NEW |