/work/obj-fuzz/dom/bindings/GroupedHistoryEventBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM GroupedHistoryEvent.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AtomList.h" |
4 | | #include "EventBinding.h" |
5 | | #include "GroupedHistoryEventBinding.h" |
6 | | #include "WrapperFactory.h" |
7 | | #include "mozilla/OwningNonNull.h" |
8 | | #include "mozilla/dom/BindingUtils.h" |
9 | | #include "mozilla/dom/DOMJSClass.h" |
10 | | #include "mozilla/dom/Element.h" |
11 | | #include "mozilla/dom/GroupedHistoryEvent.h" |
12 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
13 | | #include "mozilla/dom/Nullable.h" |
14 | | #include "mozilla/dom/PrimitiveConversions.h" |
15 | | #include "mozilla/dom/ScriptSettings.h" |
16 | | #include "mozilla/dom/XrayExpandoClass.h" |
17 | | #include "nsContentUtils.h" |
18 | | |
19 | | namespace mozilla { |
20 | | namespace dom { |
21 | | |
22 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
23 | | using namespace mozilla::dom::binding_detail; |
24 | | |
25 | | |
26 | | |
27 | | GroupedHistoryEventInit::GroupedHistoryEventInit() |
28 | | : EventInit(FastDictionaryInitializer()) |
29 | 0 | { |
30 | 0 | // Safe to pass a null context if we pass a null value |
31 | 0 | Init(nullptr, JS::NullHandleValue); |
32 | 0 | } |
33 | | |
34 | | |
35 | | |
36 | | bool |
37 | | GroupedHistoryEventInit::InitIds(JSContext* cx, GroupedHistoryEventInitAtoms* atomsCache) |
38 | 0 | { |
39 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
40 | 0 |
|
41 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
42 | 0 | // uninitialized. |
43 | 0 | if (!atomsCache->otherBrowser_id.init(cx, "otherBrowser")) { |
44 | 0 | return false; |
45 | 0 | } |
46 | 0 | return true; |
47 | 0 | } |
48 | | |
49 | | bool |
50 | | GroupedHistoryEventInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
51 | 0 | { |
52 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
53 | 0 | // Since in that case we will not have to do any property gets |
54 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
55 | 0 | // checkers by static analysis tools |
56 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
57 | 0 | GroupedHistoryEventInitAtoms* atomsCache = nullptr; |
58 | 0 | if (cx) { |
59 | 0 | atomsCache = GetAtomCache<GroupedHistoryEventInitAtoms>(cx); |
60 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
61 | 0 | return false; |
62 | 0 | } |
63 | 0 | } |
64 | 0 | |
65 | 0 | // Per spec, we init the parent's members first |
66 | 0 | if (!EventInit::Init(cx, val)) { |
67 | 0 | return false; |
68 | 0 | } |
69 | 0 | |
70 | 0 | bool isNull = val.isNullOrUndefined(); |
71 | 0 | // We only need these if !isNull, in which case we have |cx|. |
72 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
73 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
74 | 0 | if (!isNull) { |
75 | 0 | MOZ_ASSERT(cx); |
76 | 0 | object.emplace(cx, &val.toObject()); |
77 | 0 | temp.emplace(cx); |
78 | 0 | } |
79 | 0 | if (!isNull) { |
80 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->otherBrowser_id, temp.ptr())) { |
81 | 0 | return false; |
82 | 0 | } |
83 | 0 | } |
84 | 0 | if (!isNull && !temp->isUndefined()) { |
85 | 0 | if (temp.ref().isObject()) { |
86 | 0 | static_assert(IsRefcounted<mozilla::dom::Element>::value, "We can only store refcounted classes.");{ |
87 | 0 | nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(temp.ptr(), mOtherBrowser); |
88 | 0 | if (NS_FAILED(rv)) { |
89 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'otherBrowser' member of GroupedHistoryEventInit", "Element"); |
90 | 0 | return false; |
91 | 0 | } |
92 | 0 | } |
93 | 0 | } else if (temp.ref().isNullOrUndefined()) { |
94 | 0 | mOtherBrowser = nullptr; |
95 | 0 | } else { |
96 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'otherBrowser' member of GroupedHistoryEventInit"); |
97 | 0 | return false; |
98 | 0 | } |
99 | 0 | } else { |
100 | 0 | mOtherBrowser = nullptr; |
101 | 0 | } |
102 | 0 | mIsAnyMemberPresent = true; |
103 | 0 | return true; |
104 | 0 | } |
105 | | |
106 | | bool |
107 | | GroupedHistoryEventInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
108 | 0 | { |
109 | 0 | GroupedHistoryEventInitAtoms* atomsCache = GetAtomCache<GroupedHistoryEventInitAtoms>(cx); |
110 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
111 | 0 | return false; |
112 | 0 | } |
113 | 0 | |
114 | 0 | // Per spec, we define the parent's members first |
115 | 0 | if (!EventInit::ToObjectInternal(cx, rval)) { |
116 | 0 | return false; |
117 | 0 | } |
118 | 0 | JS::Rooted<JSObject*> obj(cx, &rval.toObject()); |
119 | 0 |
|
120 | 0 | do { |
121 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
122 | 0 | JS::Rooted<JS::Value> temp(cx); |
123 | 0 | RefPtr<mozilla::dom::Element> const & currentValue = mOtherBrowser; |
124 | 0 | if (!currentValue) { |
125 | 0 | temp.setNull(); |
126 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->otherBrowser_id, temp, JSPROP_ENUMERATE)) { |
127 | 0 | return false; |
128 | 0 | } |
129 | 0 | break; |
130 | 0 | } |
131 | 0 | if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) { |
132 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
133 | 0 | return false; |
134 | 0 | } |
135 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->otherBrowser_id, temp, JSPROP_ENUMERATE)) { |
136 | 0 | return false; |
137 | 0 | } |
138 | 0 | break; |
139 | 0 | } while(false); |
140 | 0 |
|
141 | 0 | return true; |
142 | 0 | } |
143 | | |
144 | | void |
145 | | GroupedHistoryEventInit::TraceDictionary(JSTracer* trc) |
146 | 0 | { |
147 | 0 | EventInit::TraceDictionary(trc); |
148 | 0 | } |
149 | | |
150 | | |
151 | | |
152 | | GroupedHistoryEventInit& |
153 | | GroupedHistoryEventInit::operator=(const GroupedHistoryEventInit& aOther) |
154 | 0 | { |
155 | 0 | EventInit::operator=(aOther); |
156 | 0 | mOtherBrowser = aOther.mOtherBrowser; |
157 | 0 | return *this; |
158 | 0 | } |
159 | | |
160 | | namespace binding_detail { |
161 | | } // namespace binding_detail |
162 | | |
163 | | |
164 | | namespace GroupedHistoryEvent_Binding { |
165 | | |
166 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<Event_Binding::NativeType>::value, |
167 | | "Can't inherit from an interface with a different ownership model."); |
168 | | |
169 | | MOZ_CAN_RUN_SCRIPT static bool |
170 | | get_otherBrowser(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GroupedHistoryEvent* self, JSJitGetterCallArgs args) |
171 | 0 | { |
172 | 0 | AUTO_PROFILER_LABEL_FAST("get GroupedHistoryEvent.otherBrowser", DOM, cx); |
173 | 0 |
|
174 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Element>(self->GetOtherBrowser())); |
175 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
176 | 0 | if (!result) { |
177 | 0 | args.rval().setNull(); |
178 | 0 | return true; |
179 | 0 | } |
180 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
181 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
182 | 0 | return false; |
183 | 0 | } |
184 | 0 | return true; |
185 | 0 | } |
186 | | |
187 | | static const JSJitInfo otherBrowser_getterinfo = { |
188 | | { (JSJitGetterOp)get_otherBrowser }, |
189 | | { prototypes::id::GroupedHistoryEvent }, |
190 | | { PrototypeTraits<prototypes::id::GroupedHistoryEvent>::Depth }, |
191 | | JSJitInfo::Getter, |
192 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
193 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
194 | | false, /* isInfallible. False in setters. */ |
195 | | false, /* isMovable. Not relevant for setters. */ |
196 | | false, /* isEliminatable. Not relevant for setters. */ |
197 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
198 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
199 | | false, /* isTypedMethod. Only relevant for methods. */ |
200 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
201 | | }; |
202 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
203 | | static_assert(0 < 1, "There is no slot for us"); |
204 | | |
205 | | MOZ_CAN_RUN_SCRIPT static bool |
206 | | get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GroupedHistoryEvent* self, JSJitGetterCallArgs args) |
207 | 0 | { |
208 | 0 | AUTO_PROFILER_LABEL_FAST("get GroupedHistoryEvent.isTrusted", DOM, cx); |
209 | 0 |
|
210 | 0 | bool result(self->IsTrusted()); |
211 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
212 | 0 | args.rval().setBoolean(result); |
213 | 0 | return true; |
214 | 0 | } |
215 | | |
216 | | static const JSJitInfo isTrusted_getterinfo = { |
217 | | { (JSJitGetterOp)get_isTrusted }, |
218 | | { prototypes::id::GroupedHistoryEvent }, |
219 | | { PrototypeTraits<prototypes::id::GroupedHistoryEvent>::Depth }, |
220 | | JSJitInfo::Getter, |
221 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
222 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
223 | | true, /* isInfallible. False in setters. */ |
224 | | true, /* isMovable. Not relevant for setters. */ |
225 | | true, /* isEliminatable. Not relevant for setters. */ |
226 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
227 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
228 | | false, /* isTypedMethod. Only relevant for methods. */ |
229 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
230 | | }; |
231 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
232 | | static_assert(0 < 1, "There is no slot for us"); |
233 | | |
234 | | static bool |
235 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
236 | 0 | { |
237 | 0 | mozilla::dom::GroupedHistoryEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GroupedHistoryEvent>(obj); |
238 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
239 | 0 | // obviously can't preserve if we're not initialized. |
240 | 0 | if (self && self->GetWrapperPreserveColor()) { |
241 | 0 | PreserveWrapper(self); |
242 | 0 | } |
243 | 0 | return true; |
244 | 0 | } |
245 | | |
246 | | static void |
247 | | _finalize(js::FreeOp* fop, JSObject* obj) |
248 | 0 | { |
249 | 0 | mozilla::dom::GroupedHistoryEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GroupedHistoryEvent>(obj); |
250 | 0 | if (self) { |
251 | 0 | ClearWrapper(self, self, obj); |
252 | 0 | AddForDeferredFinalization<mozilla::dom::GroupedHistoryEvent>(self); |
253 | 0 | } |
254 | 0 | } |
255 | | |
256 | | static size_t |
257 | | _objectMoved(JSObject* obj, JSObject* old) |
258 | 0 | { |
259 | 0 | mozilla::dom::GroupedHistoryEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GroupedHistoryEvent>(obj); |
260 | 0 | if (self) { |
261 | 0 | UpdateWrapper(self, self, obj, old); |
262 | 0 | } |
263 | 0 |
|
264 | 0 | return 0; |
265 | 0 | } |
266 | | |
267 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
268 | | #if defined(__clang__) |
269 | | #pragma clang diagnostic push |
270 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
271 | | #endif |
272 | | static const JSPropertySpec sAttributes_specs[] = { |
273 | | { "otherBrowser", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &otherBrowser_getterinfo, nullptr, nullptr }, |
274 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
275 | | }; |
276 | | #if defined(__clang__) |
277 | | #pragma clang diagnostic pop |
278 | | #endif |
279 | | |
280 | | |
281 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
282 | | { nullptr, &sAttributes_specs[0] }, |
283 | | { nullptr, nullptr } |
284 | | }; |
285 | | |
286 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
287 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
288 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
289 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
290 | | |
291 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
292 | | #if defined(__clang__) |
293 | | #pragma clang diagnostic push |
294 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
295 | | #endif |
296 | | static const JSPropertySpec sUnforgeableAttributes_specs[] = { |
297 | | { "isTrusted", JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isTrusted_getterinfo, nullptr, nullptr }, |
298 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
299 | | }; |
300 | | #if defined(__clang__) |
301 | | #pragma clang diagnostic pop |
302 | | #endif |
303 | | |
304 | | |
305 | | static const Prefable<const JSPropertySpec> sUnforgeableAttributes[] = { |
306 | | { nullptr, &sUnforgeableAttributes_specs[0] }, |
307 | | { nullptr, nullptr } |
308 | | }; |
309 | | |
310 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
311 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
312 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
313 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
314 | | |
315 | | |
316 | | static uint16_t sNativeProperties_sortedPropertyIndices[2]; |
317 | | static PropertyInfo sNativeProperties_propertyInfos[2]; |
318 | | |
319 | | static const NativePropertiesN<2> sNativeProperties = { |
320 | | false, 0, |
321 | | false, 0, |
322 | | false, 0, |
323 | | true, 0 /* sAttributes */, |
324 | | false, 0, |
325 | | true, 1 /* sUnforgeableAttributes */, |
326 | | false, 0, |
327 | | -1, |
328 | | 2, |
329 | | sNativeProperties_sortedPropertyIndices, |
330 | | { |
331 | | { sAttributes, &sNativeProperties_propertyInfos[0] }, |
332 | | { sUnforgeableAttributes, &sNativeProperties_propertyInfos[1] } |
333 | | } |
334 | | }; |
335 | | static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
336 | | "We have a property info count that is oversized"); |
337 | | |
338 | | static bool |
339 | | _constructor(JSContext* cx, unsigned argc, JS::Value* vp) |
340 | 0 | { |
341 | 0 | AUTO_PROFILER_LABEL_FAST("GroupedHistoryEvent constructor", DOM, cx); |
342 | 0 |
|
343 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
344 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
345 | 0 | if (!args.isConstructing()) { |
346 | 0 | // XXXbz wish I could get the name from the callee instead of |
347 | 0 | // Adding more relocations |
348 | 0 | return ThrowConstructorWithoutNew(cx, "GroupedHistoryEvent"); |
349 | 0 | } |
350 | 0 | |
351 | 0 | JS::Rooted<JSObject*> desiredProto(cx); |
352 | 0 | if (!GetDesiredProto(cx, args, &desiredProto)) { |
353 | 0 | return false; |
354 | 0 | } |
355 | 0 | |
356 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
357 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "GroupedHistoryEvent"); |
358 | 0 | } |
359 | 0 | GlobalObject global(cx, obj); |
360 | 0 | if (global.Failed()) { |
361 | 0 | return false; |
362 | 0 | } |
363 | 0 | |
364 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
365 | 0 | binding_detail::FakeString arg0; |
366 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
367 | 0 | return false; |
368 | 0 | } |
369 | 0 | binding_detail::FastGroupedHistoryEventInit arg1; |
370 | 0 | if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2 of GroupedHistoryEvent.constructor", false)) { |
371 | 0 | return false; |
372 | 0 | } |
373 | 0 | Maybe<JSAutoRealm> ar; |
374 | 0 | if (objIsXray) { |
375 | 0 | obj = js::CheckedUnwrap(obj); |
376 | 0 | if (!obj) { |
377 | 0 | return false; |
378 | 0 | } |
379 | 0 | ar.emplace(cx, obj); |
380 | 0 | if (!JS_WrapObject(cx, &desiredProto)) { |
381 | 0 | return false; |
382 | 0 | } |
383 | 0 | } |
384 | 0 | FastErrorResult rv; |
385 | 0 | auto result(StrongOrRawPtr<mozilla::dom::GroupedHistoryEvent>(mozilla::dom::GroupedHistoryEvent::Constructor(global, NonNullHelper(Constify(arg0)), Constify(arg1), rv))); |
386 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
387 | 0 | return false; |
388 | 0 | } |
389 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
390 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
391 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
392 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) { |
393 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
394 | 0 | return false; |
395 | 0 | } |
396 | 0 | return true; |
397 | 0 | } |
398 | | |
399 | | static const js::ClassOps sInterfaceObjectClassOps = { |
400 | | nullptr, /* addProperty */ |
401 | | nullptr, /* delProperty */ |
402 | | nullptr, /* enumerate */ |
403 | | nullptr, /* newEnumerate */ |
404 | | nullptr, /* resolve */ |
405 | | nullptr, /* mayResolve */ |
406 | | nullptr, /* finalize */ |
407 | | _constructor, /* call */ |
408 | | nullptr, /* hasInstance */ |
409 | | _constructor, /* construct */ |
410 | | nullptr, /* trace */ |
411 | | }; |
412 | | |
413 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
414 | | { |
415 | | "Function", |
416 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
417 | | &sInterfaceObjectClassOps, |
418 | | JS_NULL_CLASS_SPEC, |
419 | | JS_NULL_CLASS_EXT, |
420 | | &sInterfaceObjectClassObjectOps |
421 | | }, |
422 | | eInterface, |
423 | | true, |
424 | | prototypes::id::GroupedHistoryEvent, |
425 | | PrototypeTraits<prototypes::id::GroupedHistoryEvent>::Depth, |
426 | | sNativePropertyHooks, |
427 | | "function GroupedHistoryEvent() {\n [native code]\n}", |
428 | | Event_Binding::GetConstructorObject |
429 | | }; |
430 | | |
431 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
432 | | { |
433 | | "GroupedHistoryEventPrototype", |
434 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */), |
435 | | JS_NULL_CLASS_OPS, |
436 | | JS_NULL_CLASS_SPEC, |
437 | | JS_NULL_CLASS_EXT, |
438 | | JS_NULL_OBJECT_OPS |
439 | | }, |
440 | | eInterfacePrototype, |
441 | | false, |
442 | | prototypes::id::GroupedHistoryEvent, |
443 | | PrototypeTraits<prototypes::id::GroupedHistoryEvent>::Depth, |
444 | | sNativePropertyHooks, |
445 | | "[object GroupedHistoryEventPrototype]", |
446 | | Event_Binding::GetProtoObject |
447 | | }; |
448 | | |
449 | | bool |
450 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
451 | 0 | { |
452 | 0 | return nsContentUtils::ThreadsafeIsSystemCaller(aCx); |
453 | 0 | } |
454 | | |
455 | | static const js::ClassOps sClassOps = { |
456 | | _addProperty, /* addProperty */ |
457 | | nullptr, /* delProperty */ |
458 | | nullptr, /* enumerate */ |
459 | | nullptr, /* newEnumerate */ |
460 | | nullptr, /* resolve */ |
461 | | nullptr, /* mayResolve */ |
462 | | _finalize, /* finalize */ |
463 | | nullptr, /* call */ |
464 | | nullptr, /* hasInstance */ |
465 | | nullptr, /* construct */ |
466 | | nullptr, /* trace */ |
467 | | }; |
468 | | |
469 | | static const js::ClassExtension sClassExtension = { |
470 | | nullptr, /* weakmapKeyDelegateOp */ |
471 | | _objectMoved /* objectMovedOp */ |
472 | | }; |
473 | | |
474 | | static const DOMJSClass sClass = { |
475 | | { "GroupedHistoryEvent", |
476 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE, |
477 | | &sClassOps, |
478 | | JS_NULL_CLASS_SPEC, |
479 | | &sClassExtension, |
480 | | JS_NULL_OBJECT_OPS |
481 | | }, |
482 | | { prototypes::id::Event, prototypes::id::GroupedHistoryEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
483 | | IsBaseOf<nsISupports, mozilla::dom::GroupedHistoryEvent >::value, |
484 | | sNativePropertyHooks, |
485 | | FindAssociatedGlobalForNative<mozilla::dom::GroupedHistoryEvent>::Get, |
486 | | GetProtoObjectHandle, |
487 | | GetCCParticipant<mozilla::dom::GroupedHistoryEvent>::Get() |
488 | | }; |
489 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
490 | | "Must have the right minimal number of reserved slots."); |
491 | | static_assert(1 >= 1, |
492 | | "Must have enough reserved slots."); |
493 | | |
494 | | const JSClass* |
495 | | GetJSClass() |
496 | 0 | { |
497 | 0 | return sClass.ToJSClass(); |
498 | 0 | } |
499 | | |
500 | | bool |
501 | | Wrap(JSContext* aCx, mozilla::dom::GroupedHistoryEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
502 | 0 | { |
503 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::GroupedHistoryEvent>::value, |
504 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
505 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::GroupedHistoryEvent*>(aObject) == |
506 | 0 | reinterpret_cast<mozilla::dom::GroupedHistoryEvent*>(aObject), |
507 | 0 | "Multiple inheritance for mozilla::dom::GroupedHistoryEvent is broken."); |
508 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) == |
509 | 0 | reinterpret_cast<mozilla::dom::Event*>(aObject), |
510 | 0 | "Multiple inheritance for mozilla::dom::Event is broken."); |
511 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
512 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
513 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
514 | 0 | "You should probably not be using Wrap() directly; use " |
515 | 0 | "GetOrCreateDOMReflector instead"); |
516 | 0 |
|
517 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
518 | 0 | "nsISupports must be on our primary inheritance chain"); |
519 | 0 |
|
520 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
521 | 0 | if (!global) { |
522 | 0 | return false; |
523 | 0 | } |
524 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
525 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
526 | 0 |
|
527 | 0 | // That might have ended up wrapping us already, due to the wonders |
528 | 0 | // of XBL. Check for that, and bail out as needed. |
529 | 0 | aReflector.set(aCache->GetWrapper()); |
530 | 0 | if (aReflector) { |
531 | | #ifdef DEBUG |
532 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
533 | | #endif // DEBUG |
534 | | return true; |
535 | 0 | } |
536 | 0 |
|
537 | 0 | JSAutoRealm ar(aCx, global); |
538 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
539 | 0 | if (!canonicalProto) { |
540 | 0 | return false; |
541 | 0 | } |
542 | 0 | JS::Rooted<JSObject*> proto(aCx); |
543 | 0 | if (aGivenProto) { |
544 | 0 | proto = aGivenProto; |
545 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
546 | 0 | // coming in, we changed compartments to that of "parent" so may need |
547 | 0 | // to wrap the proto here. |
548 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
549 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
550 | 0 | return false; |
551 | 0 | } |
552 | 0 | } |
553 | 0 | } else { |
554 | 0 | proto = canonicalProto; |
555 | 0 | } |
556 | 0 |
|
557 | 0 | BindingJSObjectCreator<mozilla::dom::GroupedHistoryEvent> creator(aCx); |
558 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
559 | 0 | if (!aReflector) { |
560 | 0 | return false; |
561 | 0 | } |
562 | 0 | |
563 | 0 | aCache->SetWrapper(aReflector); |
564 | 0 |
|
565 | 0 | // Important: do unforgeable property setup after we have handed |
566 | 0 | // over ownership of the C++ object to obj as needed, so that if |
567 | 0 | // we fail and it ends up GCed it won't have problems in the |
568 | 0 | // finalizer trying to drop its ownership of the C++ object. |
569 | 0 | JS::Rooted<JSObject*> unforgeableHolder(aCx, |
570 | 0 | &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject()); |
571 | 0 | if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) { |
572 | 0 | aCache->ReleaseWrapper(aObject); |
573 | 0 | aCache->ClearWrapper(); |
574 | 0 | return false; |
575 | 0 | } |
576 | 0 | creator.InitializationSucceeded(); |
577 | 0 |
|
578 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
579 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
580 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
581 | 0 | // otherwise we won't be able to properly recreate it later, since |
582 | 0 | // we won't know what proto to use. Note that we don't check |
583 | 0 | // aGivenProto here, since it's entirely possible (and even |
584 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
585 | 0 | // same as canonicalProto. |
586 | 0 | if (proto != canonicalProto) { |
587 | 0 | PreserveWrapper(aObject); |
588 | 0 | } |
589 | 0 |
|
590 | 0 | return true; |
591 | 0 | } |
592 | | |
593 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
594 | | nullptr, |
595 | | nullptr, |
596 | | nullptr, |
597 | | { sNativeProperties.Upcast(), nullptr }, |
598 | | prototypes::id::GroupedHistoryEvent, |
599 | | constructors::id::GroupedHistoryEvent, |
600 | | Event_Binding::sNativePropertyHooks, |
601 | | &DefaultXrayExpandoObjectClass |
602 | | } }; |
603 | | |
604 | | void |
605 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
606 | 0 | { |
607 | 0 | JS::Handle<JSObject*> parentProto(Event_Binding::GetProtoObjectHandle(aCx)); |
608 | 0 | if (!parentProto) { |
609 | 0 | return; |
610 | 0 | } |
611 | 0 | |
612 | 0 | JS::Handle<JSObject*> constructorProto(Event_Binding::GetConstructorObjectHandle(aCx)); |
613 | 0 | if (!constructorProto) { |
614 | 0 | return; |
615 | 0 | } |
616 | 0 | |
617 | 0 | static bool sIdsInited = false; |
618 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
619 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
620 | 0 | return; |
621 | 0 | } |
622 | 0 | sIdsInited = true; |
623 | 0 | } |
624 | 0 |
|
625 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::GroupedHistoryEvent); |
626 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::GroupedHistoryEvent); |
627 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
628 | 0 | &sPrototypeClass.mBase, protoCache, |
629 | 0 | nullptr, |
630 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr, |
631 | 0 | interfaceCache, |
632 | 0 | sNativeProperties.Upcast(), |
633 | 0 | nullptr, |
634 | 0 | "GroupedHistoryEvent", aDefineOnGlobal, |
635 | 0 | nullptr, |
636 | 0 | false); |
637 | 0 |
|
638 | 0 | JS::Rooted<JSObject*> unforgeableHolder(aCx); |
639 | 0 | { |
640 | 0 | JS::Rooted<JSObject*> holderProto(aCx, *protoCache); |
641 | 0 | unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto); |
642 | 0 | if (!unforgeableHolder) { |
643 | 0 | *protoCache = nullptr; |
644 | 0 | if (interfaceCache) { |
645 | 0 | *interfaceCache = nullptr; |
646 | 0 | } |
647 | 0 | return; |
648 | 0 | } |
649 | 0 | } |
650 | 0 |
|
651 | 0 | if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) { |
652 | 0 | *protoCache = nullptr; |
653 | 0 | if (interfaceCache) { |
654 | 0 | *interfaceCache = nullptr; |
655 | 0 | } |
656 | 0 | return; |
657 | 0 | } |
658 | 0 |
|
659 | 0 | if (*protoCache) { |
660 | 0 | js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE, |
661 | 0 | JS::ObjectValue(*unforgeableHolder)); |
662 | 0 | } |
663 | 0 | } |
664 | | |
665 | | JSObject* |
666 | | GetConstructorObject(JSContext* aCx) |
667 | 0 | { |
668 | 0 | return GetConstructorObjectHandle(aCx); |
669 | 0 | } |
670 | | |
671 | | } // namespace GroupedHistoryEvent_Binding |
672 | | |
673 | | |
674 | | |
675 | | } // namespace dom |
676 | | } // namespace mozilla |