/src/mozilla-central/dom/svg/DOMSVGPathSeg.cpp
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 | | #include "DOMSVGPathSeg.h" |
8 | | #include "DOMSVGPathSegList.h" |
9 | | #include "SVGAnimatedPathSegList.h" |
10 | | #include "nsSVGElement.h" |
11 | | #include "nsError.h" |
12 | | |
13 | | // See the architecture comment in DOMSVGPathSegList.h. |
14 | | |
15 | | namespace mozilla { |
16 | | |
17 | | using namespace dom::SVGPathSeg_Binding; |
18 | | |
19 | | // We could use NS_IMPL_CYCLE_COLLECTION(, except that in Unlink() we need to |
20 | | // clear our list's weak ref to us to be safe. (The other option would be to |
21 | | // not unlink and rely on the breaking of the other edges in the cycle, as |
22 | | // NS_SVG_VAL_IMPL_CYCLE_COLLECTION does.) |
23 | | NS_IMPL_CYCLE_COLLECTION_CLASS(DOMSVGPathSeg) |
24 | | |
25 | 0 | NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMSVGPathSeg) |
26 | 0 | // We may not belong to a list, so we must null check tmp->mList. |
27 | 0 | if (tmp->mList) { |
28 | 0 | tmp->mList->ItemAt(tmp->mListIndex) = nullptr; |
29 | 0 | } |
30 | 0 | NS_IMPL_CYCLE_COLLECTION_UNLINK(mList) |
31 | 0 | NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER |
32 | 0 | NS_IMPL_CYCLE_COLLECTION_UNLINK_END |
33 | | |
34 | 0 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMSVGPathSeg) |
35 | 0 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mList) |
36 | 0 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END |
37 | | |
38 | 0 | NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(DOMSVGPathSeg) |
39 | 0 | NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER |
40 | 0 | NS_IMPL_CYCLE_COLLECTION_TRACE_END |
41 | | |
42 | | NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMSVGPathSeg, AddRef) |
43 | | NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMSVGPathSeg, Release) |
44 | | |
45 | | //---------------------------------------------------------------------- |
46 | | // Helper class: AutoChangePathSegNotifier |
47 | | // Stack-based helper class to pair calls to WillChangePathSegList |
48 | | // and DidChangePathSegList. |
49 | | class MOZ_RAII AutoChangePathSegNotifier |
50 | | { |
51 | | public: |
52 | | explicit AutoChangePathSegNotifier(DOMSVGPathSeg* aPathSeg MOZ_GUARD_OBJECT_NOTIFIER_PARAM) |
53 | | : mPathSeg(aPathSeg) |
54 | 0 | { |
55 | 0 | MOZ_GUARD_OBJECT_NOTIFIER_INIT; |
56 | 0 | MOZ_ASSERT(mPathSeg, "Expecting non-null pathSeg"); |
57 | 0 | MOZ_ASSERT(mPathSeg->HasOwner(), |
58 | 0 | "Expecting list to have an owner for notification"); |
59 | 0 | mEmptyOrOldValue = |
60 | 0 | mPathSeg->Element()->WillChangePathSegList(); |
61 | 0 | } |
62 | | |
63 | | ~AutoChangePathSegNotifier() |
64 | 0 | { |
65 | 0 | mPathSeg->Element()->DidChangePathSegList(mEmptyOrOldValue); |
66 | 0 | if (mPathSeg->mList->AttrIsAnimating()) { |
67 | 0 | mPathSeg->Element()->AnimationNeedsResample(); |
68 | 0 | } |
69 | 0 | } |
70 | | |
71 | | private: |
72 | | DOMSVGPathSeg* const mPathSeg; |
73 | | nsAttrValue mEmptyOrOldValue; |
74 | | MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER |
75 | | }; |
76 | | |
77 | | DOMSVGPathSeg::DOMSVGPathSeg(DOMSVGPathSegList *aList, |
78 | | uint32_t aListIndex, |
79 | | bool aIsAnimValItem) |
80 | | : mList(aList) |
81 | | , mListIndex(aListIndex) |
82 | | , mIsAnimValItem(aIsAnimValItem) |
83 | 0 | { |
84 | 0 | // These shifts are in sync with the members in the header. |
85 | 0 | MOZ_ASSERT(aList && aListIndex <= MaxListIndex(), "bad arg"); |
86 | 0 |
|
87 | 0 | MOZ_ASSERT(IndexIsValid(), "Bad index for DOMSVGPathSeg!"); |
88 | 0 | } |
89 | | |
90 | | DOMSVGPathSeg::DOMSVGPathSeg() |
91 | | : mList(nullptr) |
92 | | , mListIndex(0) |
93 | | , mIsAnimValItem(false) |
94 | 0 | { |
95 | 0 | } |
96 | | |
97 | | void |
98 | | DOMSVGPathSeg::InsertingIntoList(DOMSVGPathSegList *aList, |
99 | | uint32_t aListIndex, |
100 | | bool aIsAnimValItem) |
101 | 0 | { |
102 | 0 | MOZ_ASSERT(!HasOwner(), "Inserting item that is already in a list"); |
103 | 0 |
|
104 | 0 | mList = aList; |
105 | 0 | mListIndex = aListIndex; |
106 | 0 | mIsAnimValItem = aIsAnimValItem; |
107 | 0 |
|
108 | 0 | MOZ_ASSERT(IndexIsValid(), "Bad index for DOMSVGPathSeg!"); |
109 | 0 | } |
110 | | |
111 | | void |
112 | | DOMSVGPathSeg::RemovingFromList() |
113 | 0 | { |
114 | 0 | uint32_t argCount = SVGPathSegUtils::ArgCountForType(Type()); |
115 | 0 | // InternalItem() + 1, because the args come after the encoded seg type |
116 | 0 | memcpy(PtrToMemberArgs(), InternalItem() + 1, argCount * sizeof(float)); |
117 | 0 | mList = nullptr; |
118 | 0 | mIsAnimValItem = false; |
119 | 0 | } |
120 | | |
121 | | void |
122 | | DOMSVGPathSeg::ToSVGPathSegEncodedData(float* aRaw) |
123 | 0 | { |
124 | 0 | MOZ_ASSERT(aRaw, "null pointer"); |
125 | 0 | uint32_t argCount = SVGPathSegUtils::ArgCountForType(Type()); |
126 | 0 | if (IsInList()) { |
127 | 0 | // 1 + argCount, because we're copying the encoded seg type and args |
128 | 0 | memcpy(aRaw, InternalItem(), (1 + argCount) * sizeof(float)); |
129 | 0 | } else { |
130 | 0 | aRaw[0] = SVGPathSegUtils::EncodeType(Type()); |
131 | 0 | // aRaw + 1, because the args go after the encoded seg type |
132 | 0 | memcpy(aRaw + 1, PtrToMemberArgs(), argCount * sizeof(float)); |
133 | 0 | } |
134 | 0 | } |
135 | | |
136 | | float* |
137 | | DOMSVGPathSeg::InternalItem() |
138 | 0 | { |
139 | 0 | uint32_t dataIndex = mList->mItems[mListIndex].mInternalDataIndex; |
140 | 0 | return &(mList->InternalList().mData[dataIndex]); |
141 | 0 | } |
142 | | |
143 | | #ifdef DEBUG |
144 | | bool |
145 | | DOMSVGPathSeg::IndexIsValid() |
146 | | { |
147 | | SVGAnimatedPathSegList *alist = Element()->GetAnimPathSegList(); |
148 | | return (mIsAnimValItem && |
149 | | mListIndex < alist->GetAnimValue().CountItems()) || |
150 | | (!mIsAnimValItem && |
151 | | mListIndex < alist->GetBaseValue().CountItems()); |
152 | | } |
153 | | #endif |
154 | | |
155 | | |
156 | | //////////////////////////////////////////////////////////////////////// |
157 | | // Implementation of DOMSVGPathSeg sub-classes below this point |
158 | | |
159 | | #define IMPL_PROP_WITH_TYPE(segName, propName, index, type) \ |
160 | | type \ |
161 | | DOMSVGPathSeg##segName::propName() \ |
162 | 0 | { \ |
163 | 0 | if (mIsAnimValItem && HasOwner()) { \ |
164 | 0 | Element()->FlushAnimations(); /* May make HasOwner() == false */ \ |
165 | 0 | } \ |
166 | 0 | return type(HasOwner() ? InternalItem()[1+index] : mArgs[index]); \ |
167 | 0 | } \ Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoAbs::X() Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoAbs::Y() Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoRel::X() Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoRel::Y() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoAbs::X() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoAbs::Y() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoRel::X() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoRel::Y() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicAbs::X1() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicAbs::Y1() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicAbs::X2() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicAbs::Y2() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicAbs::X() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicAbs::Y() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicRel::X1() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicRel::Y1() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicRel::X2() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicRel::Y2() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicRel::X() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicRel::Y() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticAbs::X1() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticAbs::Y1() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticAbs::X() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticAbs::Y() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticRel::X1() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticRel::Y1() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticRel::X() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticRel::Y() Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::R1() Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::R2() Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::Angle() Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::LargeArcFlag() Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::SweepFlag() Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::X() Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::Y() Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::R1() Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::R2() Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::Angle() Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::LargeArcFlag() Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::SweepFlag() Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::X() Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::Y() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoHorizontalAbs::X() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoHorizontalRel::X() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoVerticalAbs::Y() Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoVerticalRel::Y() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothAbs::X2() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothAbs::Y2() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothAbs::X() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothAbs::Y() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothRel::X2() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothRel::Y2() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothRel::X() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothRel::Y() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothAbs::X() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothAbs::Y() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothRel::X() Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothRel::Y() |
168 | | void \ |
169 | | DOMSVGPathSeg##segName::Set##propName(type a##propName, ErrorResult& rv) \ |
170 | 0 | { \ |
171 | 0 | if (mIsAnimValItem) { \ |
172 | 0 | rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR); \ |
173 | 0 | return; \ |
174 | 0 | } \ |
175 | 0 | if (HasOwner()) { \ |
176 | 0 | if (InternalItem()[1+index] == float(a##propName)) { \ |
177 | 0 | return; \ |
178 | 0 | } \ |
179 | 0 | AutoChangePathSegNotifier notifier(this); \ |
180 | 0 | InternalItem()[1+index] = float(a##propName); \ |
181 | 0 | } else { \ |
182 | 0 | mArgs[index] = float(a##propName); \ |
183 | 0 | } \ |
184 | 0 | } Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoAbs::SetX(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoAbs::SetY(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoRel::SetX(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegMovetoRel::SetY(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoAbs::SetX(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoAbs::SetY(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoRel::SetX(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoRel::SetY(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicAbs::SetX1(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicAbs::SetY1(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicAbs::SetX2(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicAbs::SetY2(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicAbs::SetX(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicAbs::SetY(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicRel::SetX1(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicRel::SetY1(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicRel::SetX2(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicRel::SetY2(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicRel::SetX(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicRel::SetY(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticAbs::SetX1(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticAbs::SetY1(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticAbs::SetX(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticAbs::SetY(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticRel::SetX1(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticRel::SetY1(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticRel::SetX(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticRel::SetY(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::SetR1(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::SetR2(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::SetAngle(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::SetLargeArcFlag(bool, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::SetSweepFlag(bool, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::SetX(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegArcAbs::SetY(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::SetR1(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::SetR2(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::SetAngle(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::SetLargeArcFlag(bool, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::SetSweepFlag(bool, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::SetX(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegArcRel::SetY(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoHorizontalAbs::SetX(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoHorizontalRel::SetX(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoVerticalAbs::SetY(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegLinetoVerticalRel::SetY(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothAbs::SetX2(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothAbs::SetY2(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothAbs::SetX(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothAbs::SetY(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothRel::SetX2(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothRel::SetY2(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothRel::SetX(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoCubicSmoothRel::SetY(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothAbs::SetX(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothAbs::SetY(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothRel::SetX(float, mozilla::ErrorResult&) Unexecuted instantiation: mozilla::DOMSVGPathSegCurvetoQuadraticSmoothRel::SetY(float, mozilla::ErrorResult&) |
185 | | |
186 | | // For float, the normal type of arguments |
187 | | #define IMPL_FLOAT_PROP(segName, propName, index) \ |
188 | | IMPL_PROP_WITH_TYPE(segName, propName, index, float) |
189 | | |
190 | | // For the boolean flags in arc commands |
191 | | #define IMPL_BOOL_PROP(segName, propName, index) \ |
192 | | IMPL_PROP_WITH_TYPE(segName, propName, index, bool) |
193 | | |
194 | | |
195 | | /////////////////////////////////////////////////////////////////////// |
196 | | |
197 | | IMPL_FLOAT_PROP(MovetoAbs, X, 0) |
198 | | IMPL_FLOAT_PROP(MovetoAbs, Y, 1) |
199 | | |
200 | | |
201 | | //////////////////////////////////////////////////////////////////////// |
202 | | |
203 | | IMPL_FLOAT_PROP(MovetoRel, X, 0) |
204 | | IMPL_FLOAT_PROP(MovetoRel, Y, 1) |
205 | | |
206 | | |
207 | | |
208 | | //////////////////////////////////////////////////////////////////////// |
209 | | |
210 | | IMPL_FLOAT_PROP(LinetoAbs, X, 0) |
211 | | IMPL_FLOAT_PROP(LinetoAbs, Y, 1) |
212 | | |
213 | | |
214 | | //////////////////////////////////////////////////////////////////////// |
215 | | |
216 | | IMPL_FLOAT_PROP(LinetoRel, X, 0) |
217 | | IMPL_FLOAT_PROP(LinetoRel, Y, 1) |
218 | | |
219 | | |
220 | | //////////////////////////////////////////////////////////////////////// |
221 | | |
222 | | IMPL_FLOAT_PROP(CurvetoCubicAbs, X1, 0) |
223 | | IMPL_FLOAT_PROP(CurvetoCubicAbs, Y1, 1) |
224 | | IMPL_FLOAT_PROP(CurvetoCubicAbs, X2, 2) |
225 | | IMPL_FLOAT_PROP(CurvetoCubicAbs, Y2, 3) |
226 | | IMPL_FLOAT_PROP(CurvetoCubicAbs, X, 4) |
227 | | IMPL_FLOAT_PROP(CurvetoCubicAbs, Y, 5) |
228 | | |
229 | | |
230 | | //////////////////////////////////////////////////////////////////////// |
231 | | |
232 | | IMPL_FLOAT_PROP(CurvetoCubicRel, X1, 0) |
233 | | IMPL_FLOAT_PROP(CurvetoCubicRel, Y1, 1) |
234 | | IMPL_FLOAT_PROP(CurvetoCubicRel, X2, 2) |
235 | | IMPL_FLOAT_PROP(CurvetoCubicRel, Y2, 3) |
236 | | IMPL_FLOAT_PROP(CurvetoCubicRel, X, 4) |
237 | | IMPL_FLOAT_PROP(CurvetoCubicRel, Y, 5) |
238 | | |
239 | | |
240 | | //////////////////////////////////////////////////////////////////////// |
241 | | |
242 | | IMPL_FLOAT_PROP(CurvetoQuadraticAbs, X1, 0) |
243 | | IMPL_FLOAT_PROP(CurvetoQuadraticAbs, Y1, 1) |
244 | | IMPL_FLOAT_PROP(CurvetoQuadraticAbs, X, 2) |
245 | | IMPL_FLOAT_PROP(CurvetoQuadraticAbs, Y, 3) |
246 | | |
247 | | |
248 | | //////////////////////////////////////////////////////////////////////// |
249 | | |
250 | | IMPL_FLOAT_PROP(CurvetoQuadraticRel, X1, 0) |
251 | | IMPL_FLOAT_PROP(CurvetoQuadraticRel, Y1, 1) |
252 | | IMPL_FLOAT_PROP(CurvetoQuadraticRel, X, 2) |
253 | | IMPL_FLOAT_PROP(CurvetoQuadraticRel, Y, 3) |
254 | | |
255 | | |
256 | | //////////////////////////////////////////////////////////////////////// |
257 | | |
258 | | IMPL_FLOAT_PROP(ArcAbs, R1, 0) |
259 | | IMPL_FLOAT_PROP(ArcAbs, R2, 1) |
260 | | IMPL_FLOAT_PROP(ArcAbs, Angle, 2) |
261 | | IMPL_BOOL_PROP(ArcAbs, LargeArcFlag, 3) |
262 | | IMPL_BOOL_PROP(ArcAbs, SweepFlag, 4) |
263 | | IMPL_FLOAT_PROP(ArcAbs, X, 5) |
264 | | IMPL_FLOAT_PROP(ArcAbs, Y, 6) |
265 | | |
266 | | |
267 | | //////////////////////////////////////////////////////////////////////// |
268 | | |
269 | | IMPL_FLOAT_PROP(ArcRel, R1, 0) |
270 | | IMPL_FLOAT_PROP(ArcRel, R2, 1) |
271 | | IMPL_FLOAT_PROP(ArcRel, Angle, 2) |
272 | | IMPL_BOOL_PROP(ArcRel, LargeArcFlag, 3) |
273 | | IMPL_BOOL_PROP(ArcRel, SweepFlag, 4) |
274 | | IMPL_FLOAT_PROP(ArcRel, X, 5) |
275 | | IMPL_FLOAT_PROP(ArcRel, Y, 6) |
276 | | |
277 | | |
278 | | //////////////////////////////////////////////////////////////////////// |
279 | | |
280 | | IMPL_FLOAT_PROP(LinetoHorizontalAbs, X, 0) |
281 | | |
282 | | |
283 | | //////////////////////////////////////////////////////////////////////// |
284 | | |
285 | | IMPL_FLOAT_PROP(LinetoHorizontalRel, X, 0) |
286 | | |
287 | | |
288 | | //////////////////////////////////////////////////////////////////////// |
289 | | |
290 | | IMPL_FLOAT_PROP(LinetoVerticalAbs, Y, 0) |
291 | | |
292 | | |
293 | | //////////////////////////////////////////////////////////////////////// |
294 | | |
295 | | IMPL_FLOAT_PROP(LinetoVerticalRel, Y, 0) |
296 | | |
297 | | |
298 | | //////////////////////////////////////////////////////////////////////// |
299 | | |
300 | | IMPL_FLOAT_PROP(CurvetoCubicSmoothAbs, X2, 0) |
301 | | IMPL_FLOAT_PROP(CurvetoCubicSmoothAbs, Y2, 1) |
302 | | IMPL_FLOAT_PROP(CurvetoCubicSmoothAbs, X, 2) |
303 | | IMPL_FLOAT_PROP(CurvetoCubicSmoothAbs, Y, 3) |
304 | | |
305 | | |
306 | | //////////////////////////////////////////////////////////////////////// |
307 | | |
308 | | IMPL_FLOAT_PROP(CurvetoCubicSmoothRel, X2, 0) |
309 | | IMPL_FLOAT_PROP(CurvetoCubicSmoothRel, Y2, 1) |
310 | | IMPL_FLOAT_PROP(CurvetoCubicSmoothRel, X, 2) |
311 | | IMPL_FLOAT_PROP(CurvetoCubicSmoothRel, Y, 3) |
312 | | |
313 | | |
314 | | //////////////////////////////////////////////////////////////////////// |
315 | | |
316 | | IMPL_FLOAT_PROP(CurvetoQuadraticSmoothAbs, X, 0) |
317 | | IMPL_FLOAT_PROP(CurvetoQuadraticSmoothAbs, Y, 1) |
318 | | |
319 | | |
320 | | //////////////////////////////////////////////////////////////////////// |
321 | | |
322 | | |
323 | | IMPL_FLOAT_PROP(CurvetoQuadraticSmoothRel, X, 0) |
324 | | IMPL_FLOAT_PROP(CurvetoQuadraticSmoothRel, Y, 1) |
325 | | |
326 | | |
327 | | |
328 | | // This must come after DOMSVGPathSegClosePath et. al. have been declared. |
329 | | /* static */ DOMSVGPathSeg* |
330 | | DOMSVGPathSeg::CreateFor(DOMSVGPathSegList *aList, |
331 | | uint32_t aListIndex, |
332 | | bool aIsAnimValItem) |
333 | 0 | { |
334 | 0 | uint32_t dataIndex = aList->mItems[aListIndex].mInternalDataIndex; |
335 | 0 | float *data = &aList->InternalList().mData[dataIndex]; |
336 | 0 | uint32_t type = SVGPathSegUtils::DecodeType(data[0]); |
337 | 0 |
|
338 | 0 | switch (type) |
339 | 0 | { |
340 | 0 | case PATHSEG_CLOSEPATH: |
341 | 0 | return new DOMSVGPathSegClosePath(aList, aListIndex, aIsAnimValItem); |
342 | 0 | case PATHSEG_MOVETO_ABS: |
343 | 0 | return new DOMSVGPathSegMovetoAbs(aList, aListIndex, aIsAnimValItem); |
344 | 0 | case PATHSEG_MOVETO_REL: |
345 | 0 | return new DOMSVGPathSegMovetoRel(aList, aListIndex, aIsAnimValItem); |
346 | 0 | case PATHSEG_LINETO_ABS: |
347 | 0 | return new DOMSVGPathSegLinetoAbs(aList, aListIndex, aIsAnimValItem); |
348 | 0 | case PATHSEG_LINETO_REL: |
349 | 0 | return new DOMSVGPathSegLinetoRel(aList, aListIndex, aIsAnimValItem); |
350 | 0 | case PATHSEG_CURVETO_CUBIC_ABS: |
351 | 0 | return new DOMSVGPathSegCurvetoCubicAbs(aList, aListIndex, aIsAnimValItem); |
352 | 0 | case PATHSEG_CURVETO_CUBIC_REL: |
353 | 0 | return new DOMSVGPathSegCurvetoCubicRel(aList, aListIndex, aIsAnimValItem); |
354 | 0 | case PATHSEG_CURVETO_QUADRATIC_ABS: |
355 | 0 | return new DOMSVGPathSegCurvetoQuadraticAbs(aList, aListIndex, aIsAnimValItem); |
356 | 0 | case PATHSEG_CURVETO_QUADRATIC_REL: |
357 | 0 | return new DOMSVGPathSegCurvetoQuadraticRel(aList, aListIndex, aIsAnimValItem); |
358 | 0 | case PATHSEG_ARC_ABS: |
359 | 0 | return new DOMSVGPathSegArcAbs(aList, aListIndex, aIsAnimValItem); |
360 | 0 | case PATHSEG_ARC_REL: |
361 | 0 | return new DOMSVGPathSegArcRel(aList, aListIndex, aIsAnimValItem); |
362 | 0 | case PATHSEG_LINETO_HORIZONTAL_ABS: |
363 | 0 | return new DOMSVGPathSegLinetoHorizontalAbs(aList, aListIndex, aIsAnimValItem); |
364 | 0 | case PATHSEG_LINETO_HORIZONTAL_REL: |
365 | 0 | return new DOMSVGPathSegLinetoHorizontalRel(aList, aListIndex, aIsAnimValItem); |
366 | 0 | case PATHSEG_LINETO_VERTICAL_ABS: |
367 | 0 | return new DOMSVGPathSegLinetoVerticalAbs(aList, aListIndex, aIsAnimValItem); |
368 | 0 | case PATHSEG_LINETO_VERTICAL_REL: |
369 | 0 | return new DOMSVGPathSegLinetoVerticalRel(aList, aListIndex, aIsAnimValItem); |
370 | 0 | case PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: |
371 | 0 | return new DOMSVGPathSegCurvetoCubicSmoothAbs(aList, aListIndex, aIsAnimValItem); |
372 | 0 | case PATHSEG_CURVETO_CUBIC_SMOOTH_REL: |
373 | 0 | return new DOMSVGPathSegCurvetoCubicSmoothRel(aList, aListIndex, aIsAnimValItem); |
374 | 0 | case PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: |
375 | 0 | return new DOMSVGPathSegCurvetoQuadraticSmoothAbs(aList, aListIndex, aIsAnimValItem); |
376 | 0 | case PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: |
377 | 0 | return new DOMSVGPathSegCurvetoQuadraticSmoothRel(aList, aListIndex, aIsAnimValItem); |
378 | 0 | default: |
379 | 0 | MOZ_ASSERT_UNREACHABLE("Invalid path segment type"); |
380 | 0 | return nullptr; |
381 | 0 | } |
382 | 0 | } |
383 | | |
384 | | } // namespace mozilla |