/src/mozilla-central/dom/svg/DOMSVGPathSeg.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef MOZILLA_DOMSVGPATHSEG_H__ |
8 | | #define MOZILLA_DOMSVGPATHSEG_H__ |
9 | | |
10 | | #include "DOMSVGPathSegList.h" |
11 | | #include "nsCycleCollectionParticipant.h" |
12 | | #include "nsWrapperCache.h" |
13 | | #include "SVGPathSegUtils.h" |
14 | | #include "mozilla/dom/SVGPathSegBinding.h" |
15 | | |
16 | | class nsSVGElement; |
17 | | |
18 | 0 | #define MOZ_SVG_LIST_INDEX_BIT_COUNT 31 |
19 | | |
20 | | namespace mozilla { |
21 | | |
22 | | #define CHECK_ARG_COUNT_IN_SYNC(segType) \ |
23 | 0 | MOZ_ASSERT(ArrayLength(mArgs) == \ |
24 | 0 | SVGPathSegUtils::ArgCountForType(uint32_t(segType)) || \ |
25 | 0 | uint32_t(segType) == dom::SVGPathSeg_Binding::PATHSEG_CLOSEPATH, \ |
26 | 0 | "Arg count/array size out of sync") |
27 | | |
28 | | #define IMPL_SVGPATHSEG_SUBCLASS_COMMON(segName, segType) \ |
29 | | explicit DOMSVGPathSeg##segName(const float *aArgs) \ |
30 | | : DOMSVGPathSeg() \ |
31 | 0 | { \ |
32 | 0 | CHECK_ARG_COUNT_IN_SYNC(segType); \ |
33 | 0 | memcpy(mArgs, aArgs, \ |
34 | 0 | SVGPathSegUtils::ArgCountForType(uint32_t(segType)) * sizeof(float)); \ |
35 | 0 | } \ Unexecuted instantiation: mozilla::DOMSVGPathSegClosePath::DOMSVGPathSegClosePath(float const*) Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoAbs::DOMSVGPathSegMovetoAbs(float const*) Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoRel::DOMSVGPathSegMovetoRel(float const*) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoAbs::DOMSVGPathSegLinetoAbs(float const*) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoRel::DOMSVGPathSegLinetoRel(float const*) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicAbs::DOMSVGPathSegCurvetoCubicAbs(float const*) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicRel::DOMSVGPathSegCurvetoCubicRel(float const*) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticAbs::DOMSVGPathSegCurvetoQuadraticAbs(float const*) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticRel::DOMSVGPathSegCurvetoQuadraticRel(float const*) Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::DOMSVGPathSegArcAbs(float const*) Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::DOMSVGPathSegArcRel(float const*) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoHorizontalAbs::DOMSVGPathSegLinetoHorizontalAbs(float const*) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoHorizontalRel::DOMSVGPathSegLinetoHorizontalRel(float const*) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoVerticalAbs::DOMSVGPathSegLinetoVerticalAbs(float const*) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoVerticalRel::DOMSVGPathSegLinetoVerticalRel(float const*) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothAbs::DOMSVGPathSegCurvetoCubicSmoothAbs(float const*) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothRel::DOMSVGPathSegCurvetoCubicSmoothRel(float const*) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothAbs::DOMSVGPathSegCurvetoQuadraticSmoothAbs(float const*) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothRel::DOMSVGPathSegCurvetoQuadraticSmoothRel(float const*) |
36 | | DOMSVGPathSeg##segName(DOMSVGPathSegList *aList, \ |
37 | | uint32_t aListIndex, \ |
38 | | bool aIsAnimValItem) \ |
39 | | : DOMSVGPathSeg(aList, aListIndex, aIsAnimValItem) \ |
40 | 0 | { \ |
41 | 0 | CHECK_ARG_COUNT_IN_SYNC(segType); \ |
42 | 0 | } \ Unexecuted instantiation: mozilla::DOMSVGPathSegClosePath::DOMSVGPathSegClosePath(mozilla::DOMSVGPathSegList*, unsigned int, bool) Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoAbs::DOMSVGPathSegMovetoAbs(mozilla::DOMSVGPathSegList*, unsigned int, bool) Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoRel::DOMSVGPathSegMovetoRel(mozilla::DOMSVGPathSegList*, unsigned int, bool) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoAbs::DOMSVGPathSegLinetoAbs(mozilla::DOMSVGPathSegList*, unsigned int, bool) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoRel::DOMSVGPathSegLinetoRel(mozilla::DOMSVGPathSegList*, unsigned int, bool) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicAbs::DOMSVGPathSegCurvetoCubicAbs(mozilla::DOMSVGPathSegList*, unsigned int, bool) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicRel::DOMSVGPathSegCurvetoCubicRel(mozilla::DOMSVGPathSegList*, unsigned int, bool) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticAbs::DOMSVGPathSegCurvetoQuadraticAbs(mozilla::DOMSVGPathSegList*, unsigned int, bool) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticRel::DOMSVGPathSegCurvetoQuadraticRel(mozilla::DOMSVGPathSegList*, unsigned int, bool) Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::DOMSVGPathSegArcAbs(mozilla::DOMSVGPathSegList*, unsigned int, bool) Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::DOMSVGPathSegArcRel(mozilla::DOMSVGPathSegList*, unsigned int, bool) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoHorizontalAbs::DOMSVGPathSegLinetoHorizontalAbs(mozilla::DOMSVGPathSegList*, unsigned int, bool) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoHorizontalRel::DOMSVGPathSegLinetoHorizontalRel(mozilla::DOMSVGPathSegList*, unsigned int, bool) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoVerticalAbs::DOMSVGPathSegLinetoVerticalAbs(mozilla::DOMSVGPathSegList*, unsigned int, bool) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoVerticalRel::DOMSVGPathSegLinetoVerticalRel(mozilla::DOMSVGPathSegList*, unsigned int, bool) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothAbs::DOMSVGPathSegCurvetoCubicSmoothAbs(mozilla::DOMSVGPathSegList*, unsigned int, bool) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothRel::DOMSVGPathSegCurvetoCubicSmoothRel(mozilla::DOMSVGPathSegList*, unsigned int, bool) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothAbs::DOMSVGPathSegCurvetoQuadraticSmoothAbs(mozilla::DOMSVGPathSegList*, unsigned int, bool) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothRel::DOMSVGPathSegCurvetoQuadraticSmoothRel(mozilla::DOMSVGPathSegList*, unsigned int, bool) |
43 | | /* From DOMSVGPathSeg: */ \ |
44 | | virtual uint32_t \ |
45 | | Type() const override \ |
46 | 0 | { \ |
47 | 0 | return segType; \ |
48 | 0 | } \ Unexecuted instantiation: mozilla::DOMSVGPathSegClosePath::Type() const Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoAbs::Type() const Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoRel::Type() const Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoAbs::Type() const Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoRel::Type() const Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicAbs::Type() const Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicRel::Type() const Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticAbs::Type() const Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticRel::Type() const Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::Type() const Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::Type() const Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoHorizontalAbs::Type() const Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoHorizontalRel::Type() const Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoVerticalAbs::Type() const Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoVerticalRel::Type() const Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothAbs::Type() const Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothRel::Type() const Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothAbs::Type() const Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothRel::Type() const |
49 | | virtual DOMSVGPathSeg* \ |
50 | | Clone() override \ |
51 | 0 | { \ |
52 | 0 | /* InternalItem() + 1, because we're skipping the encoded seg type */ \ |
53 | 0 | float *args = IsInList() ? InternalItem() + 1 : mArgs; \ |
54 | 0 | return new DOMSVGPathSeg##segName(args); \ |
55 | 0 | } \ Unexecuted instantiation: mozilla::DOMSVGPathSegClosePath::Clone() Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoAbs::Clone() Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoRel::Clone() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoAbs::Clone() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoRel::Clone() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicAbs::Clone() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicRel::Clone() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticAbs::Clone() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticRel::Clone() Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::Clone() Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::Clone() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoHorizontalAbs::Clone() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoHorizontalRel::Clone() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoVerticalAbs::Clone() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoVerticalRel::Clone() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothAbs::Clone() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothRel::Clone() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothAbs::Clone() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothRel::Clone() |
56 | | virtual float* \ |
57 | | PtrToMemberArgs() override \ |
58 | 0 | { \ |
59 | 0 | return mArgs; \ |
60 | 0 | } \ Unexecuted instantiation: mozilla::DOMSVGPathSegClosePath::PtrToMemberArgs() Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoAbs::PtrToMemberArgs() Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoRel::PtrToMemberArgs() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoAbs::PtrToMemberArgs() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoRel::PtrToMemberArgs() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicAbs::PtrToMemberArgs() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicRel::PtrToMemberArgs() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticAbs::PtrToMemberArgs() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticRel::PtrToMemberArgs() Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::PtrToMemberArgs() Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::PtrToMemberArgs() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoHorizontalAbs::PtrToMemberArgs() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoHorizontalRel::PtrToMemberArgs() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoVerticalAbs::PtrToMemberArgs() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoVerticalRel::PtrToMemberArgs() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothAbs::PtrToMemberArgs() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothRel::PtrToMemberArgs() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothAbs::PtrToMemberArgs() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothRel::PtrToMemberArgs() |
61 | | \ |
62 | | virtual JSObject* \ |
63 | | WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override \ |
64 | 0 | { \ |
65 | 0 | return dom::SVGPathSeg##segName##_Binding::Wrap(aCx, this, aGivenProto); \ |
66 | 0 | } Unexecuted instantiation: mozilla::DOMSVGPathSegClosePath::WrapObject(JSContext*, JS::Handle<JSObject*>) Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoAbs::WrapObject(JSContext*, JS::Handle<JSObject*>) Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoRel::WrapObject(JSContext*, JS::Handle<JSObject*>) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoAbs::WrapObject(JSContext*, JS::Handle<JSObject*>) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoRel::WrapObject(JSContext*, JS::Handle<JSObject*>) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicAbs::WrapObject(JSContext*, JS::Handle<JSObject*>) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicRel::WrapObject(JSContext*, JS::Handle<JSObject*>) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticAbs::WrapObject(JSContext*, JS::Handle<JSObject*>) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticRel::WrapObject(JSContext*, JS::Handle<JSObject*>) Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::WrapObject(JSContext*, JS::Handle<JSObject*>) Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::WrapObject(JSContext*, JS::Handle<JSObject*>) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoHorizontalAbs::WrapObject(JSContext*, JS::Handle<JSObject*>) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoHorizontalRel::WrapObject(JSContext*, JS::Handle<JSObject*>) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoVerticalAbs::WrapObject(JSContext*, JS::Handle<JSObject*>) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoVerticalRel::WrapObject(JSContext*, JS::Handle<JSObject*>) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothAbs::WrapObject(JSContext*, JS::Handle<JSObject*>) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothRel::WrapObject(JSContext*, JS::Handle<JSObject*>) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothAbs::WrapObject(JSContext*, JS::Handle<JSObject*>) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothRel::WrapObject(JSContext*, JS::Handle<JSObject*>) |
67 | | |
68 | | |
69 | | /** |
70 | | * Class DOMSVGPathSeg |
71 | | * |
72 | | * This class is the base class of the classes that create the DOM objects that |
73 | | * wrap the internal path segments that are encoded in an SVGPathData. Its |
74 | | * sub-classes are also used to create the objects returned by |
75 | | * SVGPathElement.createSVGPathSegXxx(). |
76 | | * |
77 | | * See the architecture comment in DOMSVGPathSegList.h for an overview of the |
78 | | * important points regarding these DOM wrapper structures. |
79 | | * |
80 | | * See the architecture comment in DOMSVGLength.h (yes, LENGTH) for an overview |
81 | | * of the important points regarding how this specific class works. |
82 | | * |
83 | | * The main differences between this class and DOMSVGLength is that we have |
84 | | * sub-classes (it does not), and the "internal counterpart" that we provide a |
85 | | * DOM wrapper for is a list of floats, not an instance of an internal class. |
86 | | */ |
87 | | class DOMSVGPathSeg : public nsWrapperCache |
88 | | { |
89 | | friend class AutoChangePathSegNotifier; |
90 | | |
91 | | public: |
92 | | NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMSVGPathSeg) |
93 | | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMSVGPathSeg) |
94 | | |
95 | | /** |
96 | | * Unlike the other list classes, we hide our ctor (because no one should be |
97 | | * creating instances of this class directly). This factory method in exposed |
98 | | * instead to take care of creating instances of the correct sub-class. |
99 | | */ |
100 | | static DOMSVGPathSeg *CreateFor(DOMSVGPathSegList *aList, |
101 | | uint32_t aListIndex, |
102 | | bool aIsAnimValItem); |
103 | | |
104 | | /** |
105 | | * Create an unowned copy of this object. The caller is responsible for the |
106 | | * first AddRef()! |
107 | | */ |
108 | | virtual DOMSVGPathSeg* Clone() = 0; |
109 | | |
110 | 0 | bool IsInList() const { |
111 | 0 | return !!mList; |
112 | 0 | } |
113 | | |
114 | | /** |
115 | | * In future, if this class is used for non-list segments, this will be |
116 | | * different to IsInList(). |
117 | | */ |
118 | 0 | bool HasOwner() const { |
119 | 0 | return !!mList; |
120 | 0 | } |
121 | | |
122 | | /** |
123 | | * This method is called to notify this DOM object that it is being inserted |
124 | | * into a list, and give it the information it needs as a result. |
125 | | * |
126 | | * This object MUST NOT already belong to a list when this method is called. |
127 | | * That's not to say that script can't move these DOM objects between |
128 | | * lists - it can - it's just that the logic to handle that (and send out |
129 | | * the necessary notifications) is located elsewhere (in DOMSVGPathSegList).) |
130 | | */ |
131 | | void InsertingIntoList(DOMSVGPathSegList *aList, |
132 | | uint32_t aListIndex, |
133 | | bool aIsAnimValItem); |
134 | | |
135 | 0 | static uint32_t MaxListIndex() { |
136 | 0 | return (1U << MOZ_SVG_LIST_INDEX_BIT_COUNT) - 1; |
137 | 0 | } |
138 | | |
139 | | /// This method is called to notify this object that its list index changed. |
140 | 0 | void UpdateListIndex(uint32_t aListIndex) { |
141 | 0 | mListIndex = aListIndex; |
142 | 0 | } |
143 | | |
144 | | /** |
145 | | * This method is called to notify this DOM object that it is about to be |
146 | | * removed from its current DOM list so that it can first make a copy of its |
147 | | * internal counterpart's values. (If it didn't do this, then it would |
148 | | * "lose" its value on being removed.) |
149 | | */ |
150 | | void RemovingFromList(); |
151 | | |
152 | | /** |
153 | | * This method converts the segment to a string of floats as found in |
154 | | * SVGPathData (i.e. the first float contains the type of the segment, |
155 | | * encoded into a float, followed by its arguments in the same order as they |
156 | | * are given in the <path> element's 'd' attribute). |
157 | | */ |
158 | | void ToSVGPathSegEncodedData(float *aData); |
159 | | |
160 | | /** |
161 | | * The type of this path segment. |
162 | | */ |
163 | | virtual uint32_t Type() const = 0; |
164 | | |
165 | | // WebIDL |
166 | 0 | DOMSVGPathSegList* GetParentObject() { return mList; } |
167 | 0 | uint16_t PathSegType() const { return Type(); } |
168 | | void GetPathSegTypeAsLetter(nsAString &aPathSegTypeAsLetter) |
169 | 0 | { aPathSegTypeAsLetter = SVGPathSegUtils::GetPathSegTypeAsLetter(Type()); } |
170 | | virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override = 0; |
171 | | |
172 | | protected: |
173 | | |
174 | | /** |
175 | | * Generic ctor for DOMSVGPathSeg objects that are created for an attribute. |
176 | | */ |
177 | | DOMSVGPathSeg(DOMSVGPathSegList *aList, |
178 | | uint32_t aListIndex, |
179 | | bool aIsAnimValItem); |
180 | | |
181 | | /** |
182 | | * Ctor for creating the objects returned by |
183 | | * SVGPathElement.createSVGPathSegXxx(), which do not initially belong to an |
184 | | * attribute. |
185 | | */ |
186 | | DOMSVGPathSeg(); |
187 | | |
188 | 0 | virtual ~DOMSVGPathSeg() { |
189 | 0 | // Our mList's weak ref to us must be nulled out when we die. If GC has |
190 | 0 | // unlinked us using the cycle collector code, then that has already |
191 | 0 | // happened, and mList is null. |
192 | 0 | if (mList) { |
193 | 0 | mList->ItemAt(mListIndex) = nullptr; |
194 | 0 | } |
195 | 0 | } |
196 | | |
197 | 0 | nsSVGElement* Element() { |
198 | 0 | return mList->Element(); |
199 | 0 | } |
200 | | |
201 | | /** |
202 | | * Get a reference to the internal SVGPathSeg list item that this DOM wrapper |
203 | | * object currently wraps. |
204 | | * |
205 | | * To simplify the code we just have this one method for obtaining both |
206 | | * baseVal and animVal internal items. This means that animVal items don't |
207 | | * get const protection, but then our setter methods guard against changing |
208 | | * animVal items. |
209 | | */ |
210 | | float* InternalItem(); |
211 | | |
212 | | virtual float* PtrToMemberArgs() = 0; |
213 | | |
214 | | #ifdef DEBUG |
215 | | bool IndexIsValid(); |
216 | | #endif |
217 | | |
218 | | RefPtr<DOMSVGPathSegList> mList; |
219 | | |
220 | | // Bounds for the following are checked in the ctor, so be sure to update |
221 | | // that if you change the capacity of any of the following. |
222 | | |
223 | | uint32_t mListIndex:MOZ_SVG_LIST_INDEX_BIT_COUNT; |
224 | | uint32_t mIsAnimValItem:1; // uint32_t because MSVC won't pack otherwise |
225 | | }; |
226 | | |
227 | | class DOMSVGPathSegClosePath |
228 | | : public DOMSVGPathSeg |
229 | | { |
230 | | public: |
231 | | DOMSVGPathSegClosePath() |
232 | | : DOMSVGPathSeg() |
233 | 0 | { |
234 | 0 | } |
235 | | |
236 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
237 | | ClosePath, dom::SVGPathSeg_Binding::PATHSEG_CLOSEPATH) |
238 | | |
239 | | protected: |
240 | | // To allow IMPL_SVGPATHSEG_SUBCLASS_COMMON above to compile we need an |
241 | | // mArgs, but since C++ doesn't allow zero-sized arrays we need to give it |
242 | | // one (unused) element. |
243 | | float mArgs[1]; |
244 | | }; |
245 | | |
246 | | class DOMSVGPathSegMovetoAbs |
247 | | : public DOMSVGPathSeg |
248 | | { |
249 | | public: |
250 | | DOMSVGPathSegMovetoAbs(float x, float y) |
251 | | : DOMSVGPathSeg() |
252 | 0 | { |
253 | 0 | mArgs[0] = x; |
254 | 0 | mArgs[1] = y; |
255 | 0 | } |
256 | | |
257 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
258 | | MovetoAbs, dom::SVGPathSeg_Binding::PATHSEG_MOVETO_ABS) |
259 | | |
260 | | float X(); |
261 | | void SetX(float aX, ErrorResult& rv); |
262 | | float Y(); |
263 | | void SetY(float aY, ErrorResult& rv); |
264 | | |
265 | | protected: |
266 | | float mArgs[2]; |
267 | | }; |
268 | | |
269 | | class DOMSVGPathSegMovetoRel |
270 | | : public DOMSVGPathSeg |
271 | | { |
272 | | public: |
273 | | DOMSVGPathSegMovetoRel(float x, float y) |
274 | | : DOMSVGPathSeg() |
275 | 0 | { |
276 | 0 | mArgs[0] = x; |
277 | 0 | mArgs[1] = y; |
278 | 0 | } |
279 | | |
280 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
281 | | MovetoRel, dom::SVGPathSeg_Binding::PATHSEG_MOVETO_REL) |
282 | | |
283 | | float X(); |
284 | | void SetX(float aX, ErrorResult& rv); |
285 | | float Y(); |
286 | | void SetY(float aY, ErrorResult& rv); |
287 | | |
288 | | protected: |
289 | | float mArgs[2]; |
290 | | }; |
291 | | |
292 | | class DOMSVGPathSegLinetoAbs |
293 | | : public DOMSVGPathSeg |
294 | | { |
295 | | public: |
296 | | DOMSVGPathSegLinetoAbs(float x, float y) |
297 | | : DOMSVGPathSeg() |
298 | 0 | { |
299 | 0 | mArgs[0] = x; |
300 | 0 | mArgs[1] = y; |
301 | 0 | } |
302 | | |
303 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
304 | | LinetoAbs, dom::SVGPathSeg_Binding::PATHSEG_LINETO_ABS) |
305 | | |
306 | | float X(); |
307 | | void SetX(float aX, ErrorResult& rv); |
308 | | float Y(); |
309 | | void SetY(float aY, ErrorResult& rv); |
310 | | |
311 | | protected: |
312 | | float mArgs[2]; |
313 | | }; |
314 | | |
315 | | class DOMSVGPathSegLinetoRel |
316 | | : public DOMSVGPathSeg |
317 | | { |
318 | | public: |
319 | | DOMSVGPathSegLinetoRel(float x, float y) |
320 | | : DOMSVGPathSeg() |
321 | 0 | { |
322 | 0 | mArgs[0] = x; |
323 | 0 | mArgs[1] = y; |
324 | 0 | } |
325 | | |
326 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
327 | | LinetoRel, dom::SVGPathSeg_Binding::PATHSEG_LINETO_REL) |
328 | | |
329 | | float X(); |
330 | | void SetX(float aX, ErrorResult& rv); |
331 | | float Y(); |
332 | | void SetY(float aY, ErrorResult& rv); |
333 | | |
334 | | protected: |
335 | | float mArgs[2]; |
336 | | }; |
337 | | |
338 | | class DOMSVGPathSegCurvetoCubicAbs |
339 | | : public DOMSVGPathSeg |
340 | | { |
341 | | public: |
342 | | DOMSVGPathSegCurvetoCubicAbs(float x1, float y1, |
343 | | float x2, float y2, |
344 | | float x, float y) |
345 | | : DOMSVGPathSeg() |
346 | 0 | { |
347 | 0 | mArgs[0] = x1; |
348 | 0 | mArgs[1] = y1; |
349 | 0 | mArgs[2] = x2; |
350 | 0 | mArgs[3] = y2; |
351 | 0 | mArgs[4] = x; |
352 | 0 | mArgs[5] = y; |
353 | 0 | } |
354 | | |
355 | | float X(); |
356 | | void SetX(float aX, ErrorResult& rv); |
357 | | float Y(); |
358 | | void SetY(float aY, ErrorResult& rv); |
359 | | float X1(); |
360 | | void SetX1(float aX1, ErrorResult& rv); |
361 | | float Y1(); |
362 | | void SetY1(float aY1, ErrorResult& rv); |
363 | | float X2(); |
364 | | void SetX2(float aX2, ErrorResult& rv); |
365 | | float Y2(); |
366 | | void SetY2(float aY2, ErrorResult& rv); |
367 | | |
368 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
369 | | CurvetoCubicAbs, dom::SVGPathSeg_Binding::PATHSEG_CURVETO_CUBIC_ABS) |
370 | | |
371 | | protected: |
372 | | float mArgs[6]; |
373 | | }; |
374 | | |
375 | | class DOMSVGPathSegCurvetoCubicRel |
376 | | : public DOMSVGPathSeg |
377 | | { |
378 | | public: |
379 | | DOMSVGPathSegCurvetoCubicRel(float x1, float y1, |
380 | | float x2, float y2, |
381 | | float x, float y) |
382 | | : DOMSVGPathSeg() |
383 | 0 | { |
384 | 0 | mArgs[0] = x1; |
385 | 0 | mArgs[1] = y1; |
386 | 0 | mArgs[2] = x2; |
387 | 0 | mArgs[3] = y2; |
388 | 0 | mArgs[4] = x; |
389 | 0 | mArgs[5] = y; |
390 | 0 | } |
391 | | |
392 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
393 | | CurvetoCubicRel, dom::SVGPathSeg_Binding::PATHSEG_CURVETO_CUBIC_REL) |
394 | | |
395 | | float X(); |
396 | | void SetX(float aX, ErrorResult& rv); |
397 | | float Y(); |
398 | | void SetY(float aY, ErrorResult& rv); |
399 | | float X1(); |
400 | | void SetX1(float aX1, ErrorResult& rv); |
401 | | float Y1(); |
402 | | void SetY1(float aY1, ErrorResult& rv); |
403 | | float X2(); |
404 | | void SetX2(float aX2, ErrorResult& rv); |
405 | | float Y2(); |
406 | | void SetY2(float aY2, ErrorResult& rv); |
407 | | |
408 | | protected: |
409 | | float mArgs[6]; |
410 | | }; |
411 | | |
412 | | class DOMSVGPathSegCurvetoQuadraticAbs |
413 | | : public DOMSVGPathSeg |
414 | | { |
415 | | public: |
416 | | DOMSVGPathSegCurvetoQuadraticAbs(float x1, float y1, |
417 | | float x, float y) |
418 | | : DOMSVGPathSeg() |
419 | 0 | { |
420 | 0 | mArgs[0] = x1; |
421 | 0 | mArgs[1] = y1; |
422 | 0 | mArgs[2] = x; |
423 | 0 | mArgs[3] = y; |
424 | 0 | } |
425 | | |
426 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
427 | | CurvetoQuadraticAbs, dom::SVGPathSeg_Binding::PATHSEG_CURVETO_QUADRATIC_ABS) |
428 | | |
429 | | float X(); |
430 | | void SetX(float aX, ErrorResult& rv); |
431 | | float Y(); |
432 | | void SetY(float aY, ErrorResult& rv); |
433 | | float X1(); |
434 | | void SetX1(float aX1, ErrorResult& rv); |
435 | | float Y1(); |
436 | | void SetY1(float aY1, ErrorResult& rv); |
437 | | |
438 | | protected: |
439 | | float mArgs[4]; |
440 | | }; |
441 | | |
442 | | class DOMSVGPathSegCurvetoQuadraticRel |
443 | | : public DOMSVGPathSeg |
444 | | { |
445 | | public: |
446 | | DOMSVGPathSegCurvetoQuadraticRel(float x1, float y1, |
447 | | float x, float y) |
448 | | : DOMSVGPathSeg() |
449 | 0 | { |
450 | 0 | mArgs[0] = x1; |
451 | 0 | mArgs[1] = y1; |
452 | 0 | mArgs[2] = x; |
453 | 0 | mArgs[3] = y; |
454 | 0 | } |
455 | | |
456 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
457 | | CurvetoQuadraticRel, dom::SVGPathSeg_Binding::PATHSEG_CURVETO_QUADRATIC_REL) |
458 | | |
459 | | float X(); |
460 | | void SetX(float aX, ErrorResult& rv); |
461 | | float Y(); |
462 | | void SetY(float aY, ErrorResult& rv); |
463 | | float X1(); |
464 | | void SetX1(float aX1, ErrorResult& rv); |
465 | | float Y1(); |
466 | | void SetY1(float aY1, ErrorResult& rv); |
467 | | |
468 | | protected: |
469 | | float mArgs[4]; |
470 | | }; |
471 | | |
472 | | class DOMSVGPathSegArcAbs |
473 | | : public DOMSVGPathSeg |
474 | | { |
475 | | public: |
476 | | DOMSVGPathSegArcAbs(float r1, float r2, float angle, |
477 | | bool largeArcFlag, bool sweepFlag, |
478 | | float x, float y) |
479 | | : DOMSVGPathSeg() |
480 | 0 | { |
481 | 0 | mArgs[0] = r1; |
482 | 0 | mArgs[1] = r2; |
483 | 0 | mArgs[2] = angle; |
484 | 0 | mArgs[3] = largeArcFlag; |
485 | 0 | mArgs[4] = sweepFlag; |
486 | 0 | mArgs[5] = x; |
487 | 0 | mArgs[6] = y; |
488 | 0 | } |
489 | | |
490 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
491 | | ArcAbs, dom::SVGPathSeg_Binding::PATHSEG_ARC_ABS) |
492 | | |
493 | | float X(); |
494 | | void SetX(float aX, ErrorResult& rv); |
495 | | float Y(); |
496 | | void SetY(float aY, ErrorResult& rv); |
497 | | float R1(); |
498 | | void SetR1(float aR1, ErrorResult& rv); |
499 | | float R2(); |
500 | | void SetR2(float aR2, ErrorResult& rv); |
501 | | float Angle(); |
502 | | void SetAngle(float aAngle, ErrorResult& rv); |
503 | | bool LargeArcFlag(); |
504 | | void SetLargeArcFlag(bool aFlag, ErrorResult& rv); |
505 | | bool SweepFlag(); |
506 | | void SetSweepFlag(bool aFlag, ErrorResult& rv); |
507 | | |
508 | | protected: |
509 | | float mArgs[7]; |
510 | | }; |
511 | | |
512 | | class DOMSVGPathSegArcRel |
513 | | : public DOMSVGPathSeg |
514 | | { |
515 | | public: |
516 | | DOMSVGPathSegArcRel(float r1, float r2, float angle, |
517 | | bool largeArcFlag, bool sweepFlag, |
518 | | float x, float y) |
519 | | : DOMSVGPathSeg() |
520 | 0 | { |
521 | 0 | mArgs[0] = r1; |
522 | 0 | mArgs[1] = r2; |
523 | 0 | mArgs[2] = angle; |
524 | 0 | mArgs[3] = largeArcFlag; |
525 | 0 | mArgs[4] = sweepFlag; |
526 | 0 | mArgs[5] = x; |
527 | 0 | mArgs[6] = y; |
528 | 0 | } |
529 | | |
530 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
531 | | ArcRel, dom::SVGPathSeg_Binding::PATHSEG_ARC_REL) |
532 | | |
533 | | float X(); |
534 | | void SetX(float aX, ErrorResult& rv); |
535 | | float Y(); |
536 | | void SetY(float aY, ErrorResult& rv); |
537 | | float R1(); |
538 | | void SetR1(float aR1, ErrorResult& rv); |
539 | | float R2(); |
540 | | void SetR2(float aR2, ErrorResult& rv); |
541 | | float Angle(); |
542 | | void SetAngle(float aAngle, ErrorResult& rv); |
543 | | bool LargeArcFlag(); |
544 | | void SetLargeArcFlag(bool aFlag, ErrorResult& rv); |
545 | | bool SweepFlag(); |
546 | | void SetSweepFlag(bool aFlag, ErrorResult& rv); |
547 | | |
548 | | protected: |
549 | | float mArgs[7]; |
550 | | }; |
551 | | |
552 | | class DOMSVGPathSegLinetoHorizontalAbs |
553 | | : public DOMSVGPathSeg |
554 | | { |
555 | | public: |
556 | | explicit DOMSVGPathSegLinetoHorizontalAbs(float x) |
557 | | : DOMSVGPathSeg() |
558 | 0 | { |
559 | 0 | mArgs[0] = x; |
560 | 0 | } |
561 | | |
562 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
563 | | LinetoHorizontalAbs, dom::SVGPathSeg_Binding::PATHSEG_LINETO_HORIZONTAL_ABS) |
564 | | |
565 | | float X(); |
566 | | void SetX(float aX, ErrorResult& rv); |
567 | | |
568 | | protected: |
569 | | float mArgs[1]; |
570 | | }; |
571 | | |
572 | | class DOMSVGPathSegLinetoHorizontalRel |
573 | | : public DOMSVGPathSeg |
574 | | { |
575 | | public: |
576 | | explicit DOMSVGPathSegLinetoHorizontalRel(float x) |
577 | | : DOMSVGPathSeg() |
578 | 0 | { |
579 | 0 | mArgs[0] = x; |
580 | 0 | } |
581 | | |
582 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
583 | | LinetoHorizontalRel, dom::SVGPathSeg_Binding::PATHSEG_LINETO_HORIZONTAL_REL) |
584 | | |
585 | | float X(); |
586 | | void SetX(float aX, ErrorResult& rv); |
587 | | |
588 | | protected: |
589 | | float mArgs[1]; |
590 | | }; |
591 | | |
592 | | class DOMSVGPathSegLinetoVerticalAbs |
593 | | : public DOMSVGPathSeg |
594 | | { |
595 | | public: |
596 | | explicit DOMSVGPathSegLinetoVerticalAbs(float y) |
597 | | : DOMSVGPathSeg() |
598 | 0 | { |
599 | 0 | mArgs[0] = y; |
600 | 0 | } |
601 | | |
602 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
603 | | LinetoVerticalAbs, dom::SVGPathSeg_Binding::PATHSEG_LINETO_VERTICAL_ABS) |
604 | | |
605 | | float Y(); |
606 | | void SetY(float aY, ErrorResult& rv); |
607 | | |
608 | | protected: |
609 | | float mArgs[1]; |
610 | | }; |
611 | | |
612 | | class DOMSVGPathSegLinetoVerticalRel |
613 | | : public DOMSVGPathSeg |
614 | | { |
615 | | public: |
616 | | explicit DOMSVGPathSegLinetoVerticalRel(float y) |
617 | | : DOMSVGPathSeg() |
618 | 0 | { |
619 | 0 | mArgs[0] = y; |
620 | 0 | } |
621 | | |
622 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
623 | | LinetoVerticalRel, dom::SVGPathSeg_Binding::PATHSEG_LINETO_VERTICAL_REL) |
624 | | |
625 | | float Y(); |
626 | | void SetY(float aY, ErrorResult& rv); |
627 | | |
628 | | protected: |
629 | | float mArgs[1]; |
630 | | }; |
631 | | |
632 | | class DOMSVGPathSegCurvetoCubicSmoothAbs |
633 | | : public DOMSVGPathSeg |
634 | | { |
635 | | public: |
636 | | DOMSVGPathSegCurvetoCubicSmoothAbs(float x2, float y2, |
637 | | float x, float y) |
638 | | : DOMSVGPathSeg() |
639 | 0 | { |
640 | 0 | mArgs[0] = x2; |
641 | 0 | mArgs[1] = y2; |
642 | 0 | mArgs[2] = x; |
643 | 0 | mArgs[3] = y; |
644 | 0 | } |
645 | | |
646 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
647 | | CurvetoCubicSmoothAbs, dom::SVGPathSeg_Binding::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS) |
648 | | |
649 | | float X(); |
650 | | void SetX(float aX, ErrorResult& rv); |
651 | | float Y(); |
652 | | void SetY(float aY, ErrorResult& rv); |
653 | | float X2(); |
654 | | void SetX2(float aX2, ErrorResult& rv); |
655 | | float Y2(); |
656 | | void SetY2(float aY2, ErrorResult& rv); |
657 | | |
658 | | protected: |
659 | | float mArgs[4]; |
660 | | }; |
661 | | |
662 | | class DOMSVGPathSegCurvetoCubicSmoothRel |
663 | | : public DOMSVGPathSeg |
664 | | { |
665 | | public: |
666 | | DOMSVGPathSegCurvetoCubicSmoothRel(float x2, float y2, |
667 | | float x, float y) |
668 | | : DOMSVGPathSeg() |
669 | 0 | { |
670 | 0 | mArgs[0] = x2; |
671 | 0 | mArgs[1] = y2; |
672 | 0 | mArgs[2] = x; |
673 | 0 | mArgs[3] = y; |
674 | 0 | } |
675 | | |
676 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
677 | | CurvetoCubicSmoothRel, dom::SVGPathSeg_Binding::PATHSEG_CURVETO_CUBIC_SMOOTH_REL) |
678 | | |
679 | | float X(); |
680 | | void SetX(float aX, ErrorResult& rv); |
681 | | float Y(); |
682 | | void SetY(float aY, ErrorResult& rv); |
683 | | float X2(); |
684 | | void SetX2(float aX2, ErrorResult& rv); |
685 | | float Y2(); |
686 | | void SetY2(float aY2, ErrorResult& rv); |
687 | | |
688 | | protected: |
689 | | float mArgs[4]; |
690 | | }; |
691 | | |
692 | | class DOMSVGPathSegCurvetoQuadraticSmoothAbs |
693 | | : public DOMSVGPathSeg |
694 | | { |
695 | | public: |
696 | | DOMSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y) |
697 | | : DOMSVGPathSeg() |
698 | 0 | { |
699 | 0 | mArgs[0] = x; |
700 | 0 | mArgs[1] = y; |
701 | 0 | } |
702 | | |
703 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
704 | | CurvetoQuadraticSmoothAbs, dom::SVGPathSeg_Binding::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS) |
705 | | |
706 | | float X(); |
707 | | void SetX(float aX, ErrorResult& rv); |
708 | | float Y(); |
709 | | void SetY(float aY, ErrorResult& rv); |
710 | | |
711 | | protected: |
712 | | float mArgs[2]; |
713 | | }; |
714 | | |
715 | | class DOMSVGPathSegCurvetoQuadraticSmoothRel |
716 | | : public DOMSVGPathSeg |
717 | | { |
718 | | public: |
719 | | DOMSVGPathSegCurvetoQuadraticSmoothRel(float x, float y) |
720 | | : DOMSVGPathSeg() |
721 | 0 | { |
722 | 0 | mArgs[0] = x; |
723 | 0 | mArgs[1] = y; |
724 | 0 | } |
725 | | |
726 | | IMPL_SVGPATHSEG_SUBCLASS_COMMON( |
727 | | CurvetoQuadraticSmoothRel, dom::SVGPathSeg_Binding::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL) |
728 | | |
729 | | float X(); |
730 | | void SetX(float aX, ErrorResult& rv); |
731 | | float Y(); |
732 | | void SetY(float aY, ErrorResult& rv); |
733 | | |
734 | | protected: |
735 | | float mArgs[2]; |
736 | | }; |
737 | | |
738 | | } // namespace mozilla |
739 | | |
740 | | #undef MOZ_SVG_LIST_INDEX_BIT_COUNT |
741 | | |
742 | | #endif // MOZILLA_DOMSVGPATHSEG_H__ |