/work/obj-fuzz/dom/bindings/XMLSerializerBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM XMLSerializer.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "WrapperFactory.h" |
4 | | #include "XMLSerializerBinding.h" |
5 | | #include "mozilla/OwningNonNull.h" |
6 | | #include "mozilla/dom/BindingUtils.h" |
7 | | #include "mozilla/dom/DOMJSClass.h" |
8 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
9 | | #include "mozilla/dom/Nullable.h" |
10 | | #include "mozilla/dom/XrayExpandoClass.h" |
11 | | #include "nsContentUtils.h" |
12 | | #include "nsDOMSerializer.h" |
13 | | #include "nsINode.h" |
14 | | #include "nsIOutputStream.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 XMLSerializer_Binding { |
24 | | |
25 | | MOZ_CAN_RUN_SCRIPT static bool |
26 | | serializeToString(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMSerializer* self, const JSJitMethodCallArgs& args) |
27 | 0 | { |
28 | 0 | AUTO_PROFILER_LABEL_FAST("XMLSerializer.serializeToString", DOM, cx); |
29 | 0 |
|
30 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
31 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XMLSerializer.serializeToString"); |
32 | 0 | } |
33 | 0 | NonNull<nsINode> arg0; |
34 | 0 | if (args[0].isObject()) { |
35 | 0 | { |
36 | 0 | nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0); |
37 | 0 | if (NS_FAILED(rv)) { |
38 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of XMLSerializer.serializeToString", "Node"); |
39 | 0 | return false; |
40 | 0 | } |
41 | 0 | } |
42 | 0 | } else { |
43 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of XMLSerializer.serializeToString"); |
44 | 0 | return false; |
45 | 0 | } |
46 | 0 | FastErrorResult rv; |
47 | 0 | DOMString result; |
48 | 0 | self->SerializeToString(MOZ_KnownLive(NonNullHelper(arg0)), result, rv); |
49 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
50 | 0 | return false; |
51 | 0 | } |
52 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
53 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
54 | 0 | return false; |
55 | 0 | } |
56 | 0 | return true; |
57 | 0 | } |
58 | | |
59 | | static const JSJitInfo serializeToString_methodinfo = { |
60 | | { (JSJitGetterOp)serializeToString }, |
61 | | { prototypes::id::XMLSerializer }, |
62 | | { PrototypeTraits<prototypes::id::XMLSerializer>::Depth }, |
63 | | JSJitInfo::Method, |
64 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
65 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
66 | | false, /* isInfallible. False in setters. */ |
67 | | false, /* isMovable. Not relevant for setters. */ |
68 | | false, /* isEliminatable. Not relevant for setters. */ |
69 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
70 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
71 | | false, /* isTypedMethod. Only relevant for methods. */ |
72 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
73 | | }; |
74 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
75 | | static_assert(0 < 1, "There is no slot for us"); |
76 | | |
77 | | MOZ_CAN_RUN_SCRIPT static bool |
78 | | serializeToStream(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMSerializer* self, const JSJitMethodCallArgs& args) |
79 | 0 | { |
80 | 0 | AUTO_PROFILER_LABEL_FAST("XMLSerializer.serializeToStream", DOM, cx); |
81 | 0 |
|
82 | 0 | if (MOZ_UNLIKELY(args.length() < 3)) { |
83 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XMLSerializer.serializeToStream"); |
84 | 0 | } |
85 | 0 | NonNull<nsINode> arg0; |
86 | 0 | if (args[0].isObject()) { |
87 | 0 | { |
88 | 0 | nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0); |
89 | 0 | if (NS_FAILED(rv)) { |
90 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of XMLSerializer.serializeToStream", "Node"); |
91 | 0 | return false; |
92 | 0 | } |
93 | 0 | } |
94 | 0 | } else { |
95 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of XMLSerializer.serializeToStream"); |
96 | 0 | return false; |
97 | 0 | } |
98 | 0 | nsIOutputStream* arg1; |
99 | 0 | RefPtr<nsIOutputStream> arg1_holder; |
100 | 0 | if (args[1].isObject()) { |
101 | 0 | JS::Rooted<JSObject*> source(cx, &args[1].toObject()); |
102 | 0 | if (NS_FAILED(UnwrapArg<nsIOutputStream>(cx, source, getter_AddRefs(arg1_holder)))) { |
103 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of XMLSerializer.serializeToStream", "OutputStream"); |
104 | 0 | return false; |
105 | 0 | } |
106 | 0 | MOZ_ASSERT(arg1_holder); |
107 | 0 | arg1 = arg1_holder; |
108 | 0 | } else { |
109 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of XMLSerializer.serializeToStream"); |
110 | 0 | return false; |
111 | 0 | } |
112 | 0 | binding_detail::FakeString arg2; |
113 | 0 | if (!ConvertJSValueToString(cx, args[2], eNull, eNull, arg2)) { |
114 | 0 | return false; |
115 | 0 | } |
116 | 0 | FastErrorResult rv; |
117 | 0 | self->SerializeToStream(MOZ_KnownLive(NonNullHelper(arg0)), MOZ_KnownLive(NonNullHelper(arg1)), NonNullHelper(Constify(arg2)), rv); |
118 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
119 | 0 | return false; |
120 | 0 | } |
121 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
122 | 0 | args.rval().setUndefined(); |
123 | 0 | return true; |
124 | 0 | } |
125 | | |
126 | | static const JSJitInfo serializeToStream_methodinfo = { |
127 | | { (JSJitGetterOp)serializeToStream }, |
128 | | { prototypes::id::XMLSerializer }, |
129 | | { PrototypeTraits<prototypes::id::XMLSerializer>::Depth }, |
130 | | JSJitInfo::Method, |
131 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
132 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
133 | | false, /* isInfallible. False in setters. */ |
134 | | false, /* isMovable. Not relevant for setters. */ |
135 | | false, /* isEliminatable. Not relevant for setters. */ |
136 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
137 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
138 | | false, /* isTypedMethod. Only relevant for methods. */ |
139 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
140 | | }; |
141 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
142 | | static_assert(0 < 1, "There is no slot for us"); |
143 | | |
144 | | static void |
145 | | _finalize(js::FreeOp* fop, JSObject* obj) |
146 | 0 | { |
147 | 0 | nsDOMSerializer* self = UnwrapPossiblyNotInitializedDOMObject<nsDOMSerializer>(obj); |
148 | 0 | if (self) { |
149 | 0 | AddForDeferredFinalization<nsDOMSerializer>(self); |
150 | 0 | } |
151 | 0 | } |
152 | | |
153 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
154 | | #if defined(__clang__) |
155 | | #pragma clang diagnostic push |
156 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
157 | | #endif |
158 | | static const JSFunctionSpec sMethods_specs[] = { |
159 | | JS_FNSPEC("serializeToString", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&serializeToString_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
160 | | JS_FS_END |
161 | | }; |
162 | | #if defined(__clang__) |
163 | | #pragma clang diagnostic pop |
164 | | #endif |
165 | | |
166 | | |
167 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
168 | | { nullptr, &sMethods_specs[0] }, |
169 | | { nullptr, nullptr } |
170 | | }; |
171 | | |
172 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
173 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
174 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
175 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
176 | | |
177 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
178 | | #if defined(__clang__) |
179 | | #pragma clang diagnostic push |
180 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
181 | | #endif |
182 | | static const JSFunctionSpec sChromeMethods_specs[] = { |
183 | | JS_FNSPEC("serializeToStream", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&serializeToStream_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
184 | | JS_FS_END |
185 | | }; |
186 | | #if defined(__clang__) |
187 | | #pragma clang diagnostic pop |
188 | | #endif |
189 | | |
190 | | |
191 | | static const Prefable<const JSFunctionSpec> sChromeMethods[] = { |
192 | | { nullptr, &sChromeMethods_specs[0] }, |
193 | | { nullptr, nullptr } |
194 | | }; |
195 | | |
196 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
197 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
198 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
199 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
200 | | |
201 | | |
202 | | static uint16_t sNativeProperties_sortedPropertyIndices[1]; |
203 | | static PropertyInfo sNativeProperties_propertyInfos[1]; |
204 | | |
205 | | static const NativePropertiesN<1> sNativeProperties = { |
206 | | false, 0, |
207 | | false, 0, |
208 | | true, 0 /* sMethods */, |
209 | | false, 0, |
210 | | false, 0, |
211 | | false, 0, |
212 | | false, 0, |
213 | | -1, |
214 | | 1, |
215 | | sNativeProperties_sortedPropertyIndices, |
216 | | { |
217 | | { sMethods, &sNativeProperties_propertyInfos[0] } |
218 | | } |
219 | | }; |
220 | | static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
221 | | "We have a property info count that is oversized"); |
222 | | |
223 | | static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1]; |
224 | | static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1]; |
225 | | |
226 | | static const NativePropertiesN<1> sChromeOnlyNativeProperties = { |
227 | | false, 0, |
228 | | false, 0, |
229 | | true, 0 /* sChromeMethods */, |
230 | | false, 0, |
231 | | false, 0, |
232 | | false, 0, |
233 | | false, 0, |
234 | | -1, |
235 | | 1, |
236 | | sChromeOnlyNativeProperties_sortedPropertyIndices, |
237 | | { |
238 | | { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] } |
239 | | } |
240 | | }; |
241 | | static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount), |
242 | | "We have a property info count that is oversized"); |
243 | | |
244 | | static bool |
245 | | _constructor(JSContext* cx, unsigned argc, JS::Value* vp) |
246 | 0 | { |
247 | 0 | AUTO_PROFILER_LABEL_FAST("XMLSerializer constructor", DOM, cx); |
248 | 0 |
|
249 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
250 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
251 | 0 | if (!args.isConstructing()) { |
252 | 0 | // XXXbz wish I could get the name from the callee instead of |
253 | 0 | // Adding more relocations |
254 | 0 | return ThrowConstructorWithoutNew(cx, "XMLSerializer"); |
255 | 0 | } |
256 | 0 | |
257 | 0 | JS::Rooted<JSObject*> desiredProto(cx); |
258 | 0 | if (!GetDesiredProto(cx, args, &desiredProto)) { |
259 | 0 | return false; |
260 | 0 | } |
261 | 0 | |
262 | 0 | GlobalObject global(cx, obj); |
263 | 0 | if (global.Failed()) { |
264 | 0 | return false; |
265 | 0 | } |
266 | 0 | |
267 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
268 | 0 | Maybe<JSAutoRealm> ar; |
269 | 0 | if (objIsXray) { |
270 | 0 | obj = js::CheckedUnwrap(obj); |
271 | 0 | if (!obj) { |
272 | 0 | return false; |
273 | 0 | } |
274 | 0 | ar.emplace(cx, obj); |
275 | 0 | if (!JS_WrapObject(cx, &desiredProto)) { |
276 | 0 | return false; |
277 | 0 | } |
278 | 0 | } |
279 | 0 | FastErrorResult rv; |
280 | 0 | auto result(StrongOrRawPtr<nsDOMSerializer>(nsDOMSerializer::Constructor(global, rv))); |
281 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
282 | 0 | return false; |
283 | 0 | } |
284 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
285 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
286 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
287 | 0 | if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval(), desiredProto)) { |
288 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
289 | 0 | return false; |
290 | 0 | } |
291 | 0 | return true; |
292 | 0 | } |
293 | | |
294 | | static const js::ClassOps sInterfaceObjectClassOps = { |
295 | | nullptr, /* addProperty */ |
296 | | nullptr, /* delProperty */ |
297 | | nullptr, /* enumerate */ |
298 | | nullptr, /* newEnumerate */ |
299 | | nullptr, /* resolve */ |
300 | | nullptr, /* mayResolve */ |
301 | | nullptr, /* finalize */ |
302 | | _constructor, /* call */ |
303 | | nullptr, /* hasInstance */ |
304 | | _constructor, /* construct */ |
305 | | nullptr, /* trace */ |
306 | | }; |
307 | | |
308 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
309 | | { |
310 | | "Function", |
311 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
312 | | &sInterfaceObjectClassOps, |
313 | | JS_NULL_CLASS_SPEC, |
314 | | JS_NULL_CLASS_EXT, |
315 | | &sInterfaceObjectClassObjectOps |
316 | | }, |
317 | | eInterface, |
318 | | true, |
319 | | prototypes::id::XMLSerializer, |
320 | | PrototypeTraits<prototypes::id::XMLSerializer>::Depth, |
321 | | sNativePropertyHooks, |
322 | | "function XMLSerializer() {\n [native code]\n}", |
323 | | JS::GetRealmFunctionPrototype |
324 | | }; |
325 | | |
326 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
327 | | { |
328 | | "XMLSerializerPrototype", |
329 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
330 | | JS_NULL_CLASS_OPS, |
331 | | JS_NULL_CLASS_SPEC, |
332 | | JS_NULL_CLASS_EXT, |
333 | | JS_NULL_OBJECT_OPS |
334 | | }, |
335 | | eInterfacePrototype, |
336 | | false, |
337 | | prototypes::id::XMLSerializer, |
338 | | PrototypeTraits<prototypes::id::XMLSerializer>::Depth, |
339 | | sNativePropertyHooks, |
340 | | "[object XMLSerializerPrototype]", |
341 | | JS::GetRealmObjectPrototype |
342 | | }; |
343 | | |
344 | | static const js::ClassOps sClassOps = { |
345 | | nullptr, /* addProperty */ |
346 | | nullptr, /* delProperty */ |
347 | | nullptr, /* enumerate */ |
348 | | nullptr, /* newEnumerate */ |
349 | | nullptr, /* resolve */ |
350 | | nullptr, /* mayResolve */ |
351 | | _finalize, /* finalize */ |
352 | | nullptr, /* call */ |
353 | | nullptr, /* hasInstance */ |
354 | | nullptr, /* construct */ |
355 | | nullptr, /* trace */ |
356 | | }; |
357 | | |
358 | | static const js::ClassExtension sClassExtension = { |
359 | | nullptr, /* weakmapKeyDelegateOp */ |
360 | | nullptr /* objectMovedOp */ |
361 | | }; |
362 | | |
363 | | static const DOMJSClass sClass = { |
364 | | { "XMLSerializer", |
365 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
366 | | &sClassOps, |
367 | | JS_NULL_CLASS_SPEC, |
368 | | &sClassExtension, |
369 | | JS_NULL_OBJECT_OPS |
370 | | }, |
371 | | { prototypes::id::XMLSerializer, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
372 | | IsBaseOf<nsISupports, nsDOMSerializer >::value, |
373 | | sNativePropertyHooks, |
374 | | FindAssociatedGlobalForNative<nsDOMSerializer>::Get, |
375 | | GetProtoObjectHandle, |
376 | | GetCCParticipant<nsDOMSerializer>::Get() |
377 | | }; |
378 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
379 | | "Must have the right minimal number of reserved slots."); |
380 | | static_assert(1 >= 1, |
381 | | "Must have enough reserved slots."); |
382 | | |
383 | | const JSClass* |
384 | | GetJSClass() |
385 | 0 | { |
386 | 0 | return sClass.ToJSClass(); |
387 | 0 | } |
388 | | |
389 | | bool |
390 | | Wrap(JSContext* aCx, nsDOMSerializer* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
391 | 0 | { |
392 | 0 | MOZ_ASSERT(static_cast<nsDOMSerializer*>(aObject) == |
393 | 0 | reinterpret_cast<nsDOMSerializer*>(aObject), |
394 | 0 | "Multiple inheritance for nsDOMSerializer is broken."); |
395 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
396 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
397 | 0 |
|
398 | 0 | JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx)); |
399 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
400 | 0 | if (!canonicalProto) { |
401 | 0 | return false; |
402 | 0 | } |
403 | 0 | JS::Rooted<JSObject*> proto(aCx); |
404 | 0 | if (aGivenProto) { |
405 | 0 | proto = aGivenProto; |
406 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
407 | 0 | // coming in, we changed compartments to that of "parent" so may need |
408 | 0 | // to wrap the proto here. |
409 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
410 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
411 | 0 | return false; |
412 | 0 | } |
413 | 0 | } |
414 | 0 | } else { |
415 | 0 | proto = canonicalProto; |
416 | 0 | } |
417 | 0 |
|
418 | 0 | BindingJSObjectCreator<nsDOMSerializer> creator(aCx); |
419 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
420 | 0 | if (!aReflector) { |
421 | 0 | return false; |
422 | 0 | } |
423 | 0 | |
424 | 0 | |
425 | 0 | |
426 | 0 | creator.InitializationSucceeded(); |
427 | 0 | return true; |
428 | 0 | } |
429 | | |
430 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
431 | | nullptr, |
432 | | nullptr, |
433 | | nullptr, |
434 | | { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() }, |
435 | | prototypes::id::XMLSerializer, |
436 | | constructors::id::XMLSerializer, |
437 | | nullptr, |
438 | | &DefaultXrayExpandoObjectClass |
439 | | } }; |
440 | | |
441 | | void |
442 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
443 | 0 | { |
444 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
445 | 0 | if (!parentProto) { |
446 | 0 | return; |
447 | 0 | } |
448 | 0 | |
449 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
450 | 0 | if (!constructorProto) { |
451 | 0 | return; |
452 | 0 | } |
453 | 0 | |
454 | 0 | static bool sIdsInited = false; |
455 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
456 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
457 | 0 | return; |
458 | 0 | } |
459 | 0 | if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) { |
460 | 0 | return; |
461 | 0 | } |
462 | 0 | sIdsInited = true; |
463 | 0 | } |
464 | 0 |
|
465 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::XMLSerializer); |
466 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::XMLSerializer); |
467 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
468 | 0 | &sPrototypeClass.mBase, protoCache, |
469 | 0 | nullptr, |
470 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
471 | 0 | interfaceCache, |
472 | 0 | sNativeProperties.Upcast(), |
473 | 0 | sChromeOnlyNativeProperties.Upcast(), |
474 | 0 | "XMLSerializer", aDefineOnGlobal, |
475 | 0 | nullptr, |
476 | 0 | false); |
477 | 0 | } |
478 | | |
479 | | JSObject* |
480 | | GetConstructorObject(JSContext* aCx) |
481 | 0 | { |
482 | 0 | return GetConstructorObjectHandle(aCx); |
483 | 0 | } |
484 | | |
485 | | } // namespace XMLSerializer_Binding |
486 | | |
487 | | |
488 | | |
489 | | } // namespace dom |
490 | | } // namespace mozilla |