/work/obj-fuzz/dom/bindings/SVGTextPathElementBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM SVGTextPathElement.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "SVGTextContentElementBinding.h" |
4 | | #include "SVGTextPathElementBinding.h" |
5 | | #include "WrapperFactory.h" |
6 | | #include "mozilla/OwningNonNull.h" |
7 | | #include "mozilla/dom/BindingUtils.h" |
8 | | #include "mozilla/dom/DOMJSClass.h" |
9 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
10 | | #include "mozilla/dom/SVGAnimatedEnumeration.h" |
11 | | #include "mozilla/dom/SVGAnimatedLength.h" |
12 | | #include "mozilla/dom/SVGAnimatedString.h" |
13 | | #include "mozilla/dom/SVGTextPathElement.h" |
14 | | #include "mozilla/dom/XrayExpandoClass.h" |
15 | | |
16 | | namespace mozilla { |
17 | | namespace dom { |
18 | | |
19 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
20 | | using namespace mozilla::dom::binding_detail; |
21 | | |
22 | | |
23 | | namespace SVGTextPathElement_Binding { |
24 | | |
25 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<SVGTextContentElement_Binding::NativeType>::value, |
26 | | "Can't inherit from an interface with a different ownership model."); |
27 | | |
28 | | MOZ_CAN_RUN_SCRIPT static bool |
29 | | get_startOffset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGTextPathElement* self, JSJitGetterCallArgs args) |
30 | 0 | { |
31 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGTextPathElement.startOffset", DOM, cx); |
32 | 0 |
|
33 | 0 | auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedLength>(self->StartOffset())); |
34 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
35 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
36 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
37 | 0 | return false; |
38 | 0 | } |
39 | 0 | return true; |
40 | 0 | } |
41 | | |
42 | | static const JSJitInfo startOffset_getterinfo = { |
43 | | { (JSJitGetterOp)get_startOffset }, |
44 | | { prototypes::id::SVGTextPathElement }, |
45 | | { PrototypeTraits<prototypes::id::SVGTextPathElement>::Depth }, |
46 | | JSJitInfo::Getter, |
47 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
48 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
49 | | false, /* isInfallible. False in setters. */ |
50 | | true, /* isMovable. Not relevant for setters. */ |
51 | | true, /* isEliminatable. Not relevant for setters. */ |
52 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
53 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
54 | | false, /* isTypedMethod. Only relevant for methods. */ |
55 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
56 | | }; |
57 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
58 | | static_assert(0 < 1, "There is no slot for us"); |
59 | | |
60 | | MOZ_CAN_RUN_SCRIPT static bool |
61 | | get_method(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGTextPathElement* self, JSJitGetterCallArgs args) |
62 | 0 | { |
63 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGTextPathElement.method", DOM, cx); |
64 | 0 |
|
65 | 0 | auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedEnumeration>(self->Method())); |
66 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
67 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
68 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
69 | 0 | return false; |
70 | 0 | } |
71 | 0 | return true; |
72 | 0 | } |
73 | | |
74 | | static const JSJitInfo method_getterinfo = { |
75 | | { (JSJitGetterOp)get_method }, |
76 | | { prototypes::id::SVGTextPathElement }, |
77 | | { PrototypeTraits<prototypes::id::SVGTextPathElement>::Depth }, |
78 | | JSJitInfo::Getter, |
79 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
80 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
81 | | false, /* isInfallible. False in setters. */ |
82 | | true, /* isMovable. Not relevant for setters. */ |
83 | | true, /* isEliminatable. Not relevant for setters. */ |
84 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
85 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
86 | | false, /* isTypedMethod. Only relevant for methods. */ |
87 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
88 | | }; |
89 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
90 | | static_assert(0 < 1, "There is no slot for us"); |
91 | | |
92 | | MOZ_CAN_RUN_SCRIPT static bool |
93 | | get_spacing(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGTextPathElement* self, JSJitGetterCallArgs args) |
94 | 0 | { |
95 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGTextPathElement.spacing", DOM, cx); |
96 | 0 |
|
97 | 0 | auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedEnumeration>(self->Spacing())); |
98 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
99 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
100 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
101 | 0 | return false; |
102 | 0 | } |
103 | 0 | return true; |
104 | 0 | } |
105 | | |
106 | | static const JSJitInfo spacing_getterinfo = { |
107 | | { (JSJitGetterOp)get_spacing }, |
108 | | { prototypes::id::SVGTextPathElement }, |
109 | | { PrototypeTraits<prototypes::id::SVGTextPathElement>::Depth }, |
110 | | JSJitInfo::Getter, |
111 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
112 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
113 | | false, /* isInfallible. False in setters. */ |
114 | | true, /* isMovable. Not relevant for setters. */ |
115 | | true, /* isEliminatable. Not relevant for setters. */ |
116 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
117 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
118 | | false, /* isTypedMethod. Only relevant for methods. */ |
119 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
120 | | }; |
121 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
122 | | static_assert(0 < 1, "There is no slot for us"); |
123 | | |
124 | | MOZ_CAN_RUN_SCRIPT static bool |
125 | | get_href(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGTextPathElement* self, JSJitGetterCallArgs args) |
126 | 0 | { |
127 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGTextPathElement.href", DOM, cx); |
128 | 0 |
|
129 | 0 | auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedString>(self->Href())); |
130 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
131 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
132 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
133 | 0 | return false; |
134 | 0 | } |
135 | 0 | return true; |
136 | 0 | } |
137 | | |
138 | | static const JSJitInfo href_getterinfo = { |
139 | | { (JSJitGetterOp)get_href }, |
140 | | { prototypes::id::SVGTextPathElement }, |
141 | | { PrototypeTraits<prototypes::id::SVGTextPathElement>::Depth }, |
142 | | JSJitInfo::Getter, |
143 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
144 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
145 | | false, /* isInfallible. False in setters. */ |
146 | | true, /* isMovable. Not relevant for setters. */ |
147 | | true, /* isEliminatable. Not relevant for setters. */ |
148 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
149 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
150 | | false, /* isTypedMethod. Only relevant for methods. */ |
151 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
152 | | }; |
153 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
154 | | static_assert(0 < 1, "There is no slot for us"); |
155 | | |
156 | | static bool |
157 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
158 | 0 | { |
159 | 0 | mozilla::dom::SVGTextPathElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGTextPathElement>(obj); |
160 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
161 | 0 | // obviously can't preserve if we're not initialized. |
162 | 0 | if (self && self->GetWrapperPreserveColor()) { |
163 | 0 | PreserveWrapper(self); |
164 | 0 | } |
165 | 0 | return true; |
166 | 0 | } |
167 | | |
168 | | static void |
169 | | _finalize(js::FreeOp* fop, JSObject* obj) |
170 | 0 | { |
171 | 0 | mozilla::dom::SVGTextPathElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGTextPathElement>(obj); |
172 | 0 | if (self) { |
173 | 0 | ClearWrapper(self, self, obj); |
174 | 0 | AddForDeferredFinalization<mozilla::dom::SVGTextPathElement>(self); |
175 | 0 | } |
176 | 0 | } |
177 | | |
178 | | static size_t |
179 | | _objectMoved(JSObject* obj, JSObject* old) |
180 | 0 | { |
181 | 0 | mozilla::dom::SVGTextPathElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGTextPathElement>(obj); |
182 | 0 | if (self) { |
183 | 0 | UpdateWrapper(self, self, obj, old); |
184 | 0 | } |
185 | 0 |
|
186 | 0 | return 0; |
187 | 0 | } |
188 | | |
189 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
190 | | #if defined(__clang__) |
191 | | #pragma clang diagnostic push |
192 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
193 | | #endif |
194 | | static const JSPropertySpec sAttributes_specs[] = { |
195 | | { "startOffset", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &startOffset_getterinfo, nullptr, nullptr }, |
196 | | { "method", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &method_getterinfo, nullptr, nullptr }, |
197 | | { "spacing", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &spacing_getterinfo, nullptr, nullptr }, |
198 | | { "href", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &href_getterinfo, nullptr, nullptr }, |
199 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
200 | | }; |
201 | | #if defined(__clang__) |
202 | | #pragma clang diagnostic pop |
203 | | #endif |
204 | | |
205 | | |
206 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
207 | | { nullptr, &sAttributes_specs[0] }, |
208 | | { nullptr, nullptr } |
209 | | }; |
210 | | |
211 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
212 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
213 | | static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
214 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
215 | | |
216 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
217 | | #if defined(__clang__) |
218 | | #pragma clang diagnostic push |
219 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
220 | | #endif |
221 | | static const ConstantSpec sConstants_specs[] = { |
222 | | { "TEXTPATH_METHODTYPE_UNKNOWN", JS::Int32Value(0) }, |
223 | | { "TEXTPATH_METHODTYPE_ALIGN", JS::Int32Value(1) }, |
224 | | { "TEXTPATH_METHODTYPE_STRETCH", JS::Int32Value(2) }, |
225 | | { "TEXTPATH_SPACINGTYPE_UNKNOWN", JS::Int32Value(0) }, |
226 | | { "TEXTPATH_SPACINGTYPE_AUTO", JS::Int32Value(1) }, |
227 | | { "TEXTPATH_SPACINGTYPE_EXACT", JS::Int32Value(2) }, |
228 | | { 0, JS::UndefinedValue() } |
229 | | }; |
230 | | #if defined(__clang__) |
231 | | #pragma clang diagnostic pop |
232 | | #endif |
233 | | |
234 | | |
235 | | static const Prefable<const ConstantSpec> sConstants[] = { |
236 | | { nullptr, &sConstants_specs[0] }, |
237 | | { nullptr, nullptr } |
238 | | }; |
239 | | |
240 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
241 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
242 | | static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
243 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
244 | | |
245 | | |
246 | | static uint16_t sNativeProperties_sortedPropertyIndices[10]; |
247 | | static PropertyInfo sNativeProperties_propertyInfos[10]; |
248 | | |
249 | | static const NativePropertiesN<2> sNativeProperties = { |
250 | | false, 0, |
251 | | false, 0, |
252 | | false, 0, |
253 | | true, 0 /* sAttributes */, |
254 | | false, 0, |
255 | | false, 0, |
256 | | true, 1 /* sConstants */, |
257 | | -1, |
258 | | 10, |
259 | | sNativeProperties_sortedPropertyIndices, |
260 | | { |
261 | | { sAttributes, &sNativeProperties_propertyInfos[0] }, |
262 | | { sConstants, &sNativeProperties_propertyInfos[4] } |
263 | | } |
264 | | }; |
265 | | static_assert(10 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
266 | | "We have a property info count that is oversized"); |
267 | | |
268 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
269 | | { |
270 | | "Function", |
271 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
272 | | &sBoringInterfaceObjectClassClassOps, |
273 | | JS_NULL_CLASS_SPEC, |
274 | | JS_NULL_CLASS_EXT, |
275 | | &sInterfaceObjectClassObjectOps |
276 | | }, |
277 | | eInterface, |
278 | | true, |
279 | | prototypes::id::SVGTextPathElement, |
280 | | PrototypeTraits<prototypes::id::SVGTextPathElement>::Depth, |
281 | | sNativePropertyHooks, |
282 | | "function SVGTextPathElement() {\n [native code]\n}", |
283 | | SVGTextContentElement_Binding::GetConstructorObject |
284 | | }; |
285 | | |
286 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
287 | | { |
288 | | "SVGTextPathElementPrototype", |
289 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
290 | | JS_NULL_CLASS_OPS, |
291 | | JS_NULL_CLASS_SPEC, |
292 | | JS_NULL_CLASS_EXT, |
293 | | JS_NULL_OBJECT_OPS |
294 | | }, |
295 | | eInterfacePrototype, |
296 | | false, |
297 | | prototypes::id::SVGTextPathElement, |
298 | | PrototypeTraits<prototypes::id::SVGTextPathElement>::Depth, |
299 | | sNativePropertyHooks, |
300 | | "[object SVGTextPathElementPrototype]", |
301 | | SVGTextContentElement_Binding::GetProtoObject |
302 | | }; |
303 | | |
304 | | static const js::ClassOps sClassOps = { |
305 | | _addProperty, /* addProperty */ |
306 | | nullptr, /* delProperty */ |
307 | | nullptr, /* enumerate */ |
308 | | nullptr, /* newEnumerate */ |
309 | | nullptr, /* resolve */ |
310 | | nullptr, /* mayResolve */ |
311 | | _finalize, /* finalize */ |
312 | | nullptr, /* call */ |
313 | | nullptr, /* hasInstance */ |
314 | | nullptr, /* construct */ |
315 | | nullptr, /* trace */ |
316 | | }; |
317 | | |
318 | | static const js::ClassExtension sClassExtension = { |
319 | | nullptr, /* weakmapKeyDelegateOp */ |
320 | | _objectMoved /* objectMovedOp */ |
321 | | }; |
322 | | |
323 | | static const DOMJSClass sClass = { |
324 | | { "SVGTextPathElement", |
325 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
326 | | &sClassOps, |
327 | | JS_NULL_CLASS_SPEC, |
328 | | &sClassExtension, |
329 | | JS_NULL_OBJECT_OPS |
330 | | }, |
331 | | { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::SVGElement, prototypes::id::SVGGraphicsElement, prototypes::id::SVGTextContentElement, prototypes::id::SVGTextPathElement, prototypes::id::_ID_Count }, |
332 | | IsBaseOf<nsISupports, mozilla::dom::SVGTextPathElement >::value, |
333 | | sNativePropertyHooks, |
334 | | FindAssociatedGlobalForNative<mozilla::dom::SVGTextPathElement>::Get, |
335 | | GetProtoObjectHandle, |
336 | | GetCCParticipant<mozilla::dom::SVGTextPathElement>::Get() |
337 | | }; |
338 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
339 | | "Must have the right minimal number of reserved slots."); |
340 | | static_assert(1 >= 1, |
341 | | "Must have enough reserved slots."); |
342 | | |
343 | | const JSClass* |
344 | | GetJSClass() |
345 | 0 | { |
346 | 0 | return sClass.ToJSClass(); |
347 | 0 | } |
348 | | |
349 | | bool |
350 | | Wrap(JSContext* aCx, mozilla::dom::SVGTextPathElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
351 | 0 | { |
352 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::SVGTextPathElement>::value, |
353 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
354 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::SVGTextPathElement*>(aObject) == |
355 | 0 | reinterpret_cast<mozilla::dom::SVGTextPathElement*>(aObject), |
356 | 0 | "Multiple inheritance for mozilla::dom::SVGTextPathElement is broken."); |
357 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::SVGTextContentElement*>(aObject) == |
358 | 0 | reinterpret_cast<mozilla::dom::SVGTextContentElement*>(aObject), |
359 | 0 | "Multiple inheritance for mozilla::dom::SVGTextContentElement is broken."); |
360 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::SVGGraphicsElement*>(aObject) == |
361 | 0 | reinterpret_cast<mozilla::dom::SVGGraphicsElement*>(aObject), |
362 | 0 | "Multiple inheritance for mozilla::dom::SVGGraphicsElement is broken."); |
363 | 0 | MOZ_ASSERT(static_cast<nsSVGElement*>(aObject) == |
364 | 0 | reinterpret_cast<nsSVGElement*>(aObject), |
365 | 0 | "Multiple inheritance for nsSVGElement is broken."); |
366 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) == |
367 | 0 | reinterpret_cast<mozilla::dom::Element*>(aObject), |
368 | 0 | "Multiple inheritance for mozilla::dom::Element is broken."); |
369 | 0 | MOZ_ASSERT(static_cast<nsINode*>(aObject) == |
370 | 0 | reinterpret_cast<nsINode*>(aObject), |
371 | 0 | "Multiple inheritance for nsINode is broken."); |
372 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
373 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
374 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
375 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
376 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
377 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
378 | 0 | "You should probably not be using Wrap() directly; use " |
379 | 0 | "GetOrCreateDOMReflector instead"); |
380 | 0 |
|
381 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
382 | 0 | "nsISupports must be on our primary inheritance chain"); |
383 | 0 |
|
384 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
385 | 0 | if (!global) { |
386 | 0 | return false; |
387 | 0 | } |
388 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
389 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
390 | 0 |
|
391 | 0 | // That might have ended up wrapping us already, due to the wonders |
392 | 0 | // of XBL. Check for that, and bail out as needed. |
393 | 0 | aReflector.set(aCache->GetWrapper()); |
394 | 0 | if (aReflector) { |
395 | | #ifdef DEBUG |
396 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
397 | | #endif // DEBUG |
398 | | return true; |
399 | 0 | } |
400 | 0 |
|
401 | 0 | JSAutoRealm ar(aCx, global); |
402 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
403 | 0 | if (!canonicalProto) { |
404 | 0 | return false; |
405 | 0 | } |
406 | 0 | JS::Rooted<JSObject*> proto(aCx); |
407 | 0 | if (aGivenProto) { |
408 | 0 | proto = aGivenProto; |
409 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
410 | 0 | // coming in, we changed compartments to that of "parent" so may need |
411 | 0 | // to wrap the proto here. |
412 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
413 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
414 | 0 | return false; |
415 | 0 | } |
416 | 0 | } |
417 | 0 | } else { |
418 | 0 | proto = canonicalProto; |
419 | 0 | } |
420 | 0 |
|
421 | 0 | BindingJSObjectCreator<mozilla::dom::SVGTextPathElement> creator(aCx); |
422 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
423 | 0 | if (!aReflector) { |
424 | 0 | return false; |
425 | 0 | } |
426 | 0 | |
427 | 0 | aCache->SetWrapper(aReflector); |
428 | 0 | creator.InitializationSucceeded(); |
429 | 0 |
|
430 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
431 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
432 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
433 | 0 | // otherwise we won't be able to properly recreate it later, since |
434 | 0 | // we won't know what proto to use. Note that we don't check |
435 | 0 | // aGivenProto here, since it's entirely possible (and even |
436 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
437 | 0 | // same as canonicalProto. |
438 | 0 | if (proto != canonicalProto) { |
439 | 0 | PreserveWrapper(aObject); |
440 | 0 | } |
441 | 0 |
|
442 | 0 | return true; |
443 | 0 | } |
444 | | |
445 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
446 | | nullptr, |
447 | | nullptr, |
448 | | nullptr, |
449 | | { sNativeProperties.Upcast(), nullptr }, |
450 | | prototypes::id::SVGTextPathElement, |
451 | | constructors::id::SVGTextPathElement, |
452 | | SVGTextContentElement_Binding::sNativePropertyHooks, |
453 | | &DefaultXrayExpandoObjectClass |
454 | | } }; |
455 | | |
456 | | void |
457 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
458 | 0 | { |
459 | 0 | JS::Handle<JSObject*> parentProto(SVGTextContentElement_Binding::GetProtoObjectHandle(aCx)); |
460 | 0 | if (!parentProto) { |
461 | 0 | return; |
462 | 0 | } |
463 | 0 | |
464 | 0 | JS::Handle<JSObject*> constructorProto(SVGTextContentElement_Binding::GetConstructorObjectHandle(aCx)); |
465 | 0 | if (!constructorProto) { |
466 | 0 | return; |
467 | 0 | } |
468 | 0 | |
469 | 0 | static bool sIdsInited = false; |
470 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
471 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
472 | 0 | return; |
473 | 0 | } |
474 | 0 | sIdsInited = true; |
475 | 0 | } |
476 | 0 |
|
477 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SVGTextPathElement); |
478 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGTextPathElement); |
479 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
480 | 0 | &sPrototypeClass.mBase, protoCache, |
481 | 0 | nullptr, |
482 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
483 | 0 | interfaceCache, |
484 | 0 | sNativeProperties.Upcast(), |
485 | 0 | nullptr, |
486 | 0 | "SVGTextPathElement", aDefineOnGlobal, |
487 | 0 | nullptr, |
488 | 0 | false); |
489 | 0 | } |
490 | | |
491 | | JSObject* |
492 | | GetConstructorObject(JSContext* aCx) |
493 | 0 | { |
494 | 0 | return GetConstructorObjectHandle(aCx); |
495 | 0 | } |
496 | | |
497 | | } // namespace SVGTextPathElement_Binding |
498 | | |
499 | | |
500 | | |
501 | | } // namespace dom |
502 | | } // namespace mozilla |