Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM IDBRequest.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "EventHandlerBinding.h"
4 : #include "EventTargetBinding.h"
5 : #include "IDBRequestBinding.h"
6 : #include "WrapperFactory.h"
7 : #include "jsapi.h"
8 : #include "mozilla/OwningNonNull.h"
9 : #include "mozilla/dom/BindingUtils.h"
10 : #include "mozilla/dom/DOMError.h"
11 : #include "mozilla/dom/DOMJSClass.h"
12 : #include "mozilla/dom/IDBCursor.h"
13 : #include "mozilla/dom/IDBIndex.h"
14 : #include "mozilla/dom/IDBObjectStore.h"
15 : #include "mozilla/dom/IDBRequest.h"
16 : #include "mozilla/dom/IDBTransaction.h"
17 : #include "mozilla/dom/NonRefcountedDOMObject.h"
18 : #include "mozilla/dom/Nullable.h"
19 : #include "mozilla/dom/UnionConversions.h"
20 : #include "mozilla/dom/XrayExpandoClass.h"
21 :
22 : namespace mozilla {
23 : namespace dom {
24 :
25 : namespace IDBRequestReadyStateValues {
26 : extern const EnumEntry strings[3] = {
27 : {"pending", 7},
28 : {"done", 4},
29 : { nullptr, 0 }
30 : };
31 : } // namespace IDBRequestReadyStateValues
32 :
33 : bool
34 0 : ToJSValue(JSContext* aCx, IDBRequestReadyState aArgument, JS::MutableHandle<JS::Value> aValue)
35 : {
36 0 : MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(IDBRequestReadyStateValues::strings));
37 : JSString* resultStr =
38 0 : JS_NewStringCopyN(aCx, IDBRequestReadyStateValues::strings[uint32_t(aArgument)].value,
39 0 : IDBRequestReadyStateValues::strings[uint32_t(aArgument)].length);
40 0 : if (!resultStr) {
41 0 : return false;
42 : }
43 0 : aValue.setString(resultStr);
44 0 : return true;
45 : }
46 :
47 :
48 : void
49 0 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningIDBObjectStoreOrIDBIndexOrIDBCursor& aUnion, const char* aName, uint32_t aFlags)
50 : {
51 0 : if (aUnion.IsIDBObjectStore()) {
52 0 : ImplCycleCollectionTraverse(aCallback, aUnion.GetAsIDBObjectStore(), "mIDBObjectStore", aFlags);
53 0 : } else if (aUnion.IsIDBIndex()) {
54 0 : ImplCycleCollectionTraverse(aCallback, aUnion.GetAsIDBIndex(), "mIDBIndex", aFlags);
55 0 : } else if (aUnion.IsIDBCursor()) {
56 0 : ImplCycleCollectionTraverse(aCallback, aUnion.GetAsIDBCursor(), "mIDBCursor", aFlags);
57 : }
58 0 : }
59 :
60 :
61 : void
62 0 : ImplCycleCollectionUnlink(OwningIDBObjectStoreOrIDBIndexOrIDBCursor& aUnion)
63 : {
64 0 : aUnion.Uninit();
65 0 : }
66 :
67 :
68 : bool
69 0 : IDBObjectStoreOrIDBIndexOrIDBCursor::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
70 : {
71 0 : switch (mType) {
72 : case eUninitialized: {
73 0 : return false;
74 : break;
75 : }
76 : case eIDBObjectStore: {
77 0 : if (!GetOrCreateDOMReflector(cx, mValue.mIDBObjectStore.Value(), rval)) {
78 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
79 0 : return false;
80 : }
81 0 : return true;
82 : break;
83 : }
84 : case eIDBIndex: {
85 0 : if (!GetOrCreateDOMReflector(cx, mValue.mIDBIndex.Value(), rval)) {
86 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
87 0 : return false;
88 : }
89 0 : return true;
90 : break;
91 : }
92 : case eIDBCursor: {
93 0 : if (!GetOrCreateDOMReflector(cx, mValue.mIDBCursor.Value(), rval)) {
94 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
95 0 : return false;
96 : }
97 0 : return true;
98 : break;
99 : }
100 : default: {
101 0 : return false;
102 : break;
103 : }
104 : }
105 :
106 : return false;
107 : }
108 :
109 :
110 : OwningNonNull<mozilla::dom::IDBObjectStore>&
111 0 : OwningIDBObjectStoreOrIDBIndexOrIDBCursor::RawSetAsIDBObjectStore()
112 : {
113 0 : if (mType == eIDBObjectStore) {
114 0 : return mValue.mIDBObjectStore.Value();
115 : }
116 0 : MOZ_ASSERT(mType == eUninitialized);
117 0 : mType = eIDBObjectStore;
118 0 : return mValue.mIDBObjectStore.SetValue();
119 : }
120 :
121 : OwningNonNull<mozilla::dom::IDBObjectStore>&
122 0 : OwningIDBObjectStoreOrIDBIndexOrIDBCursor::SetAsIDBObjectStore()
123 : {
124 0 : if (mType == eIDBObjectStore) {
125 0 : return mValue.mIDBObjectStore.Value();
126 : }
127 0 : Uninit();
128 0 : mType = eIDBObjectStore;
129 0 : return mValue.mIDBObjectStore.SetValue();
130 : }
131 :
132 : bool
133 0 : OwningIDBObjectStoreOrIDBIndexOrIDBCursor::TrySetToIDBObjectStore(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
134 : {
135 0 : tryNext = false;
136 : { // scope for memberSlot
137 0 : OwningNonNull<mozilla::dom::IDBObjectStore>& memberSlot = RawSetAsIDBObjectStore();
138 : static_assert(IsRefcounted<mozilla::dom::IDBObjectStore>::value, "We can only store refcounted classes.");{
139 0 : nsresult rv = UnwrapObject<prototypes::id::IDBObjectStore, mozilla::dom::IDBObjectStore>(value, memberSlot);
140 0 : if (NS_FAILED(rv)) {
141 0 : DestroyIDBObjectStore();
142 0 : tryNext = true;
143 0 : return true;
144 : }
145 : }
146 : }
147 0 : return true;
148 : }
149 :
150 : void
151 0 : OwningIDBObjectStoreOrIDBIndexOrIDBCursor::DestroyIDBObjectStore()
152 : {
153 0 : MOZ_ASSERT(IsIDBObjectStore(), "Wrong type!");
154 0 : mValue.mIDBObjectStore.Destroy();
155 0 : mType = eUninitialized;
156 0 : }
157 :
158 :
159 :
160 :
161 : OwningNonNull<mozilla::dom::IDBIndex>&
162 0 : OwningIDBObjectStoreOrIDBIndexOrIDBCursor::RawSetAsIDBIndex()
163 : {
164 0 : if (mType == eIDBIndex) {
165 0 : return mValue.mIDBIndex.Value();
166 : }
167 0 : MOZ_ASSERT(mType == eUninitialized);
168 0 : mType = eIDBIndex;
169 0 : return mValue.mIDBIndex.SetValue();
170 : }
171 :
172 : OwningNonNull<mozilla::dom::IDBIndex>&
173 0 : OwningIDBObjectStoreOrIDBIndexOrIDBCursor::SetAsIDBIndex()
174 : {
175 0 : if (mType == eIDBIndex) {
176 0 : return mValue.mIDBIndex.Value();
177 : }
178 0 : Uninit();
179 0 : mType = eIDBIndex;
180 0 : return mValue.mIDBIndex.SetValue();
181 : }
182 :
183 : bool
184 0 : OwningIDBObjectStoreOrIDBIndexOrIDBCursor::TrySetToIDBIndex(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
185 : {
186 0 : tryNext = false;
187 : { // scope for memberSlot
188 0 : OwningNonNull<mozilla::dom::IDBIndex>& memberSlot = RawSetAsIDBIndex();
189 : static_assert(IsRefcounted<mozilla::dom::IDBIndex>::value, "We can only store refcounted classes.");{
190 0 : nsresult rv = UnwrapObject<prototypes::id::IDBIndex, mozilla::dom::IDBIndex>(value, memberSlot);
191 0 : if (NS_FAILED(rv)) {
192 0 : DestroyIDBIndex();
193 0 : tryNext = true;
194 0 : return true;
195 : }
196 : }
197 : }
198 0 : return true;
199 : }
200 :
201 : void
202 0 : OwningIDBObjectStoreOrIDBIndexOrIDBCursor::DestroyIDBIndex()
203 : {
204 0 : MOZ_ASSERT(IsIDBIndex(), "Wrong type!");
205 0 : mValue.mIDBIndex.Destroy();
206 0 : mType = eUninitialized;
207 0 : }
208 :
209 :
210 :
211 :
212 : OwningNonNull<mozilla::dom::IDBCursor>&
213 0 : OwningIDBObjectStoreOrIDBIndexOrIDBCursor::RawSetAsIDBCursor()
214 : {
215 0 : if (mType == eIDBCursor) {
216 0 : return mValue.mIDBCursor.Value();
217 : }
218 0 : MOZ_ASSERT(mType == eUninitialized);
219 0 : mType = eIDBCursor;
220 0 : return mValue.mIDBCursor.SetValue();
221 : }
222 :
223 : OwningNonNull<mozilla::dom::IDBCursor>&
224 0 : OwningIDBObjectStoreOrIDBIndexOrIDBCursor::SetAsIDBCursor()
225 : {
226 0 : if (mType == eIDBCursor) {
227 0 : return mValue.mIDBCursor.Value();
228 : }
229 0 : Uninit();
230 0 : mType = eIDBCursor;
231 0 : return mValue.mIDBCursor.SetValue();
232 : }
233 :
234 : bool
235 0 : OwningIDBObjectStoreOrIDBIndexOrIDBCursor::TrySetToIDBCursor(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
236 : {
237 0 : tryNext = false;
238 : { // scope for memberSlot
239 0 : OwningNonNull<mozilla::dom::IDBCursor>& memberSlot = RawSetAsIDBCursor();
240 : static_assert(IsRefcounted<mozilla::dom::IDBCursor>::value, "We can only store refcounted classes.");{
241 0 : nsresult rv = UnwrapObject<prototypes::id::IDBCursor, mozilla::dom::IDBCursor>(value, memberSlot);
242 0 : if (NS_FAILED(rv)) {
243 0 : DestroyIDBCursor();
244 0 : tryNext = true;
245 0 : return true;
246 : }
247 : }
248 : }
249 0 : return true;
250 : }
251 :
252 : void
253 0 : OwningIDBObjectStoreOrIDBIndexOrIDBCursor::DestroyIDBCursor()
254 : {
255 0 : MOZ_ASSERT(IsIDBCursor(), "Wrong type!");
256 0 : mValue.mIDBCursor.Destroy();
257 0 : mType = eUninitialized;
258 0 : }
259 :
260 :
261 :
262 :
263 : void
264 0 : OwningIDBObjectStoreOrIDBIndexOrIDBCursor::Uninit()
265 : {
266 0 : switch (mType) {
267 : case eUninitialized: {
268 0 : break;
269 : }
270 : case eIDBObjectStore: {
271 0 : DestroyIDBObjectStore();
272 0 : break;
273 : }
274 : case eIDBIndex: {
275 0 : DestroyIDBIndex();
276 0 : break;
277 : }
278 : case eIDBCursor: {
279 0 : DestroyIDBCursor();
280 0 : break;
281 : }
282 : }
283 0 : }
284 :
285 : bool
286 0 : OwningIDBObjectStoreOrIDBIndexOrIDBCursor::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
287 : {
288 0 : switch (mType) {
289 : case eUninitialized: {
290 0 : return false;
291 : break;
292 : }
293 : case eIDBObjectStore: {
294 0 : if (!GetOrCreateDOMReflector(cx, mValue.mIDBObjectStore.Value(), rval)) {
295 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
296 0 : return false;
297 : }
298 0 : return true;
299 : break;
300 : }
301 : case eIDBIndex: {
302 0 : if (!GetOrCreateDOMReflector(cx, mValue.mIDBIndex.Value(), rval)) {
303 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
304 0 : return false;
305 : }
306 0 : return true;
307 : break;
308 : }
309 : case eIDBCursor: {
310 0 : if (!GetOrCreateDOMReflector(cx, mValue.mIDBCursor.Value(), rval)) {
311 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
312 0 : return false;
313 : }
314 0 : return true;
315 : break;
316 : }
317 : default: {
318 0 : return false;
319 : break;
320 : }
321 : }
322 :
323 : return false;
324 : }
325 :
326 : void
327 0 : OwningIDBObjectStoreOrIDBIndexOrIDBCursor::TraceUnion(JSTracer* trc)
328 : {
329 0 : }
330 :
331 : OwningIDBObjectStoreOrIDBIndexOrIDBCursor&
332 0 : OwningIDBObjectStoreOrIDBIndexOrIDBCursor::operator=(const OwningIDBObjectStoreOrIDBIndexOrIDBCursor& aOther)
333 : {
334 0 : switch (aOther.mType) {
335 : case eUninitialized: {
336 0 : MOZ_ASSERT(mType == eUninitialized,
337 : "We need to destroy ourselves?");
338 0 : break;
339 : }
340 : case eIDBObjectStore: {
341 0 : SetAsIDBObjectStore() = aOther.GetAsIDBObjectStore();
342 0 : break;
343 : }
344 : case eIDBIndex: {
345 0 : SetAsIDBIndex() = aOther.GetAsIDBIndex();
346 0 : break;
347 : }
348 : case eIDBCursor: {
349 0 : SetAsIDBCursor() = aOther.GetAsIDBCursor();
350 0 : break;
351 : }
352 : }
353 0 : return *this;
354 : }
355 :
356 :
357 : namespace IDBRequestBinding {
358 :
359 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTargetBinding::NativeType>::value,
360 : "Can't inherit from an interface with a different ownership model.");
361 :
362 : static bool
363 0 : get_result(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBRequest* self, JSJitGetterCallArgs args)
364 : {
365 0 : binding_detail::FastErrorResult rv;
366 0 : JS::Rooted<JS::Value> result(cx);
367 0 : self->GetResult(cx, &result, rv);
368 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
369 0 : return false;
370 : }
371 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
372 0 : JS::ExposeValueToActiveJS(result);
373 0 : args.rval().set(result);
374 0 : if (!MaybeWrapValue(cx, args.rval())) {
375 0 : return false;
376 : }
377 0 : return true;
378 : }
379 :
380 : static const JSJitInfo result_getterinfo = {
381 : { (JSJitGetterOp)get_result },
382 : { prototypes::id::IDBRequest },
383 : { PrototypeTraits<prototypes::id::IDBRequest>::Depth },
384 : JSJitInfo::Getter,
385 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
386 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
387 : false, /* isInfallible. False in setters. */
388 : false, /* isMovable. Not relevant for setters. */
389 : false, /* isEliminatable. Not relevant for setters. */
390 : false, /* isAlwaysInSlot. Only relevant for getters. */
391 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
392 : false, /* isTypedMethod. Only relevant for methods. */
393 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
394 : };
395 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
396 : static_assert(0 < 1, "There is no slot for us");
397 :
398 : static bool
399 0 : get_error(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBRequest* self, JSJitGetterCallArgs args)
400 : {
401 0 : binding_detail::FastErrorResult rv;
402 0 : auto result(StrongOrRawPtr<mozilla::dom::DOMError>(self->GetError(rv)));
403 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
404 0 : return false;
405 : }
406 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
407 0 : if (!result) {
408 0 : args.rval().setNull();
409 0 : return true;
410 : }
411 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
412 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
413 0 : return false;
414 : }
415 0 : return true;
416 : }
417 :
418 : static const JSJitInfo error_getterinfo = {
419 : { (JSJitGetterOp)get_error },
420 : { prototypes::id::IDBRequest },
421 : { PrototypeTraits<prototypes::id::IDBRequest>::Depth },
422 : JSJitInfo::Getter,
423 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
424 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
425 : false, /* isInfallible. False in setters. */
426 : false, /* isMovable. Not relevant for setters. */
427 : false, /* isEliminatable. Not relevant for setters. */
428 : false, /* isAlwaysInSlot. Only relevant for getters. */
429 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
430 : false, /* isTypedMethod. Only relevant for methods. */
431 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
432 : };
433 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
434 : static_assert(0 < 1, "There is no slot for us");
435 :
436 : static bool
437 0 : get_source(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBRequest* self, JSJitGetterCallArgs args)
438 : {
439 0 : Nullable<OwningIDBObjectStoreOrIDBIndexOrIDBCursor> result;
440 0 : self->GetSource(result);
441 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
442 0 : if (result.IsNull()) {
443 0 : args.rval().setNull();
444 0 : return true;
445 : }
446 0 : if (!result.Value().ToJSVal(cx, obj, args.rval())) {
447 0 : return false;
448 : }
449 0 : return true;
450 : }
451 :
452 : static const JSJitInfo source_getterinfo = {
453 : { (JSJitGetterOp)get_source },
454 : { prototypes::id::IDBRequest },
455 : { PrototypeTraits<prototypes::id::IDBRequest>::Depth },
456 : JSJitInfo::Getter,
457 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
458 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
459 : false, /* isInfallible. False in setters. */
460 : false, /* isMovable. Not relevant for setters. */
461 : false, /* isEliminatable. Not relevant for setters. */
462 : false, /* isAlwaysInSlot. Only relevant for getters. */
463 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
464 : false, /* isTypedMethod. Only relevant for methods. */
465 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
466 : };
467 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
468 : static_assert(0 < 1, "There is no slot for us");
469 :
470 : static bool
471 0 : get_transaction(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBRequest* self, JSJitGetterCallArgs args)
472 : {
473 0 : auto result(StrongOrRawPtr<mozilla::dom::IDBTransaction>(self->GetTransaction()));
474 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
475 0 : if (!result) {
476 0 : args.rval().setNull();
477 0 : return true;
478 : }
479 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
480 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
481 0 : return false;
482 : }
483 0 : return true;
484 : }
485 :
486 : static const JSJitInfo transaction_getterinfo = {
487 : { (JSJitGetterOp)get_transaction },
488 : { prototypes::id::IDBRequest },
489 : { PrototypeTraits<prototypes::id::IDBRequest>::Depth },
490 : JSJitInfo::Getter,
491 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
492 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
493 : false, /* isInfallible. False in setters. */
494 : false, /* isMovable. Not relevant for setters. */
495 : false, /* isEliminatable. Not relevant for setters. */
496 : false, /* isAlwaysInSlot. Only relevant for getters. */
497 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
498 : false, /* isTypedMethod. Only relevant for methods. */
499 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
500 : };
501 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
502 : static_assert(0 < 1, "There is no slot for us");
503 :
504 : static bool
505 0 : get_readyState(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBRequest* self, JSJitGetterCallArgs args)
506 : {
507 0 : IDBRequestReadyState result(self->ReadyState());
508 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
509 0 : if (!ToJSValue(cx, result, args.rval())) {
510 0 : return false;
511 : }
512 0 : return true;
513 : }
514 :
515 : static const JSJitInfo readyState_getterinfo = {
516 : { (JSJitGetterOp)get_readyState },
517 : { prototypes::id::IDBRequest },
518 : { PrototypeTraits<prototypes::id::IDBRequest>::Depth },
519 : JSJitInfo::Getter,
520 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
521 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
522 : false, /* isInfallible. False in setters. */
523 : false, /* isMovable. Not relevant for setters. */
524 : false, /* isEliminatable. Not relevant for setters. */
525 : false, /* isAlwaysInSlot. Only relevant for getters. */
526 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
527 : false, /* isTypedMethod. Only relevant for methods. */
528 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
529 : };
530 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
531 : static_assert(0 < 1, "There is no slot for us");
532 :
533 : static bool
534 0 : get_onsuccess(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBRequest* self, JSJitGetterCallArgs args)
535 : {
536 0 : RefPtr<EventHandlerNonNull> result(self->GetOnsuccess());
537 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
538 0 : if (result) {
539 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
540 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
541 0 : return false;
542 : }
543 0 : return true;
544 : } else {
545 0 : args.rval().setNull();
546 0 : return true;
547 : }
548 : }
549 :
550 : static bool
551 0 : set_onsuccess(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBRequest* self, JSJitSetterCallArgs args)
552 : {
553 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
554 0 : if (args[0].isObject()) {
555 : { // scope for tempRoot
556 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
557 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
558 : }
559 : } else {
560 0 : arg0 = nullptr;
561 : }
562 0 : self->SetOnsuccess(Constify(arg0));
563 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
564 :
565 0 : return true;
566 : }
567 :
568 : static const JSJitInfo onsuccess_getterinfo = {
569 : { (JSJitGetterOp)get_onsuccess },
570 : { prototypes::id::IDBRequest },
571 : { PrototypeTraits<prototypes::id::IDBRequest>::Depth },
572 : JSJitInfo::Getter,
573 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
574 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
575 : false, /* isInfallible. False in setters. */
576 : false, /* isMovable. Not relevant for setters. */
577 : false, /* isEliminatable. Not relevant for setters. */
578 : false, /* isAlwaysInSlot. Only relevant for getters. */
579 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
580 : false, /* isTypedMethod. Only relevant for methods. */
581 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
582 : };
583 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
584 : static_assert(0 < 1, "There is no slot for us");
585 : static const JSJitInfo onsuccess_setterinfo = {
586 : { (JSJitGetterOp)set_onsuccess },
587 : { prototypes::id::IDBRequest },
588 : { PrototypeTraits<prototypes::id::IDBRequest>::Depth },
589 : JSJitInfo::Setter,
590 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
591 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
592 : false, /* isInfallible. False in setters. */
593 : false, /* isMovable. Not relevant for setters. */
594 : false, /* isEliminatable. Not relevant for setters. */
595 : false, /* isAlwaysInSlot. Only relevant for getters. */
596 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
597 : false, /* isTypedMethod. Only relevant for methods. */
598 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
599 : };
600 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
601 : static_assert(0 < 1, "There is no slot for us");
602 :
603 : static bool
604 0 : get_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBRequest* self, JSJitGetterCallArgs args)
605 : {
606 0 : RefPtr<EventHandlerNonNull> result(self->GetOnerror());
607 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
608 0 : if (result) {
609 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
610 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
611 0 : return false;
612 : }
613 0 : return true;
614 : } else {
615 0 : args.rval().setNull();
616 0 : return true;
617 : }
618 : }
619 :
620 : static bool
621 0 : set_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBRequest* self, JSJitSetterCallArgs args)
622 : {
623 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
624 0 : if (args[0].isObject()) {
625 : { // scope for tempRoot
626 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
627 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
628 : }
629 : } else {
630 0 : arg0 = nullptr;
631 : }
632 0 : self->SetOnerror(Constify(arg0));
633 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
634 :
635 0 : return true;
636 : }
637 :
638 : static const JSJitInfo onerror_getterinfo = {
639 : { (JSJitGetterOp)get_onerror },
640 : { prototypes::id::IDBRequest },
641 : { PrototypeTraits<prototypes::id::IDBRequest>::Depth },
642 : JSJitInfo::Getter,
643 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
644 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
645 : false, /* isInfallible. False in setters. */
646 : false, /* isMovable. Not relevant for setters. */
647 : false, /* isEliminatable. Not relevant for setters. */
648 : false, /* isAlwaysInSlot. Only relevant for getters. */
649 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
650 : false, /* isTypedMethod. Only relevant for methods. */
651 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
652 : };
653 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
654 : static_assert(0 < 1, "There is no slot for us");
655 : static const JSJitInfo onerror_setterinfo = {
656 : { (JSJitGetterOp)set_onerror },
657 : { prototypes::id::IDBRequest },
658 : { PrototypeTraits<prototypes::id::IDBRequest>::Depth },
659 : JSJitInfo::Setter,
660 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
661 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
662 : false, /* isInfallible. False in setters. */
663 : false, /* isMovable. Not relevant for setters. */
664 : false, /* isEliminatable. Not relevant for setters. */
665 : false, /* isAlwaysInSlot. Only relevant for getters. */
666 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
667 : false, /* isTypedMethod. Only relevant for methods. */
668 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
669 : };
670 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
671 : static_assert(0 < 1, "There is no slot for us");
672 :
673 : static bool
674 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
675 : {
676 0 : mozilla::dom::IDBRequest* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBRequest>(obj);
677 : // We don't want to preserve if we don't have a wrapper, and we
678 : // obviously can't preserve if we're not initialized.
679 0 : if (self && self->GetWrapperPreserveColor()) {
680 0 : PreserveWrapper(self);
681 : }
682 0 : return true;
683 : }
684 :
685 : static void
686 0 : _finalize(js::FreeOp* fop, JSObject* obj)
687 : {
688 0 : mozilla::dom::IDBRequest* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBRequest>(obj);
689 0 : if (self) {
690 0 : ClearWrapper(self, self, obj);
691 0 : AddForDeferredFinalization<mozilla::dom::IDBRequest>(self);
692 : }
693 0 : }
694 :
695 : static void
696 0 : _objectMoved(JSObject* obj, const JSObject* old)
697 : {
698 0 : mozilla::dom::IDBRequest* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBRequest>(obj);
699 0 : if (self) {
700 0 : UpdateWrapper(self, self, obj, old);
701 : }
702 0 : }
703 :
704 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
705 : #if defined(__clang__)
706 : #pragma clang diagnostic push
707 : #pragma clang diagnostic ignored "-Wmissing-braces"
708 : #endif
709 : static const JSPropertySpec sAttributes_specs[] = {
710 : { "result", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &result_getterinfo, nullptr, nullptr },
711 : { "error", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &error_getterinfo, nullptr, nullptr },
712 : { "source", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &source_getterinfo, nullptr, nullptr },
713 : { "transaction", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &transaction_getterinfo, nullptr, nullptr },
714 : { "readyState", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &readyState_getterinfo, nullptr, nullptr },
715 : { "onsuccess", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onsuccess_getterinfo, GenericBindingSetter, &onsuccess_setterinfo },
716 : { "onerror", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onerror_getterinfo, GenericBindingSetter, &onerror_setterinfo },
717 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
718 : };
719 : #if defined(__clang__)
720 : #pragma clang diagnostic pop
721 : #endif
722 :
723 :
724 : // Can't be const because the pref-enabled boolean needs to be writable
725 : static Prefable<const JSPropertySpec> sAttributes[] = {
726 : { nullptr, &sAttributes_specs[0] },
727 : { nullptr, nullptr }
728 : };
729 :
730 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
731 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
732 : static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
733 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
734 :
735 :
736 : static uint16_t sNativeProperties_sortedPropertyIndices[7];
737 : static PropertyInfo sNativeProperties_propertyInfos[7];
738 :
739 : static const NativePropertiesN<1> sNativeProperties = {
740 : false, 0,
741 : false, 0,
742 : false, 0,
743 : true, 0 /* sAttributes */,
744 : false, 0,
745 : false, 0,
746 : false, 0,
747 : -1,
748 : 7,
749 : sNativeProperties_sortedPropertyIndices,
750 : {
751 : { sAttributes, &sNativeProperties_propertyInfos[0] }
752 : }
753 : };
754 : static_assert(7 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
755 : "We have a property info count that is oversized");
756 :
757 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
758 : {
759 : "Function",
760 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
761 : &sBoringInterfaceObjectClassClassOps,
762 : JS_NULL_CLASS_SPEC,
763 : JS_NULL_CLASS_EXT,
764 : &sInterfaceObjectClassObjectOps
765 : },
766 : eInterface,
767 : true,
768 : prototypes::id::IDBRequest,
769 : PrototypeTraits<prototypes::id::IDBRequest>::Depth,
770 : sNativePropertyHooks,
771 : "function IDBRequest() {\n [native code]\n}",
772 : EventTargetBinding::GetConstructorObject
773 : };
774 :
775 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
776 : {
777 : "IDBRequestPrototype",
778 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
779 : JS_NULL_CLASS_OPS,
780 : JS_NULL_CLASS_SPEC,
781 : JS_NULL_CLASS_EXT,
782 : JS_NULL_OBJECT_OPS
783 : },
784 : eInterfacePrototype,
785 : false,
786 : prototypes::id::IDBRequest,
787 : PrototypeTraits<prototypes::id::IDBRequest>::Depth,
788 : sNativePropertyHooks,
789 : "[object IDBRequestPrototype]",
790 : EventTargetBinding::GetProtoObject
791 : };
792 :
793 : JSObject*
794 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
795 : {
796 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
797 : }
798 :
799 : static const js::ClassOps sClassOps = {
800 : _addProperty, /* addProperty */
801 : nullptr, /* delProperty */
802 : nullptr, /* getProperty */
803 : nullptr, /* setProperty */
804 : nullptr, /* enumerate */
805 : nullptr, /* newEnumerate */
806 : nullptr, /* resolve */
807 : nullptr, /* mayResolve */
808 : _finalize, /* finalize */
809 : nullptr, /* call */
810 : nullptr, /* hasInstance */
811 : nullptr, /* construct */
812 : nullptr, /* trace */
813 : };
814 :
815 : static const js::ClassExtension sClassExtension = {
816 : nullptr, /* weakmapKeyDelegateOp */
817 : _objectMoved /* objectMovedOp */
818 : };
819 :
820 : static const DOMJSClass sClass = {
821 : { "IDBRequest",
822 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
823 : &sClassOps,
824 : JS_NULL_CLASS_SPEC,
825 : &sClassExtension,
826 : JS_NULL_OBJECT_OPS
827 : },
828 : { prototypes::id::EventTarget, prototypes::id::IDBRequest, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
829 : IsBaseOf<nsISupports, mozilla::dom::IDBRequest >::value,
830 : sNativePropertyHooks,
831 : FindAssociatedGlobalForNative<mozilla::dom::IDBRequest>::Get,
832 : GetProtoObjectHandle,
833 : GetCCParticipant<mozilla::dom::IDBRequest>::Get()
834 : };
835 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
836 : "Must have the right minimal number of reserved slots.");
837 : static_assert(1 >= 1,
838 : "Must have enough reserved slots.");
839 :
840 : const JSClass*
841 0 : GetJSClass()
842 : {
843 0 : return sClass.ToJSClass();
844 : }
845 :
846 : bool
847 0 : Wrap(JSContext* aCx, mozilla::dom::IDBRequest* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
848 : {
849 : MOZ_ASSERT(static_cast<mozilla::dom::IDBRequest*>(aObject) ==
850 : reinterpret_cast<mozilla::dom::IDBRequest*>(aObject),
851 : "Multiple inheritance for mozilla::dom::IDBRequest is broken.");
852 : MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
853 : reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
854 : "Multiple inheritance for mozilla::dom::EventTarget is broken.");
855 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
856 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
857 0 : MOZ_ASSERT(!aCache->GetWrapper(),
858 : "You should probably not be using Wrap() directly; use "
859 : "GetOrCreateDOMReflector instead");
860 :
861 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
862 : "nsISupports must be on our primary inheritance chain");
863 :
864 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
865 0 : if (!global) {
866 0 : return false;
867 : }
868 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
869 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
870 :
871 : // That might have ended up wrapping us already, due to the wonders
872 : // of XBL. Check for that, and bail out as needed.
873 0 : aReflector.set(aCache->GetWrapper());
874 0 : if (aReflector) {
875 : #ifdef DEBUG
876 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
877 : #endif // DEBUG
878 0 : return true;
879 : }
880 :
881 0 : JSAutoCompartment ac(aCx, global);
882 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
883 0 : if (!canonicalProto) {
884 0 : return false;
885 : }
886 0 : JS::Rooted<JSObject*> proto(aCx);
887 0 : if (aGivenProto) {
888 0 : proto = aGivenProto;
889 : // Unfortunately, while aGivenProto was in the compartment of aCx
890 : // coming in, we changed compartments to that of "parent" so may need
891 : // to wrap the proto here.
892 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
893 0 : if (!JS_WrapObject(aCx, &proto)) {
894 0 : return false;
895 : }
896 : }
897 : } else {
898 0 : proto = canonicalProto;
899 : }
900 :
901 0 : BindingJSObjectCreator<mozilla::dom::IDBRequest> creator(aCx);
902 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
903 0 : if (!aReflector) {
904 0 : return false;
905 : }
906 :
907 0 : aCache->SetWrapper(aReflector);
908 0 : creator.InitializationSucceeded();
909 :
910 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
911 : aCache->GetWrapperPreserveColor() == aReflector);
912 : // If proto != canonicalProto, we have to preserve our wrapper;
913 : // otherwise we won't be able to properly recreate it later, since
914 : // we won't know what proto to use. Note that we don't check
915 : // aGivenProto here, since it's entirely possible (and even
916 : // somewhat common) to have a non-null aGivenProto which is the
917 : // same as canonicalProto.
918 0 : if (proto != canonicalProto) {
919 0 : PreserveWrapper(aObject);
920 : }
921 :
922 0 : return true;
923 : }
924 :
925 : const NativePropertyHooks sNativePropertyHooks[] = { {
926 : nullptr,
927 : nullptr,
928 : nullptr,
929 : { sNativeProperties.Upcast(), nullptr },
930 : prototypes::id::IDBRequest,
931 : constructors::id::IDBRequest,
932 : EventTargetBinding::sNativePropertyHooks,
933 : &DefaultXrayExpandoObjectClass
934 : } };
935 :
936 : void
937 15 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
938 : {
939 15 : JS::Handle<JSObject*> parentProto(EventTargetBinding::GetProtoObjectHandle(aCx));
940 15 : if (!parentProto) {
941 0 : return;
942 : }
943 :
944 15 : JS::Handle<JSObject*> constructorProto(EventTargetBinding::GetConstructorObjectHandle(aCx));
945 15 : if (!constructorProto) {
946 0 : return;
947 : }
948 :
949 : static bool sIdsInited = false;
950 15 : if (!sIdsInited && NS_IsMainThread()) {
951 1 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
952 0 : return;
953 : }
954 1 : sIdsInited = true;
955 : }
956 :
957 15 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::IDBRequest);
958 15 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::IDBRequest);
959 15 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
960 : &sPrototypeClass.mBase, protoCache,
961 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
962 : interfaceCache,
963 : sNativeProperties.Upcast(),
964 : nullptr,
965 : "IDBRequest", aDefineOnGlobal,
966 : nullptr,
967 15 : false);
968 : }
969 :
970 : JS::Handle<JSObject*>
971 15 : GetProtoObjectHandle(JSContext* aCx)
972 : {
973 : /* Get the interface prototype object for this class. This will create the
974 : object as needed. */
975 15 : bool aDefineOnGlobal = true;
976 :
977 : /* Make sure our global is sane. Hopefully we can remove this sometime */
978 15 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
979 15 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
980 0 : return nullptr;
981 : }
982 :
983 : /* Check to see whether the interface objects are already installed */
984 15 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
985 15 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::IDBRequest)) {
986 30 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
987 15 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
988 : }
989 :
990 : /*
991 : * The object might _still_ be null, but that's OK.
992 : *
993 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
994 : * traced by TraceProtoAndIfaceCache() and its contents are never
995 : * changed after they have been set.
996 : *
997 : * Calling address() avoids the read read barrier that does gray
998 : * unmarking, but it's not possible for the object to be gray here.
999 : */
1000 :
1001 15 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::IDBRequest);
1002 15 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1003 15 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1004 : }
1005 :
1006 : JSObject*
1007 0 : GetProtoObject(JSContext* aCx)
1008 : {
1009 0 : return GetProtoObjectHandle(aCx);
1010 : }
1011 :
1012 : JS::Handle<JSObject*>
1013 30 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
1014 : {
1015 : /* Get the interface object for this class. This will create the object as
1016 : needed. */
1017 :
1018 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1019 30 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1020 30 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1021 0 : return nullptr;
1022 : }
1023 :
1024 : /* Check to see whether the interface objects are already installed */
1025 30 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1026 30 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::IDBRequest)) {
1027 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1028 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1029 : }
1030 :
1031 : /*
1032 : * The object might _still_ be null, but that's OK.
1033 : *
1034 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1035 : * traced by TraceProtoAndIfaceCache() and its contents are never
1036 : * changed after they have been set.
1037 : *
1038 : * Calling address() avoids the read read barrier that does gray
1039 : * unmarking, but it's not possible for the object to be gray here.
1040 : */
1041 :
1042 30 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::IDBRequest);
1043 30 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1044 30 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1045 : }
1046 :
1047 : JSObject*
1048 15 : GetConstructorObject(JSContext* aCx)
1049 : {
1050 15 : return GetConstructorObjectHandle(aCx);
1051 : }
1052 :
1053 : } // namespace IDBRequestBinding
1054 :
1055 :
1056 :
1057 : } // namespace dom
1058 : } // namespace mozilla
|