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