Coverage Report

Created: 2018-09-25 14:53

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