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