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