Coverage Report

Created: 2018-09-25 14:53

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