Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/GridBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM Grid.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "GridBinding.h"
4
#include "WrapperFactory.h"
5
#include "XrayWrapper.h"
6
#include "jsapi.h"
7
#include "mozilla/FloatingPoint.h"
8
#include "mozilla/OwningNonNull.h"
9
#include "mozilla/dom/BindingUtils.h"
10
#include "mozilla/dom/DOMJSClass.h"
11
#include "mozilla/dom/DOMJSProxyHandler.h"
12
#include "mozilla/dom/Grid.h"
13
#include "mozilla/dom/GridArea.h"
14
#include "mozilla/dom/GridDimension.h"
15
#include "mozilla/dom/GridLine.h"
16
#include "mozilla/dom/GridLines.h"
17
#include "mozilla/dom/GridTrack.h"
18
#include "mozilla/dom/GridTracks.h"
19
#include "mozilla/dom/NonRefcountedDOMObject.h"
20
#include "mozilla/dom/Nullable.h"
21
#include "mozilla/dom/PrimitiveConversions.h"
22
#include "mozilla/dom/XrayExpandoClass.h"
23
#include "nsContentUtils.h"
24
25
namespace mozilla {
26
namespace dom {
27
28
namespace binding_detail {}; // Just to make sure it's known as a namespace
29
using namespace mozilla::dom::binding_detail;
30
31
32
namespace GridDeclarationValues {
33
extern const EnumEntry strings[3] = {
34
  {"explicit", 8},
35
  {"implicit", 8},
36
  { nullptr, 0 }
37
};
38
} // namespace GridDeclarationValues
39
40
bool
41
ToJSValue(JSContext* aCx, GridDeclaration aArgument, JS::MutableHandle<JS::Value> aValue)
42
0
{
43
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(GridDeclarationValues::strings));
44
0
  JSString* resultStr =
45
0
    JS_NewStringCopyN(aCx, GridDeclarationValues::strings[uint32_t(aArgument)].value,
46
0
                      GridDeclarationValues::strings[uint32_t(aArgument)].length);
47
0
  if (!resultStr) {
48
0
    return false;
49
0
  }
50
0
  aValue.setString(resultStr);
51
0
  return true;
52
0
}
53
54
55
namespace GridTrackStateValues {
56
extern const EnumEntry strings[4] = {
57
  {"static", 6},
58
  {"repeat", 6},
59
  {"removed", 7},
60
  { nullptr, 0 }
61
};
62
} // namespace GridTrackStateValues
63
64
bool
65
ToJSValue(JSContext* aCx, GridTrackState aArgument, JS::MutableHandle<JS::Value> aValue)
66
0
{
67
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(GridTrackStateValues::strings));
68
0
  JSString* resultStr =
69
0
    JS_NewStringCopyN(aCx, GridTrackStateValues::strings[uint32_t(aArgument)].value,
70
0
                      GridTrackStateValues::strings[uint32_t(aArgument)].length);
71
0
  if (!resultStr) {
72
0
    return false;
73
0
  }
74
0
  aValue.setString(resultStr);
75
0
  return true;
76
0
}
77
78
79
namespace Grid_Binding {
80
81
MOZ_CAN_RUN_SCRIPT static bool
82
get_rows(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Grid* self, JSJitGetterCallArgs args)
83
0
{
84
0
  AUTO_PROFILER_LABEL_FAST("get Grid.rows", DOM, cx);
85
0
86
0
  auto result(StrongOrRawPtr<mozilla::dom::GridDimension>(self->Rows()));
87
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
88
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
89
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
90
0
    return false;
91
0
  }
92
0
  return true;
93
0
}
94
95
static const JSJitInfo rows_getterinfo = {
96
  { (JSJitGetterOp)get_rows },
97
  { prototypes::id::Grid },
98
  { PrototypeTraits<prototypes::id::Grid>::Depth },
99
  JSJitInfo::Getter,
100
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
101
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
102
  false,  /* isInfallible. False in setters. */
103
  false,  /* isMovable.  Not relevant for setters. */
104
  false, /* isEliminatable.  Not relevant for setters. */
105
  false, /* isAlwaysInSlot.  Only relevant for getters. */
106
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
107
  false,  /* isTypedMethod.  Only relevant for methods. */
108
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
109
};
110
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
111
static_assert(0 < 2, "There is no slot for us");
112
113
MOZ_CAN_RUN_SCRIPT static bool
114
get_cols(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Grid* self, JSJitGetterCallArgs args)
115
0
{
116
0
  AUTO_PROFILER_LABEL_FAST("get Grid.cols", DOM, cx);
117
0
118
0
  auto result(StrongOrRawPtr<mozilla::dom::GridDimension>(self->Cols()));
119
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
120
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
121
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
122
0
    return false;
123
0
  }
124
0
  return true;
125
0
}
126
127
static const JSJitInfo cols_getterinfo = {
128
  { (JSJitGetterOp)get_cols },
129
  { prototypes::id::Grid },
130
  { PrototypeTraits<prototypes::id::Grid>::Depth },
131
  JSJitInfo::Getter,
132
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
133
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
134
  false,  /* isInfallible. False in setters. */
135
  false,  /* isMovable.  Not relevant for setters. */
136
  false, /* isEliminatable.  Not relevant for setters. */
137
  false, /* isAlwaysInSlot.  Only relevant for getters. */
138
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
139
  false,  /* isTypedMethod.  Only relevant for methods. */
140
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
141
};
142
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
143
static_assert(0 < 2, "There is no slot for us");
144
145
MOZ_CAN_RUN_SCRIPT static bool
146
get_areas(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Grid* self, JSJitGetterCallArgs args)
147
0
{
148
0
  AUTO_PROFILER_LABEL_FAST("get Grid.areas", DOM, cx);
149
0
150
0
  // Have to either root across the getter call or reget after.
151
0
  bool isXray;
152
0
  JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
153
0
  if (!slotStorage) {
154
0
    return false;
155
0
  }
156
0
  const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 0) : (DOM_INSTANCE_RESERVED_SLOTS + 0);
157
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
158
0
  {
159
0
    // Scope for cachedVal
160
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
161
0
    if (!cachedVal.isUndefined()) {
162
0
      args.rval().set(cachedVal);
163
0
      // The cached value is in the compartment of slotStorage,
164
0
      // so wrap into the caller compartment as needed.
165
0
      if (MaybeWrapNonDOMObjectValue(cx, args.rval())) {
166
0
        return true;
167
0
      }
168
0
      return false;
169
0
    }
170
0
  }
171
0
172
0
  nsTArray<StrongPtrForMember<mozilla::dom::GridArea>::Type> result;
173
0
  self->GetAreas(result);
174
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
175
0
  {
176
0
    JS::Rooted<JSObject*> conversionScope(cx, isXray ? JS::CurrentGlobalOrNull(cx) : slotStorage);
177
0
    JSAutoRealm ar(cx, conversionScope);
178
0
    do { // block we break out of when done wrapping
179
0
180
0
      uint32_t length = result.Length();
181
0
      JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
182
0
      if (!returnArray) {
183
0
        return false;
184
0
      }
185
0
      // Scope for 'tmp'
186
0
      {
187
0
        JS::Rooted<JS::Value> tmp(cx);
188
0
        for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
189
0
          // Control block to let us common up the JS_DefineElement calls when there
190
0
          // are different ways to succeed at wrapping the object.
191
0
          do {
192
0
            if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) {
193
0
              MOZ_ASSERT(JS_IsExceptionPending(cx));
194
0
              return false;
195
0
            }
196
0
            break;
197
0
          } while (false);
198
0
          if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
199
0
                                JSPROP_ENUMERATE)) {
200
0
            return false;
201
0
          }
202
0
        }
203
0
      }
204
0
      args.rval().setObject(*returnArray);
205
0
      break;
206
0
    } while (false);
207
0
  }
208
0
  { // And now store things in the realm of our slotStorage.
209
0
    JSAutoRealm ar(cx, slotStorage);
210
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
211
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
212
0
    if (!MaybeWrapNonDOMObjectValue(cx, &storedVal)) {
213
0
      return false;
214
0
    }
215
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
216
0
    if (!isXray) {
217
0
      // In the Xray case we don't need to do this, because getting the
218
0
      // expando object already preserved our wrapper.
219
0
      PreserveWrapper(self);
220
0
    }
221
0
  }
222
0
  // And now make sure args.rval() is in the caller realm.
223
0
  if (MaybeWrapNonDOMObjectValue(cx, args.rval())) {
224
0
    return true;
225
0
  }
226
0
  return false;
227
0
}
228
229
static const JSJitInfo areas_getterinfo = {
230
  { (JSJitGetterOp)get_areas },
231
  { prototypes::id::Grid },
232
  { PrototypeTraits<prototypes::id::Grid>::Depth },
233
  JSJitInfo::Getter,
234
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
235
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
236
  false,  /* isInfallible. False in setters. */
237
  true,  /* isMovable.  Not relevant for setters. */
238
  true, /* isEliminatable.  Not relevant for setters. */
239
  false, /* isAlwaysInSlot.  Only relevant for getters. */
240
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
241
  false,  /* isTypedMethod.  Only relevant for methods. */
242
  (DOM_INSTANCE_RESERVED_SLOTS + 0)   /* Reserved slot index, if we're stored in a slot, else 0. */
243
};
244
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) <= JSJitInfo::maxSlotIndex, "We won't fit");
245
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) < 2, "There is no slot for us");
246
247
static bool
248
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
249
0
{
250
0
  mozilla::dom::Grid* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Grid>(obj);
251
0
  // We don't want to preserve if we don't have a wrapper, and we
252
0
  // obviously can't preserve if we're not initialized.
253
0
  if (self && self->GetWrapperPreserveColor()) {
254
0
    PreserveWrapper(self);
255
0
  }
256
0
  return true;
257
0
}
258
259
static void
260
_finalize(js::FreeOp* fop, JSObject* obj)
261
0
{
262
0
  mozilla::dom::Grid* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Grid>(obj);
263
0
  if (self) {
264
0
    ClearWrapper(self, self, obj);
265
0
    AddForDeferredFinalization<mozilla::dom::Grid>(self);
266
0
  }
267
0
}
268
269
static size_t
270
_objectMoved(JSObject* obj, JSObject* old)
271
0
{
272
0
  mozilla::dom::Grid* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Grid>(obj);
273
0
  if (self) {
274
0
    UpdateWrapper(self, self, obj, old);
275
0
  }
276
0
277
0
  return 0;
278
0
}
279
280
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
281
#if defined(__clang__)
282
#pragma clang diagnostic push
283
#pragma clang diagnostic ignored "-Wmissing-braces"
284
#endif
285
static const JSPropertySpec sAttributes_specs[] = {
286
  { "rows", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &rows_getterinfo, nullptr, nullptr },
287
  { "cols", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &cols_getterinfo, nullptr, nullptr },
288
  { "areas", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &areas_getterinfo, nullptr, nullptr },
289
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
290
};
291
#if defined(__clang__)
292
#pragma clang diagnostic pop
293
#endif
294
295
296
static const Prefable<const JSPropertySpec> sAttributes[] = {
297
  { nullptr, &sAttributes_specs[0] },
298
  { nullptr, nullptr }
299
};
300
301
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
302
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
303
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
304
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
305
306
307
static uint16_t sNativeProperties_sortedPropertyIndices[3];
308
static PropertyInfo sNativeProperties_propertyInfos[3];
309
310
static const NativePropertiesN<1> sNativeProperties = {
311
  false, 0,
312
  false, 0,
313
  false, 0,
314
  true,  0 /* sAttributes */,
315
  false, 0,
316
  false, 0,
317
  false, 0,
318
  -1,
319
  3,
320
  sNativeProperties_sortedPropertyIndices,
321
  {
322
    { sAttributes, &sNativeProperties_propertyInfos[0] }
323
  }
324
};
325
static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
326
    "We have a property info count that is oversized");
327
328
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
329
  {
330
    "Function",
331
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
332
    &sBoringInterfaceObjectClassClassOps,
333
    JS_NULL_CLASS_SPEC,
334
    JS_NULL_CLASS_EXT,
335
    &sInterfaceObjectClassObjectOps
336
  },
337
  eInterface,
338
  true,
339
  prototypes::id::Grid,
340
  PrototypeTraits<prototypes::id::Grid>::Depth,
341
  sNativePropertyHooks,
342
  "function Grid() {\n    [native code]\n}",
343
  JS::GetRealmFunctionPrototype
344
};
345
346
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
347
  {
348
    "GridPrototype",
349
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
350
    JS_NULL_CLASS_OPS,
351
    JS_NULL_CLASS_SPEC,
352
    JS_NULL_CLASS_EXT,
353
    JS_NULL_OBJECT_OPS
354
  },
355
  eInterfacePrototype,
356
  false,
357
  prototypes::id::Grid,
358
  PrototypeTraits<prototypes::id::Grid>::Depth,
359
  sNativePropertyHooks,
360
  "[object GridPrototype]",
361
  JS::GetRealmObjectPrototype
362
};
363
364
bool
365
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
366
0
{
367
0
  return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
368
0
}
369
370
static const js::ClassOps sClassOps = {
371
  _addProperty, /* addProperty */
372
  nullptr,               /* delProperty */
373
  nullptr,               /* enumerate */
374
  nullptr, /* newEnumerate */
375
  nullptr, /* resolve */
376
  nullptr, /* mayResolve */
377
  _finalize, /* finalize */
378
  nullptr, /* call */
379
  nullptr,               /* hasInstance */
380
  nullptr,               /* construct */
381
  nullptr, /* trace */
382
};
383
384
static const js::ClassExtension sClassExtension = {
385
  nullptr, /* weakmapKeyDelegateOp */
386
  _objectMoved /* objectMovedOp */
387
};
388
389
static const DOMJSClass sClass = {
390
  { "Grid",
391
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(2),
392
    &sClassOps,
393
    JS_NULL_CLASS_SPEC,
394
    &sClassExtension,
395
    JS_NULL_OBJECT_OPS
396
  },
397
  { prototypes::id::Grid, 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 },
398
  IsBaseOf<nsISupports, mozilla::dom::Grid >::value,
399
  sNativePropertyHooks,
400
  FindAssociatedGlobalForNative<mozilla::dom::Grid>::Get,
401
  GetProtoObjectHandle,
402
  GetCCParticipant<mozilla::dom::Grid>::Get()
403
};
404
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
405
              "Must have the right minimal number of reserved slots.");
406
static_assert(2 >= 2,
407
              "Must have enough reserved slots.");
408
409
const JSClass*
410
GetJSClass()
411
0
{
412
0
  return sClass.ToJSClass();
413
0
}
414
415
bool
416
Wrap(JSContext* aCx, mozilla::dom::Grid* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
417
0
{
418
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::Grid>::value,
419
0
                "Shouldn't have wrappercached things that are not refcounted.");
420
0
  MOZ_ASSERT(static_cast<mozilla::dom::Grid*>(aObject) ==
421
0
             reinterpret_cast<mozilla::dom::Grid*>(aObject),
422
0
             "Multiple inheritance for mozilla::dom::Grid is broken.");
423
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
424
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
425
0
  MOZ_ASSERT(!aCache->GetWrapper(),
426
0
             "You should probably not be using Wrap() directly; use "
427
0
             "GetOrCreateDOMReflector instead");
428
0
429
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
430
0
             "nsISupports must be on our primary inheritance chain");
431
0
432
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
433
0
  if (!global) {
434
0
    return false;
435
0
  }
436
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
437
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
438
0
439
0
  // That might have ended up wrapping us already, due to the wonders
440
0
  // of XBL.  Check for that, and bail out as needed.
441
0
  aReflector.set(aCache->GetWrapper());
442
0
  if (aReflector) {
443
#ifdef DEBUG
444
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
445
#endif // DEBUG
446
    return true;
447
0
  }
448
0
449
0
  JSAutoRealm ar(aCx, global);
450
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
451
0
  if (!canonicalProto) {
452
0
    return false;
453
0
  }
454
0
  JS::Rooted<JSObject*> proto(aCx);
455
0
  if (aGivenProto) {
456
0
    proto = aGivenProto;
457
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
458
0
    // coming in, we changed compartments to that of "parent" so may need
459
0
    // to wrap the proto here.
460
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
461
0
      if (!JS_WrapObject(aCx, &proto)) {
462
0
        return false;
463
0
      }
464
0
    }
465
0
  } else {
466
0
    proto = canonicalProto;
467
0
  }
468
0
469
0
  BindingJSObjectCreator<mozilla::dom::Grid> creator(aCx);
470
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
471
0
  if (!aReflector) {
472
0
    return false;
473
0
  }
474
0
475
0
  aCache->SetWrapper(aReflector);
476
0
  creator.InitializationSucceeded();
477
0
478
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
479
0
             aCache->GetWrapperPreserveColor() == aReflector);
480
0
  // If proto != canonicalProto, we have to preserve our wrapper;
481
0
  // otherwise we won't be able to properly recreate it later, since
482
0
  // we won't know what proto to use.  Note that we don't check
483
0
  // aGivenProto here, since it's entirely possible (and even
484
0
  // somewhat common) to have a non-null aGivenProto which is the
485
0
  // same as canonicalProto.
486
0
  if (proto != canonicalProto) {
487
0
    PreserveWrapper(aObject);
488
0
  }
489
0
490
0
  return true;
491
0
}
492
493
// This may allocate too many slots, because we only really need
494
// slots for our non-interface-typed members that we cache.  But
495
// allocating slots only for those would make the slot index
496
// computations much more complicated, so let's do this the simple
497
// way for now.
498
DEFINE_XRAY_EXPANDO_CLASS(static, sXrayExpandoObjectClass, 1);
499
500
const NativePropertyHooks sNativePropertyHooks[] = { {
501
  nullptr,
502
  nullptr,
503
  nullptr,
504
  { sNativeProperties.Upcast(), nullptr },
505
  prototypes::id::Grid,
506
  constructors::id::Grid,
507
  nullptr,
508
  &sXrayExpandoObjectClass
509
} };
510
511
void
512
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
513
0
{
514
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
515
0
  if (!parentProto) {
516
0
    return;
517
0
  }
518
0
519
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
520
0
  if (!constructorProto) {
521
0
    return;
522
0
  }
523
0
524
0
  static bool sIdsInited = false;
525
0
  if (!sIdsInited && NS_IsMainThread()) {
526
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
527
0
      return;
528
0
    }
529
0
    sIdsInited = true;
530
0
  }
531
0
532
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::Grid);
533
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::Grid);
534
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
535
0
                              &sPrototypeClass.mBase, protoCache,
536
0
                              nullptr,
537
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
538
0
                              interfaceCache,
539
0
                              sNativeProperties.Upcast(),
540
0
                              nullptr,
541
0
                              "Grid", aDefineOnGlobal,
542
0
                              nullptr,
543
0
                              false);
544
0
}
545
546
JSObject*
547
GetConstructorObject(JSContext* aCx)
548
0
{
549
0
  return GetConstructorObjectHandle(aCx);
550
0
}
551
552
} // namespace Grid_Binding
553
554
555
556
namespace GridArea_Binding {
557
558
MOZ_CAN_RUN_SCRIPT static bool
559
get_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridArea* self, JSJitGetterCallArgs args)
560
0
{
561
0
  AUTO_PROFILER_LABEL_FAST("get GridArea.name", DOM, cx);
562
0
563
0
  DOMString result;
564
0
  self->GetName(result);
565
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
566
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
567
0
    return false;
568
0
  }
569
0
  return true;
570
0
}
571
572
static const JSJitInfo name_getterinfo = {
573
  { (JSJitGetterOp)get_name },
574
  { prototypes::id::GridArea },
575
  { PrototypeTraits<prototypes::id::GridArea>::Depth },
576
  JSJitInfo::Getter,
577
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
578
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
579
  false,  /* isInfallible. False in setters. */
580
  false,  /* isMovable.  Not relevant for setters. */
581
  false, /* isEliminatable.  Not relevant for setters. */
582
  false, /* isAlwaysInSlot.  Only relevant for getters. */
583
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
584
  false,  /* isTypedMethod.  Only relevant for methods. */
585
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
586
};
587
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
588
static_assert(0 < 1, "There is no slot for us");
589
590
MOZ_CAN_RUN_SCRIPT static bool
591
get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridArea* self, JSJitGetterCallArgs args)
592
0
{
593
0
  AUTO_PROFILER_LABEL_FAST("get GridArea.type", DOM, cx);
594
0
595
0
  GridDeclaration result(self->Type());
596
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
597
0
  if (!ToJSValue(cx, result, args.rval())) {
598
0
    return false;
599
0
  }
600
0
  return true;
601
0
}
602
603
static const JSJitInfo type_getterinfo = {
604
  { (JSJitGetterOp)get_type },
605
  { prototypes::id::GridArea },
606
  { PrototypeTraits<prototypes::id::GridArea>::Depth },
607
  JSJitInfo::Getter,
608
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
609
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
610
  false,  /* isInfallible. False in setters. */
611
  false,  /* isMovable.  Not relevant for setters. */
612
  false, /* isEliminatable.  Not relevant for setters. */
613
  false, /* isAlwaysInSlot.  Only relevant for getters. */
614
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
615
  false,  /* isTypedMethod.  Only relevant for methods. */
616
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
617
};
618
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
619
static_assert(0 < 1, "There is no slot for us");
620
621
MOZ_CAN_RUN_SCRIPT static bool
622
get_rowStart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridArea* self, JSJitGetterCallArgs args)
623
0
{
624
0
  AUTO_PROFILER_LABEL_FAST("get GridArea.rowStart", DOM, cx);
625
0
626
0
  uint32_t result(self->RowStart());
627
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
628
0
  args.rval().setNumber(result);
629
0
  return true;
630
0
}
631
632
static const JSJitInfo rowStart_getterinfo = {
633
  { (JSJitGetterOp)get_rowStart },
634
  { prototypes::id::GridArea },
635
  { PrototypeTraits<prototypes::id::GridArea>::Depth },
636
  JSJitInfo::Getter,
637
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
638
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
639
  true,  /* isInfallible. False in setters. */
640
  false,  /* isMovable.  Not relevant for setters. */
641
  false, /* isEliminatable.  Not relevant for setters. */
642
  false, /* isAlwaysInSlot.  Only relevant for getters. */
643
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
644
  false,  /* isTypedMethod.  Only relevant for methods. */
645
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
646
};
647
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
648
static_assert(0 < 1, "There is no slot for us");
649
650
MOZ_CAN_RUN_SCRIPT static bool
651
get_rowEnd(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridArea* self, JSJitGetterCallArgs args)
652
0
{
653
0
  AUTO_PROFILER_LABEL_FAST("get GridArea.rowEnd", DOM, cx);
654
0
655
0
  uint32_t result(self->RowEnd());
656
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
657
0
  args.rval().setNumber(result);
658
0
  return true;
659
0
}
660
661
static const JSJitInfo rowEnd_getterinfo = {
662
  { (JSJitGetterOp)get_rowEnd },
663
  { prototypes::id::GridArea },
664
  { PrototypeTraits<prototypes::id::GridArea>::Depth },
665
  JSJitInfo::Getter,
666
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
667
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
668
  true,  /* isInfallible. False in setters. */
669
  false,  /* isMovable.  Not relevant for setters. */
670
  false, /* isEliminatable.  Not relevant for setters. */
671
  false, /* isAlwaysInSlot.  Only relevant for getters. */
672
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
673
  false,  /* isTypedMethod.  Only relevant for methods. */
674
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
675
};
676
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
677
static_assert(0 < 1, "There is no slot for us");
678
679
MOZ_CAN_RUN_SCRIPT static bool
680
get_columnStart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridArea* self, JSJitGetterCallArgs args)
681
0
{
682
0
  AUTO_PROFILER_LABEL_FAST("get GridArea.columnStart", DOM, cx);
683
0
684
0
  uint32_t result(self->ColumnStart());
685
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
686
0
  args.rval().setNumber(result);
687
0
  return true;
688
0
}
689
690
static const JSJitInfo columnStart_getterinfo = {
691
  { (JSJitGetterOp)get_columnStart },
692
  { prototypes::id::GridArea },
693
  { PrototypeTraits<prototypes::id::GridArea>::Depth },
694
  JSJitInfo::Getter,
695
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
696
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
697
  true,  /* isInfallible. False in setters. */
698
  false,  /* isMovable.  Not relevant for setters. */
699
  false, /* isEliminatable.  Not relevant for setters. */
700
  false, /* isAlwaysInSlot.  Only relevant for getters. */
701
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
702
  false,  /* isTypedMethod.  Only relevant for methods. */
703
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
704
};
705
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
706
static_assert(0 < 1, "There is no slot for us");
707
708
MOZ_CAN_RUN_SCRIPT static bool
709
get_columnEnd(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridArea* self, JSJitGetterCallArgs args)
710
0
{
711
0
  AUTO_PROFILER_LABEL_FAST("get GridArea.columnEnd", DOM, cx);
712
0
713
0
  uint32_t result(self->ColumnEnd());
714
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
715
0
  args.rval().setNumber(result);
716
0
  return true;
717
0
}
718
719
static const JSJitInfo columnEnd_getterinfo = {
720
  { (JSJitGetterOp)get_columnEnd },
721
  { prototypes::id::GridArea },
722
  { PrototypeTraits<prototypes::id::GridArea>::Depth },
723
  JSJitInfo::Getter,
724
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
725
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
726
  true,  /* isInfallible. False in setters. */
727
  false,  /* isMovable.  Not relevant for setters. */
728
  false, /* isEliminatable.  Not relevant for setters. */
729
  false, /* isAlwaysInSlot.  Only relevant for getters. */
730
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
731
  false,  /* isTypedMethod.  Only relevant for methods. */
732
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
733
};
734
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
735
static_assert(0 < 1, "There is no slot for us");
736
737
static bool
738
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
739
0
{
740
0
  mozilla::dom::GridArea* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridArea>(obj);
741
0
  // We don't want to preserve if we don't have a wrapper, and we
742
0
  // obviously can't preserve if we're not initialized.
743
0
  if (self && self->GetWrapperPreserveColor()) {
744
0
    PreserveWrapper(self);
745
0
  }
746
0
  return true;
747
0
}
748
749
static void
750
_finalize(js::FreeOp* fop, JSObject* obj)
751
0
{
752
0
  mozilla::dom::GridArea* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridArea>(obj);
753
0
  if (self) {
754
0
    ClearWrapper(self, self, obj);
755
0
    AddForDeferredFinalization<mozilla::dom::GridArea>(self);
756
0
  }
757
0
}
758
759
static size_t
760
_objectMoved(JSObject* obj, JSObject* old)
761
0
{
762
0
  mozilla::dom::GridArea* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridArea>(obj);
763
0
  if (self) {
764
0
    UpdateWrapper(self, self, obj, old);
765
0
  }
766
0
767
0
  return 0;
768
0
}
769
770
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
771
#if defined(__clang__)
772
#pragma clang diagnostic push
773
#pragma clang diagnostic ignored "-Wmissing-braces"
774
#endif
775
static const JSPropertySpec sAttributes_specs[] = {
776
  { "name", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &name_getterinfo, nullptr, nullptr },
777
  { "type", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &type_getterinfo, nullptr, nullptr },
778
  { "rowStart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &rowStart_getterinfo, nullptr, nullptr },
779
  { "rowEnd", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &rowEnd_getterinfo, nullptr, nullptr },
780
  { "columnStart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &columnStart_getterinfo, nullptr, nullptr },
781
  { "columnEnd", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &columnEnd_getterinfo, nullptr, nullptr },
782
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
783
};
784
#if defined(__clang__)
785
#pragma clang diagnostic pop
786
#endif
787
788
789
static const Prefable<const JSPropertySpec> sAttributes[] = {
790
  { nullptr, &sAttributes_specs[0] },
791
  { nullptr, nullptr }
792
};
793
794
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
795
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
796
static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
797
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
798
799
800
static uint16_t sNativeProperties_sortedPropertyIndices[6];
801
static PropertyInfo sNativeProperties_propertyInfos[6];
802
803
static const NativePropertiesN<1> sNativeProperties = {
804
  false, 0,
805
  false, 0,
806
  false, 0,
807
  true,  0 /* sAttributes */,
808
  false, 0,
809
  false, 0,
810
  false, 0,
811
  -1,
812
  6,
813
  sNativeProperties_sortedPropertyIndices,
814
  {
815
    { sAttributes, &sNativeProperties_propertyInfos[0] }
816
  }
817
};
818
static_assert(6 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
819
    "We have a property info count that is oversized");
820
821
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
822
  {
823
    "Function",
824
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
825
    &sBoringInterfaceObjectClassClassOps,
826
    JS_NULL_CLASS_SPEC,
827
    JS_NULL_CLASS_EXT,
828
    &sInterfaceObjectClassObjectOps
829
  },
830
  eInterface,
831
  true,
832
  prototypes::id::GridArea,
833
  PrototypeTraits<prototypes::id::GridArea>::Depth,
834
  sNativePropertyHooks,
835
  "function GridArea() {\n    [native code]\n}",
836
  JS::GetRealmFunctionPrototype
837
};
838
839
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
840
  {
841
    "GridAreaPrototype",
842
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
843
    JS_NULL_CLASS_OPS,
844
    JS_NULL_CLASS_SPEC,
845
    JS_NULL_CLASS_EXT,
846
    JS_NULL_OBJECT_OPS
847
  },
848
  eInterfacePrototype,
849
  false,
850
  prototypes::id::GridArea,
851
  PrototypeTraits<prototypes::id::GridArea>::Depth,
852
  sNativePropertyHooks,
853
  "[object GridAreaPrototype]",
854
  JS::GetRealmObjectPrototype
855
};
856
857
bool
858
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
859
0
{
860
0
  return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
861
0
}
862
863
static const js::ClassOps sClassOps = {
864
  _addProperty, /* addProperty */
865
  nullptr,               /* delProperty */
866
  nullptr,               /* enumerate */
867
  nullptr, /* newEnumerate */
868
  nullptr, /* resolve */
869
  nullptr, /* mayResolve */
870
  _finalize, /* finalize */
871
  nullptr, /* call */
872
  nullptr,               /* hasInstance */
873
  nullptr,               /* construct */
874
  nullptr, /* trace */
875
};
876
877
static const js::ClassExtension sClassExtension = {
878
  nullptr, /* weakmapKeyDelegateOp */
879
  _objectMoved /* objectMovedOp */
880
};
881
882
static const DOMJSClass sClass = {
883
  { "GridArea",
884
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
885
    &sClassOps,
886
    JS_NULL_CLASS_SPEC,
887
    &sClassExtension,
888
    JS_NULL_OBJECT_OPS
889
  },
890
  { prototypes::id::GridArea, 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 },
891
  IsBaseOf<nsISupports, mozilla::dom::GridArea >::value,
892
  sNativePropertyHooks,
893
  FindAssociatedGlobalForNative<mozilla::dom::GridArea>::Get,
894
  GetProtoObjectHandle,
895
  GetCCParticipant<mozilla::dom::GridArea>::Get()
896
};
897
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
898
              "Must have the right minimal number of reserved slots.");
899
static_assert(1 >= 1,
900
              "Must have enough reserved slots.");
901
902
const JSClass*
903
GetJSClass()
904
0
{
905
0
  return sClass.ToJSClass();
906
0
}
907
908
bool
909
Wrap(JSContext* aCx, mozilla::dom::GridArea* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
910
0
{
911
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::GridArea>::value,
912
0
                "Shouldn't have wrappercached things that are not refcounted.");
913
0
  MOZ_ASSERT(static_cast<mozilla::dom::GridArea*>(aObject) ==
914
0
             reinterpret_cast<mozilla::dom::GridArea*>(aObject),
915
0
             "Multiple inheritance for mozilla::dom::GridArea is broken.");
916
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
917
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
918
0
  MOZ_ASSERT(!aCache->GetWrapper(),
919
0
             "You should probably not be using Wrap() directly; use "
920
0
             "GetOrCreateDOMReflector instead");
921
0
922
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
923
0
             "nsISupports must be on our primary inheritance chain");
924
0
925
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
926
0
  if (!global) {
927
0
    return false;
928
0
  }
929
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
930
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
931
0
932
0
  // That might have ended up wrapping us already, due to the wonders
933
0
  // of XBL.  Check for that, and bail out as needed.
934
0
  aReflector.set(aCache->GetWrapper());
935
0
  if (aReflector) {
936
#ifdef DEBUG
937
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
938
#endif // DEBUG
939
    return true;
940
0
  }
941
0
942
0
  JSAutoRealm ar(aCx, global);
943
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
944
0
  if (!canonicalProto) {
945
0
    return false;
946
0
  }
947
0
  JS::Rooted<JSObject*> proto(aCx);
948
0
  if (aGivenProto) {
949
0
    proto = aGivenProto;
950
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
951
0
    // coming in, we changed compartments to that of "parent" so may need
952
0
    // to wrap the proto here.
953
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
954
0
      if (!JS_WrapObject(aCx, &proto)) {
955
0
        return false;
956
0
      }
957
0
    }
958
0
  } else {
959
0
    proto = canonicalProto;
960
0
  }
961
0
962
0
  BindingJSObjectCreator<mozilla::dom::GridArea> creator(aCx);
963
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
964
0
  if (!aReflector) {
965
0
    return false;
966
0
  }
967
0
968
0
  aCache->SetWrapper(aReflector);
969
0
  creator.InitializationSucceeded();
970
0
971
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
972
0
             aCache->GetWrapperPreserveColor() == aReflector);
973
0
  // If proto != canonicalProto, we have to preserve our wrapper;
974
0
  // otherwise we won't be able to properly recreate it later, since
975
0
  // we won't know what proto to use.  Note that we don't check
976
0
  // aGivenProto here, since it's entirely possible (and even
977
0
  // somewhat common) to have a non-null aGivenProto which is the
978
0
  // same as canonicalProto.
979
0
  if (proto != canonicalProto) {
980
0
    PreserveWrapper(aObject);
981
0
  }
982
0
983
0
  return true;
984
0
}
985
986
const NativePropertyHooks sNativePropertyHooks[] = { {
987
  nullptr,
988
  nullptr,
989
  nullptr,
990
  { sNativeProperties.Upcast(), nullptr },
991
  prototypes::id::GridArea,
992
  constructors::id::GridArea,
993
  nullptr,
994
  &DefaultXrayExpandoObjectClass
995
} };
996
997
void
998
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
999
0
{
1000
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
1001
0
  if (!parentProto) {
1002
0
    return;
1003
0
  }
1004
0
1005
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
1006
0
  if (!constructorProto) {
1007
0
    return;
1008
0
  }
1009
0
1010
0
  static bool sIdsInited = false;
1011
0
  if (!sIdsInited && NS_IsMainThread()) {
1012
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1013
0
      return;
1014
0
    }
1015
0
    sIdsInited = true;
1016
0
  }
1017
0
1018
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::GridArea);
1019
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::GridArea);
1020
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1021
0
                              &sPrototypeClass.mBase, protoCache,
1022
0
                              nullptr,
1023
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1024
0
                              interfaceCache,
1025
0
                              sNativeProperties.Upcast(),
1026
0
                              nullptr,
1027
0
                              "GridArea", aDefineOnGlobal,
1028
0
                              nullptr,
1029
0
                              false);
1030
0
}
1031
1032
JSObject*
1033
GetConstructorObject(JSContext* aCx)
1034
0
{
1035
0
  return GetConstructorObjectHandle(aCx);
1036
0
}
1037
1038
} // namespace GridArea_Binding
1039
1040
1041
1042
namespace GridDimension_Binding {
1043
1044
MOZ_CAN_RUN_SCRIPT static bool
1045
get_lines(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridDimension* self, JSJitGetterCallArgs args)
1046
0
{
1047
0
  AUTO_PROFILER_LABEL_FAST("get GridDimension.lines", DOM, cx);
1048
0
1049
0
  auto result(StrongOrRawPtr<mozilla::dom::GridLines>(self->Lines()));
1050
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1051
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1052
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1053
0
    return false;
1054
0
  }
1055
0
  return true;
1056
0
}
1057
1058
static const JSJitInfo lines_getterinfo = {
1059
  { (JSJitGetterOp)get_lines },
1060
  { prototypes::id::GridDimension },
1061
  { PrototypeTraits<prototypes::id::GridDimension>::Depth },
1062
  JSJitInfo::Getter,
1063
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1064
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1065
  false,  /* isInfallible. False in setters. */
1066
  false,  /* isMovable.  Not relevant for setters. */
1067
  false, /* isEliminatable.  Not relevant for setters. */
1068
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1069
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1070
  false,  /* isTypedMethod.  Only relevant for methods. */
1071
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1072
};
1073
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1074
static_assert(0 < 1, "There is no slot for us");
1075
1076
MOZ_CAN_RUN_SCRIPT static bool
1077
get_tracks(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridDimension* self, JSJitGetterCallArgs args)
1078
0
{
1079
0
  AUTO_PROFILER_LABEL_FAST("get GridDimension.tracks", DOM, cx);
1080
0
1081
0
  auto result(StrongOrRawPtr<mozilla::dom::GridTracks>(self->Tracks()));
1082
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1083
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1084
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1085
0
    return false;
1086
0
  }
1087
0
  return true;
1088
0
}
1089
1090
static const JSJitInfo tracks_getterinfo = {
1091
  { (JSJitGetterOp)get_tracks },
1092
  { prototypes::id::GridDimension },
1093
  { PrototypeTraits<prototypes::id::GridDimension>::Depth },
1094
  JSJitInfo::Getter,
1095
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1096
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1097
  false,  /* isInfallible. False in setters. */
1098
  false,  /* isMovable.  Not relevant for setters. */
1099
  false, /* isEliminatable.  Not relevant for setters. */
1100
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1101
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1102
  false,  /* isTypedMethod.  Only relevant for methods. */
1103
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1104
};
1105
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1106
static_assert(0 < 1, "There is no slot for us");
1107
1108
static bool
1109
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1110
0
{
1111
0
  mozilla::dom::GridDimension* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridDimension>(obj);
1112
0
  // We don't want to preserve if we don't have a wrapper, and we
1113
0
  // obviously can't preserve if we're not initialized.
1114
0
  if (self && self->GetWrapperPreserveColor()) {
1115
0
    PreserveWrapper(self);
1116
0
  }
1117
0
  return true;
1118
0
}
1119
1120
static void
1121
_finalize(js::FreeOp* fop, JSObject* obj)
1122
0
{
1123
0
  mozilla::dom::GridDimension* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridDimension>(obj);
1124
0
  if (self) {
1125
0
    ClearWrapper(self, self, obj);
1126
0
    AddForDeferredFinalization<mozilla::dom::GridDimension>(self);
1127
0
  }
1128
0
}
1129
1130
static size_t
1131
_objectMoved(JSObject* obj, JSObject* old)
1132
0
{
1133
0
  mozilla::dom::GridDimension* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridDimension>(obj);
1134
0
  if (self) {
1135
0
    UpdateWrapper(self, self, obj, old);
1136
0
  }
1137
0
1138
0
  return 0;
1139
0
}
1140
1141
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1142
#if defined(__clang__)
1143
#pragma clang diagnostic push
1144
#pragma clang diagnostic ignored "-Wmissing-braces"
1145
#endif
1146
static const JSPropertySpec sAttributes_specs[] = {
1147
  { "lines", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &lines_getterinfo, nullptr, nullptr },
1148
  { "tracks", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &tracks_getterinfo, nullptr, nullptr },
1149
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1150
};
1151
#if defined(__clang__)
1152
#pragma clang diagnostic pop
1153
#endif
1154
1155
1156
static const Prefable<const JSPropertySpec> sAttributes[] = {
1157
  { nullptr, &sAttributes_specs[0] },
1158
  { nullptr, nullptr }
1159
};
1160
1161
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1162
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1163
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1164
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1165
1166
1167
static uint16_t sNativeProperties_sortedPropertyIndices[2];
1168
static PropertyInfo sNativeProperties_propertyInfos[2];
1169
1170
static const NativePropertiesN<1> sNativeProperties = {
1171
  false, 0,
1172
  false, 0,
1173
  false, 0,
1174
  true,  0 /* sAttributes */,
1175
  false, 0,
1176
  false, 0,
1177
  false, 0,
1178
  -1,
1179
  2,
1180
  sNativeProperties_sortedPropertyIndices,
1181
  {
1182
    { sAttributes, &sNativeProperties_propertyInfos[0] }
1183
  }
1184
};
1185
static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1186
    "We have a property info count that is oversized");
1187
1188
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1189
  {
1190
    "Function",
1191
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1192
    &sBoringInterfaceObjectClassClassOps,
1193
    JS_NULL_CLASS_SPEC,
1194
    JS_NULL_CLASS_EXT,
1195
    &sInterfaceObjectClassObjectOps
1196
  },
1197
  eInterface,
1198
  true,
1199
  prototypes::id::GridDimension,
1200
  PrototypeTraits<prototypes::id::GridDimension>::Depth,
1201
  sNativePropertyHooks,
1202
  "function GridDimension() {\n    [native code]\n}",
1203
  JS::GetRealmFunctionPrototype
1204
};
1205
1206
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1207
  {
1208
    "GridDimensionPrototype",
1209
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1210
    JS_NULL_CLASS_OPS,
1211
    JS_NULL_CLASS_SPEC,
1212
    JS_NULL_CLASS_EXT,
1213
    JS_NULL_OBJECT_OPS
1214
  },
1215
  eInterfacePrototype,
1216
  false,
1217
  prototypes::id::GridDimension,
1218
  PrototypeTraits<prototypes::id::GridDimension>::Depth,
1219
  sNativePropertyHooks,
1220
  "[object GridDimensionPrototype]",
1221
  JS::GetRealmObjectPrototype
1222
};
1223
1224
bool
1225
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
1226
0
{
1227
0
  return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
1228
0
}
1229
1230
static const js::ClassOps sClassOps = {
1231
  _addProperty, /* addProperty */
1232
  nullptr,               /* delProperty */
1233
  nullptr,               /* enumerate */
1234
  nullptr, /* newEnumerate */
1235
  nullptr, /* resolve */
1236
  nullptr, /* mayResolve */
1237
  _finalize, /* finalize */
1238
  nullptr, /* call */
1239
  nullptr,               /* hasInstance */
1240
  nullptr,               /* construct */
1241
  nullptr, /* trace */
1242
};
1243
1244
static const js::ClassExtension sClassExtension = {
1245
  nullptr, /* weakmapKeyDelegateOp */
1246
  _objectMoved /* objectMovedOp */
1247
};
1248
1249
static const DOMJSClass sClass = {
1250
  { "GridDimension",
1251
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1252
    &sClassOps,
1253
    JS_NULL_CLASS_SPEC,
1254
    &sClassExtension,
1255
    JS_NULL_OBJECT_OPS
1256
  },
1257
  { prototypes::id::GridDimension, 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 },
1258
  IsBaseOf<nsISupports, mozilla::dom::GridDimension >::value,
1259
  sNativePropertyHooks,
1260
  FindAssociatedGlobalForNative<mozilla::dom::GridDimension>::Get,
1261
  GetProtoObjectHandle,
1262
  GetCCParticipant<mozilla::dom::GridDimension>::Get()
1263
};
1264
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1265
              "Must have the right minimal number of reserved slots.");
1266
static_assert(1 >= 1,
1267
              "Must have enough reserved slots.");
1268
1269
const JSClass*
1270
GetJSClass()
1271
0
{
1272
0
  return sClass.ToJSClass();
1273
0
}
1274
1275
bool
1276
Wrap(JSContext* aCx, mozilla::dom::GridDimension* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1277
0
{
1278
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::GridDimension>::value,
1279
0
                "Shouldn't have wrappercached things that are not refcounted.");
1280
0
  MOZ_ASSERT(static_cast<mozilla::dom::GridDimension*>(aObject) ==
1281
0
             reinterpret_cast<mozilla::dom::GridDimension*>(aObject),
1282
0
             "Multiple inheritance for mozilla::dom::GridDimension is broken.");
1283
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1284
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1285
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1286
0
             "You should probably not be using Wrap() directly; use "
1287
0
             "GetOrCreateDOMReflector instead");
1288
0
1289
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1290
0
             "nsISupports must be on our primary inheritance chain");
1291
0
1292
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1293
0
  if (!global) {
1294
0
    return false;
1295
0
  }
1296
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1297
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1298
0
1299
0
  // That might have ended up wrapping us already, due to the wonders
1300
0
  // of XBL.  Check for that, and bail out as needed.
1301
0
  aReflector.set(aCache->GetWrapper());
1302
0
  if (aReflector) {
1303
#ifdef DEBUG
1304
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1305
#endif // DEBUG
1306
    return true;
1307
0
  }
1308
0
1309
0
  JSAutoRealm ar(aCx, global);
1310
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1311
0
  if (!canonicalProto) {
1312
0
    return false;
1313
0
  }
1314
0
  JS::Rooted<JSObject*> proto(aCx);
1315
0
  if (aGivenProto) {
1316
0
    proto = aGivenProto;
1317
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1318
0
    // coming in, we changed compartments to that of "parent" so may need
1319
0
    // to wrap the proto here.
1320
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1321
0
      if (!JS_WrapObject(aCx, &proto)) {
1322
0
        return false;
1323
0
      }
1324
0
    }
1325
0
  } else {
1326
0
    proto = canonicalProto;
1327
0
  }
1328
0
1329
0
  BindingJSObjectCreator<mozilla::dom::GridDimension> creator(aCx);
1330
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1331
0
  if (!aReflector) {
1332
0
    return false;
1333
0
  }
1334
0
1335
0
  aCache->SetWrapper(aReflector);
1336
0
  creator.InitializationSucceeded();
1337
0
1338
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1339
0
             aCache->GetWrapperPreserveColor() == aReflector);
1340
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1341
0
  // otherwise we won't be able to properly recreate it later, since
1342
0
  // we won't know what proto to use.  Note that we don't check
1343
0
  // aGivenProto here, since it's entirely possible (and even
1344
0
  // somewhat common) to have a non-null aGivenProto which is the
1345
0
  // same as canonicalProto.
1346
0
  if (proto != canonicalProto) {
1347
0
    PreserveWrapper(aObject);
1348
0
  }
1349
0
1350
0
  return true;
1351
0
}
1352
1353
const NativePropertyHooks sNativePropertyHooks[] = { {
1354
  nullptr,
1355
  nullptr,
1356
  nullptr,
1357
  { sNativeProperties.Upcast(), nullptr },
1358
  prototypes::id::GridDimension,
1359
  constructors::id::GridDimension,
1360
  nullptr,
1361
  &DefaultXrayExpandoObjectClass
1362
} };
1363
1364
void
1365
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1366
0
{
1367
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
1368
0
  if (!parentProto) {
1369
0
    return;
1370
0
  }
1371
0
1372
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
1373
0
  if (!constructorProto) {
1374
0
    return;
1375
0
  }
1376
0
1377
0
  static bool sIdsInited = false;
1378
0
  if (!sIdsInited && NS_IsMainThread()) {
1379
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1380
0
      return;
1381
0
    }
1382
0
    sIdsInited = true;
1383
0
  }
1384
0
1385
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::GridDimension);
1386
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::GridDimension);
1387
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1388
0
                              &sPrototypeClass.mBase, protoCache,
1389
0
                              nullptr,
1390
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1391
0
                              interfaceCache,
1392
0
                              sNativeProperties.Upcast(),
1393
0
                              nullptr,
1394
0
                              "GridDimension", aDefineOnGlobal,
1395
0
                              nullptr,
1396
0
                              false);
1397
0
}
1398
1399
JSObject*
1400
GetConstructorObject(JSContext* aCx)
1401
0
{
1402
0
  return GetConstructorObjectHandle(aCx);
1403
0
}
1404
1405
} // namespace GridDimension_Binding
1406
1407
1408
1409
namespace GridLine_Binding {
1410
1411
MOZ_CAN_RUN_SCRIPT static bool
1412
get_names(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridLine* self, JSJitGetterCallArgs args)
1413
0
{
1414
0
  AUTO_PROFILER_LABEL_FAST("get GridLine.names", DOM, cx);
1415
0
1416
0
  // Have to either root across the getter call or reget after.
1417
0
  bool isXray;
1418
0
  JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
1419
0
  if (!slotStorage) {
1420
0
    return false;
1421
0
  }
1422
0
  const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 0) : (DOM_INSTANCE_RESERVED_SLOTS + 0);
1423
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
1424
0
  {
1425
0
    // Scope for cachedVal
1426
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
1427
0
    if (!cachedVal.isUndefined()) {
1428
0
      args.rval().set(cachedVal);
1429
0
      // The cached value is in the compartment of slotStorage,
1430
0
      // so wrap into the caller compartment as needed.
1431
0
      if (MaybeWrapNonDOMObjectValue(cx, args.rval())) {
1432
0
        return true;
1433
0
      }
1434
0
      return false;
1435
0
    }
1436
0
  }
1437
0
1438
0
  nsTArray<nsString> result;
1439
0
  self->GetNames(result);
1440
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1441
0
  {
1442
0
    JS::Rooted<JSObject*> conversionScope(cx, isXray ? JS::CurrentGlobalOrNull(cx) : slotStorage);
1443
0
    JSAutoRealm ar(cx, conversionScope);
1444
0
    do { // block we break out of when done wrapping
1445
0
1446
0
      uint32_t length = result.Length();
1447
0
      JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
1448
0
      if (!returnArray) {
1449
0
        return false;
1450
0
      }
1451
0
      // Scope for 'tmp'
1452
0
      {
1453
0
        JS::Rooted<JS::Value> tmp(cx);
1454
0
        for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
1455
0
          // Control block to let us common up the JS_DefineElement calls when there
1456
0
          // are different ways to succeed at wrapping the object.
1457
0
          do {
1458
0
            if (!xpc::NonVoidStringToJsval(cx, result[sequenceIdx0], &tmp)) {
1459
0
              return false;
1460
0
            }
1461
0
            break;
1462
0
          } while (false);
1463
0
          if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
1464
0
                                JSPROP_ENUMERATE)) {
1465
0
            return false;
1466
0
          }
1467
0
        }
1468
0
      }
1469
0
      args.rval().setObject(*returnArray);
1470
0
      break;
1471
0
    } while (false);
1472
0
  }
1473
0
  { // And now store things in the realm of our slotStorage.
1474
0
    JSAutoRealm ar(cx, slotStorage);
1475
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
1476
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
1477
0
    if (!MaybeWrapNonDOMObjectValue(cx, &storedVal)) {
1478
0
      return false;
1479
0
    }
1480
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
1481
0
    if (!isXray) {
1482
0
      // In the Xray case we don't need to do this, because getting the
1483
0
      // expando object already preserved our wrapper.
1484
0
      PreserveWrapper(self);
1485
0
    }
1486
0
  }
1487
0
  // And now make sure args.rval() is in the caller realm.
1488
0
  if (MaybeWrapNonDOMObjectValue(cx, args.rval())) {
1489
0
    return true;
1490
0
  }
1491
0
  return false;
1492
0
}
1493
1494
static const JSJitInfo names_getterinfo = {
1495
  { (JSJitGetterOp)get_names },
1496
  { prototypes::id::GridLine },
1497
  { PrototypeTraits<prototypes::id::GridLine>::Depth },
1498
  JSJitInfo::Getter,
1499
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
1500
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1501
  false,  /* isInfallible. False in setters. */
1502
  true,  /* isMovable.  Not relevant for setters. */
1503
  true, /* isEliminatable.  Not relevant for setters. */
1504
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1505
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
1506
  false,  /* isTypedMethod.  Only relevant for methods. */
1507
  (DOM_INSTANCE_RESERVED_SLOTS + 0)   /* Reserved slot index, if we're stored in a slot, else 0. */
1508
};
1509
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) <= JSJitInfo::maxSlotIndex, "We won't fit");
1510
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) < 2, "There is no slot for us");
1511
1512
MOZ_CAN_RUN_SCRIPT static bool
1513
get_start(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridLine* self, JSJitGetterCallArgs args)
1514
0
{
1515
0
  AUTO_PROFILER_LABEL_FAST("get GridLine.start", DOM, cx);
1516
0
1517
0
  double result(self->Start());
1518
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1519
0
  args.rval().set(JS_NumberValue(double(result)));
1520
0
  return true;
1521
0
}
1522
1523
static const JSJitInfo start_getterinfo = {
1524
  { (JSJitGetterOp)get_start },
1525
  { prototypes::id::GridLine },
1526
  { PrototypeTraits<prototypes::id::GridLine>::Depth },
1527
  JSJitInfo::Getter,
1528
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1529
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
1530
  true,  /* isInfallible. False in setters. */
1531
  false,  /* isMovable.  Not relevant for setters. */
1532
  false, /* isEliminatable.  Not relevant for setters. */
1533
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1534
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1535
  false,  /* isTypedMethod.  Only relevant for methods. */
1536
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1537
};
1538
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1539
static_assert(0 < 2, "There is no slot for us");
1540
1541
MOZ_CAN_RUN_SCRIPT static bool
1542
get_breadth(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridLine* self, JSJitGetterCallArgs args)
1543
0
{
1544
0
  AUTO_PROFILER_LABEL_FAST("get GridLine.breadth", DOM, cx);
1545
0
1546
0
  double result(self->Breadth());
1547
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1548
0
  args.rval().set(JS_NumberValue(double(result)));
1549
0
  return true;
1550
0
}
1551
1552
static const JSJitInfo breadth_getterinfo = {
1553
  { (JSJitGetterOp)get_breadth },
1554
  { prototypes::id::GridLine },
1555
  { PrototypeTraits<prototypes::id::GridLine>::Depth },
1556
  JSJitInfo::Getter,
1557
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1558
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
1559
  true,  /* isInfallible. False in setters. */
1560
  false,  /* isMovable.  Not relevant for setters. */
1561
  false, /* isEliminatable.  Not relevant for setters. */
1562
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1563
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1564
  false,  /* isTypedMethod.  Only relevant for methods. */
1565
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1566
};
1567
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1568
static_assert(0 < 2, "There is no slot for us");
1569
1570
MOZ_CAN_RUN_SCRIPT static bool
1571
get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridLine* self, JSJitGetterCallArgs args)
1572
0
{
1573
0
  AUTO_PROFILER_LABEL_FAST("get GridLine.type", DOM, cx);
1574
0
1575
0
  GridDeclaration result(self->Type());
1576
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1577
0
  if (!ToJSValue(cx, result, args.rval())) {
1578
0
    return false;
1579
0
  }
1580
0
  return true;
1581
0
}
1582
1583
static const JSJitInfo type_getterinfo = {
1584
  { (JSJitGetterOp)get_type },
1585
  { prototypes::id::GridLine },
1586
  { PrototypeTraits<prototypes::id::GridLine>::Depth },
1587
  JSJitInfo::Getter,
1588
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1589
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
1590
  false,  /* isInfallible. False in setters. */
1591
  false,  /* isMovable.  Not relevant for setters. */
1592
  false, /* isEliminatable.  Not relevant for setters. */
1593
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1594
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1595
  false,  /* isTypedMethod.  Only relevant for methods. */
1596
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1597
};
1598
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1599
static_assert(0 < 2, "There is no slot for us");
1600
1601
MOZ_CAN_RUN_SCRIPT static bool
1602
get_number(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridLine* self, JSJitGetterCallArgs args)
1603
0
{
1604
0
  AUTO_PROFILER_LABEL_FAST("get GridLine.number", DOM, cx);
1605
0
1606
0
  uint32_t result(self->Number());
1607
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1608
0
  args.rval().setNumber(result);
1609
0
  return true;
1610
0
}
1611
1612
static const JSJitInfo number_getterinfo = {
1613
  { (JSJitGetterOp)get_number },
1614
  { prototypes::id::GridLine },
1615
  { PrototypeTraits<prototypes::id::GridLine>::Depth },
1616
  JSJitInfo::Getter,
1617
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1618
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
1619
  true,  /* isInfallible. False in setters. */
1620
  false,  /* isMovable.  Not relevant for setters. */
1621
  false, /* isEliminatable.  Not relevant for setters. */
1622
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1623
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1624
  false,  /* isTypedMethod.  Only relevant for methods. */
1625
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1626
};
1627
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1628
static_assert(0 < 2, "There is no slot for us");
1629
1630
MOZ_CAN_RUN_SCRIPT static bool
1631
get_negativeNumber(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridLine* self, JSJitGetterCallArgs args)
1632
0
{
1633
0
  AUTO_PROFILER_LABEL_FAST("get GridLine.negativeNumber", DOM, cx);
1634
0
1635
0
  int32_t result(self->NegativeNumber());
1636
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1637
0
  args.rval().setInt32(int32_t(result));
1638
0
  return true;
1639
0
}
1640
1641
static const JSJitInfo negativeNumber_getterinfo = {
1642
  { (JSJitGetterOp)get_negativeNumber },
1643
  { prototypes::id::GridLine },
1644
  { PrototypeTraits<prototypes::id::GridLine>::Depth },
1645
  JSJitInfo::Getter,
1646
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1647
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
1648
  true,  /* isInfallible. False in setters. */
1649
  false,  /* isMovable.  Not relevant for setters. */
1650
  false, /* isEliminatable.  Not relevant for setters. */
1651
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1652
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1653
  false,  /* isTypedMethod.  Only relevant for methods. */
1654
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1655
};
1656
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1657
static_assert(0 < 2, "There is no slot for us");
1658
1659
static bool
1660
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1661
0
{
1662
0
  mozilla::dom::GridLine* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridLine>(obj);
1663
0
  // We don't want to preserve if we don't have a wrapper, and we
1664
0
  // obviously can't preserve if we're not initialized.
1665
0
  if (self && self->GetWrapperPreserveColor()) {
1666
0
    PreserveWrapper(self);
1667
0
  }
1668
0
  return true;
1669
0
}
1670
1671
static void
1672
_finalize(js::FreeOp* fop, JSObject* obj)
1673
0
{
1674
0
  mozilla::dom::GridLine* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridLine>(obj);
1675
0
  if (self) {
1676
0
    ClearWrapper(self, self, obj);
1677
0
    AddForDeferredFinalization<mozilla::dom::GridLine>(self);
1678
0
  }
1679
0
}
1680
1681
static size_t
1682
_objectMoved(JSObject* obj, JSObject* old)
1683
0
{
1684
0
  mozilla::dom::GridLine* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridLine>(obj);
1685
0
  if (self) {
1686
0
    UpdateWrapper(self, self, obj, old);
1687
0
  }
1688
0
1689
0
  return 0;
1690
0
}
1691
1692
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1693
#if defined(__clang__)
1694
#pragma clang diagnostic push
1695
#pragma clang diagnostic ignored "-Wmissing-braces"
1696
#endif
1697
static const JSPropertySpec sAttributes_specs[] = {
1698
  { "names", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &names_getterinfo, nullptr, nullptr },
1699
  { "start", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &start_getterinfo, nullptr, nullptr },
1700
  { "breadth", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &breadth_getterinfo, nullptr, nullptr },
1701
  { "type", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &type_getterinfo, nullptr, nullptr },
1702
  { "number", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &number_getterinfo, nullptr, nullptr },
1703
  { "negativeNumber", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &negativeNumber_getterinfo, nullptr, nullptr },
1704
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1705
};
1706
#if defined(__clang__)
1707
#pragma clang diagnostic pop
1708
#endif
1709
1710
1711
static const Prefable<const JSPropertySpec> sAttributes[] = {
1712
  { nullptr, &sAttributes_specs[0] },
1713
  { nullptr, nullptr }
1714
};
1715
1716
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1717
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1718
static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1719
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1720
1721
1722
static uint16_t sNativeProperties_sortedPropertyIndices[6];
1723
static PropertyInfo sNativeProperties_propertyInfos[6];
1724
1725
static const NativePropertiesN<1> sNativeProperties = {
1726
  false, 0,
1727
  false, 0,
1728
  false, 0,
1729
  true,  0 /* sAttributes */,
1730
  false, 0,
1731
  false, 0,
1732
  false, 0,
1733
  -1,
1734
  6,
1735
  sNativeProperties_sortedPropertyIndices,
1736
  {
1737
    { sAttributes, &sNativeProperties_propertyInfos[0] }
1738
  }
1739
};
1740
static_assert(6 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1741
    "We have a property info count that is oversized");
1742
1743
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1744
  {
1745
    "Function",
1746
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1747
    &sBoringInterfaceObjectClassClassOps,
1748
    JS_NULL_CLASS_SPEC,
1749
    JS_NULL_CLASS_EXT,
1750
    &sInterfaceObjectClassObjectOps
1751
  },
1752
  eInterface,
1753
  true,
1754
  prototypes::id::GridLine,
1755
  PrototypeTraits<prototypes::id::GridLine>::Depth,
1756
  sNativePropertyHooks,
1757
  "function GridLine() {\n    [native code]\n}",
1758
  JS::GetRealmFunctionPrototype
1759
};
1760
1761
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1762
  {
1763
    "GridLinePrototype",
1764
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1765
    JS_NULL_CLASS_OPS,
1766
    JS_NULL_CLASS_SPEC,
1767
    JS_NULL_CLASS_EXT,
1768
    JS_NULL_OBJECT_OPS
1769
  },
1770
  eInterfacePrototype,
1771
  false,
1772
  prototypes::id::GridLine,
1773
  PrototypeTraits<prototypes::id::GridLine>::Depth,
1774
  sNativePropertyHooks,
1775
  "[object GridLinePrototype]",
1776
  JS::GetRealmObjectPrototype
1777
};
1778
1779
bool
1780
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
1781
0
{
1782
0
  return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
1783
0
}
1784
1785
static const js::ClassOps sClassOps = {
1786
  _addProperty, /* addProperty */
1787
  nullptr,               /* delProperty */
1788
  nullptr,               /* enumerate */
1789
  nullptr, /* newEnumerate */
1790
  nullptr, /* resolve */
1791
  nullptr, /* mayResolve */
1792
  _finalize, /* finalize */
1793
  nullptr, /* call */
1794
  nullptr,               /* hasInstance */
1795
  nullptr,               /* construct */
1796
  nullptr, /* trace */
1797
};
1798
1799
static const js::ClassExtension sClassExtension = {
1800
  nullptr, /* weakmapKeyDelegateOp */
1801
  _objectMoved /* objectMovedOp */
1802
};
1803
1804
static const DOMJSClass sClass = {
1805
  { "GridLine",
1806
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(2),
1807
    &sClassOps,
1808
    JS_NULL_CLASS_SPEC,
1809
    &sClassExtension,
1810
    JS_NULL_OBJECT_OPS
1811
  },
1812
  { prototypes::id::GridLine, 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 },
1813
  IsBaseOf<nsISupports, mozilla::dom::GridLine >::value,
1814
  sNativePropertyHooks,
1815
  FindAssociatedGlobalForNative<mozilla::dom::GridLine>::Get,
1816
  GetProtoObjectHandle,
1817
  GetCCParticipant<mozilla::dom::GridLine>::Get()
1818
};
1819
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1820
              "Must have the right minimal number of reserved slots.");
1821
static_assert(2 >= 2,
1822
              "Must have enough reserved slots.");
1823
1824
const JSClass*
1825
GetJSClass()
1826
0
{
1827
0
  return sClass.ToJSClass();
1828
0
}
1829
1830
bool
1831
Wrap(JSContext* aCx, mozilla::dom::GridLine* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1832
0
{
1833
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::GridLine>::value,
1834
0
                "Shouldn't have wrappercached things that are not refcounted.");
1835
0
  MOZ_ASSERT(static_cast<mozilla::dom::GridLine*>(aObject) ==
1836
0
             reinterpret_cast<mozilla::dom::GridLine*>(aObject),
1837
0
             "Multiple inheritance for mozilla::dom::GridLine is broken.");
1838
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1839
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1840
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1841
0
             "You should probably not be using Wrap() directly; use "
1842
0
             "GetOrCreateDOMReflector instead");
1843
0
1844
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1845
0
             "nsISupports must be on our primary inheritance chain");
1846
0
1847
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1848
0
  if (!global) {
1849
0
    return false;
1850
0
  }
1851
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1852
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1853
0
1854
0
  // That might have ended up wrapping us already, due to the wonders
1855
0
  // of XBL.  Check for that, and bail out as needed.
1856
0
  aReflector.set(aCache->GetWrapper());
1857
0
  if (aReflector) {
1858
#ifdef DEBUG
1859
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1860
#endif // DEBUG
1861
    return true;
1862
0
  }
1863
0
1864
0
  JSAutoRealm ar(aCx, global);
1865
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1866
0
  if (!canonicalProto) {
1867
0
    return false;
1868
0
  }
1869
0
  JS::Rooted<JSObject*> proto(aCx);
1870
0
  if (aGivenProto) {
1871
0
    proto = aGivenProto;
1872
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1873
0
    // coming in, we changed compartments to that of "parent" so may need
1874
0
    // to wrap the proto here.
1875
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1876
0
      if (!JS_WrapObject(aCx, &proto)) {
1877
0
        return false;
1878
0
      }
1879
0
    }
1880
0
  } else {
1881
0
    proto = canonicalProto;
1882
0
  }
1883
0
1884
0
  BindingJSObjectCreator<mozilla::dom::GridLine> creator(aCx);
1885
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1886
0
  if (!aReflector) {
1887
0
    return false;
1888
0
  }
1889
0
1890
0
  aCache->SetWrapper(aReflector);
1891
0
  creator.InitializationSucceeded();
1892
0
1893
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1894
0
             aCache->GetWrapperPreserveColor() == aReflector);
1895
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1896
0
  // otherwise we won't be able to properly recreate it later, since
1897
0
  // we won't know what proto to use.  Note that we don't check
1898
0
  // aGivenProto here, since it's entirely possible (and even
1899
0
  // somewhat common) to have a non-null aGivenProto which is the
1900
0
  // same as canonicalProto.
1901
0
  if (proto != canonicalProto) {
1902
0
    PreserveWrapper(aObject);
1903
0
  }
1904
0
1905
0
  return true;
1906
0
}
1907
1908
// This may allocate too many slots, because we only really need
1909
// slots for our non-interface-typed members that we cache.  But
1910
// allocating slots only for those would make the slot index
1911
// computations much more complicated, so let's do this the simple
1912
// way for now.
1913
DEFINE_XRAY_EXPANDO_CLASS(static, sXrayExpandoObjectClass, 1);
1914
1915
const NativePropertyHooks sNativePropertyHooks[] = { {
1916
  nullptr,
1917
  nullptr,
1918
  nullptr,
1919
  { sNativeProperties.Upcast(), nullptr },
1920
  prototypes::id::GridLine,
1921
  constructors::id::GridLine,
1922
  nullptr,
1923
  &sXrayExpandoObjectClass
1924
} };
1925
1926
void
1927
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1928
0
{
1929
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
1930
0
  if (!parentProto) {
1931
0
    return;
1932
0
  }
1933
0
1934
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
1935
0
  if (!constructorProto) {
1936
0
    return;
1937
0
  }
1938
0
1939
0
  static bool sIdsInited = false;
1940
0
  if (!sIdsInited && NS_IsMainThread()) {
1941
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1942
0
      return;
1943
0
    }
1944
0
    sIdsInited = true;
1945
0
  }
1946
0
1947
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::GridLine);
1948
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::GridLine);
1949
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1950
0
                              &sPrototypeClass.mBase, protoCache,
1951
0
                              nullptr,
1952
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1953
0
                              interfaceCache,
1954
0
                              sNativeProperties.Upcast(),
1955
0
                              nullptr,
1956
0
                              "GridLine", aDefineOnGlobal,
1957
0
                              nullptr,
1958
0
                              false);
1959
0
}
1960
1961
JSObject*
1962
GetConstructorObject(JSContext* aCx)
1963
0
{
1964
0
  return GetConstructorObjectHandle(aCx);
1965
0
}
1966
1967
} // namespace GridLine_Binding
1968
1969
1970
1971
namespace GridLines_Binding {
1972
1973
MOZ_CAN_RUN_SCRIPT static bool
1974
get_length(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridLines* self, JSJitGetterCallArgs args)
1975
0
{
1976
0
  AUTO_PROFILER_LABEL_FAST("get GridLines.length", DOM, cx);
1977
0
1978
0
  uint32_t result(self->Length());
1979
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1980
0
  args.rval().setNumber(result);
1981
0
  return true;
1982
0
}
1983
1984
static const JSJitInfo length_getterinfo = {
1985
  { (JSJitGetterOp)get_length },
1986
  { prototypes::id::GridLines },
1987
  { PrototypeTraits<prototypes::id::GridLines>::Depth },
1988
  JSJitInfo::Getter,
1989
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1990
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
1991
  true,  /* isInfallible. False in setters. */
1992
  false,  /* isMovable.  Not relevant for setters. */
1993
  false, /* isEliminatable.  Not relevant for setters. */
1994
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1995
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1996
  false,  /* isTypedMethod.  Only relevant for methods. */
1997
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1998
};
1999
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2000
static_assert(0 < 1, "There is no slot for us");
2001
2002
MOZ_CAN_RUN_SCRIPT static bool
2003
item(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridLines* self, const JSJitMethodCallArgs& args)
2004
0
{
2005
0
  AUTO_PROFILER_LABEL_FAST("GridLines.item", DOM, cx);
2006
0
2007
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
2008
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "GridLines.item");
2009
0
  }
2010
0
  uint32_t arg0;
2011
0
  if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
2012
0
    return false;
2013
0
  }
2014
0
  auto result(StrongOrRawPtr<mozilla::dom::GridLine>(self->Item(arg0)));
2015
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2016
0
  if (!result) {
2017
0
    args.rval().setNull();
2018
0
    return true;
2019
0
  }
2020
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
2021
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
2022
0
    return false;
2023
0
  }
2024
0
  return true;
2025
0
}
2026
2027
static const JSJitInfo item_methodinfo = {
2028
  { (JSJitGetterOp)item },
2029
  { prototypes::id::GridLines },
2030
  { PrototypeTraits<prototypes::id::GridLines>::Depth },
2031
  JSJitInfo::Method,
2032
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2033
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
2034
  false,  /* isInfallible. False in setters. */
2035
  false,  /* isMovable.  Not relevant for setters. */
2036
  false, /* isEliminatable.  Not relevant for setters. */
2037
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2038
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2039
  false,  /* isTypedMethod.  Only relevant for methods. */
2040
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2041
};
2042
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2043
static_assert(0 < 1, "There is no slot for us");
2044
2045
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
2046
#if defined(__clang__)
2047
#pragma clang diagnostic push
2048
#pragma clang diagnostic ignored "-Wmissing-braces"
2049
#endif
2050
static const JSFunctionSpec sMethods_specs[] = {
2051
  JS_FNSPEC("item", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&item_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
2052
  JS_SYM_FNSPEC(iterator, nullptr, nullptr, 0, 0, "ArrayValues"),
2053
  JS_FS_END
2054
};
2055
#if defined(__clang__)
2056
#pragma clang diagnostic pop
2057
#endif
2058
2059
2060
static const Prefable<const JSFunctionSpec> sMethods[] = {
2061
  { nullptr, &sMethods_specs[0] },
2062
  { nullptr, nullptr }
2063
};
2064
2065
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
2066
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
2067
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
2068
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
2069
2070
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
2071
#if defined(__clang__)
2072
#pragma clang diagnostic push
2073
#pragma clang diagnostic ignored "-Wmissing-braces"
2074
#endif
2075
static const JSPropertySpec sAttributes_specs[] = {
2076
  { "length", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &length_getterinfo, nullptr, nullptr },
2077
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
2078
};
2079
#if defined(__clang__)
2080
#pragma clang diagnostic pop
2081
#endif
2082
2083
2084
static const Prefable<const JSPropertySpec> sAttributes[] = {
2085
  { nullptr, &sAttributes_specs[0] },
2086
  { nullptr, nullptr }
2087
};
2088
2089
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
2090
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
2091
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
2092
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
2093
2094
2095
static uint16_t sNativeProperties_sortedPropertyIndices[3];
2096
static PropertyInfo sNativeProperties_propertyInfos[3];
2097
2098
static const NativePropertiesN<2> sNativeProperties = {
2099
  false, 0,
2100
  false, 0,
2101
  true,  0 /* sMethods */,
2102
  true,  1 /* sAttributes */,
2103
  false, 0,
2104
  false, 0,
2105
  false, 0,
2106
  -1,
2107
  3,
2108
  sNativeProperties_sortedPropertyIndices,
2109
  {
2110
    { sMethods, &sNativeProperties_propertyInfos[0] },
2111
    { sAttributes, &sNativeProperties_propertyInfos[2] }
2112
  }
2113
};
2114
static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
2115
    "We have a property info count that is oversized");
2116
2117
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
2118
  {
2119
    "Function",
2120
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
2121
    &sBoringInterfaceObjectClassClassOps,
2122
    JS_NULL_CLASS_SPEC,
2123
    JS_NULL_CLASS_EXT,
2124
    &sInterfaceObjectClassObjectOps
2125
  },
2126
  eInterface,
2127
  true,
2128
  prototypes::id::GridLines,
2129
  PrototypeTraits<prototypes::id::GridLines>::Depth,
2130
  sNativePropertyHooks,
2131
  "function GridLines() {\n    [native code]\n}",
2132
  JS::GetRealmFunctionPrototype
2133
};
2134
2135
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
2136
  {
2137
    "GridLinesPrototype",
2138
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
2139
    JS_NULL_CLASS_OPS,
2140
    JS_NULL_CLASS_SPEC,
2141
    JS_NULL_CLASS_EXT,
2142
    JS_NULL_OBJECT_OPS
2143
  },
2144
  eInterfacePrototype,
2145
  false,
2146
  prototypes::id::GridLines,
2147
  PrototypeTraits<prototypes::id::GridLines>::Depth,
2148
  sNativePropertyHooks,
2149
  "[object GridLinesPrototype]",
2150
  JS::GetRealmObjectPrototype
2151
};
2152
2153
bool
2154
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
2155
0
{
2156
0
  return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
2157
0
}
2158
2159
static_assert(IsBaseOf<nsISupports, mozilla::dom::GridLines >::value,
2160
                  "We don't support non-nsISupports native classes for "
2161
                  "proxy-based bindings yet");
2162
2163
2164
class DOMProxyHandler : public mozilla::dom::DOMProxyHandler
2165
{
2166
public:
2167
  explicit constexpr DOMProxyHandler()
2168
0
  {
2169
0
  }
2170
2171
  virtual bool
2172
  getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const override;
2173
2174
  virtual bool
2175
  defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const override;
2176
2177
  using mozilla::dom::DOMProxyHandler::defineProperty;
2178
2179
  virtual bool
2180
  ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const override;
2181
2182
  virtual bool
2183
  hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const override;
2184
2185
  virtual bool
2186
  get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const override;
2187
2188
  virtual const char*
2189
  className(JSContext* cx, JS::Handle<JSObject*> proxy) const override;
2190
2191
  virtual bool
2192
  finalizeInBackground(const JS::Value& priv) const override;
2193
2194
  virtual void
2195
  finalize(JSFreeOp* fop, JSObject* proxy) const override;
2196
2197
  static const DOMProxyHandler*
2198
  getInstance();
2199
2200
  virtual bool
2201
  delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const override;
2202
2203
  virtual bool
2204
  getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const override;
2205
2206
  virtual size_t
2207
  objectMoved(JSObject* obj, JSObject* old) const override;
2208
};
2209
2210
MOZ_ALWAYS_INLINE bool
2211
IsProxy(JSObject* obj)
2212
0
{
2213
0
  return js::IsProxy(obj) && js::GetProxyHandler(obj) == DOMProxyHandler::getInstance();
2214
0
}
2215
2216
MOZ_ALWAYS_INLINE mozilla::dom::GridLines*
2217
UnwrapProxy(JSObject* obj)
2218
0
{
2219
0
  MOZ_ASSERT(js::IsProxy(obj));
2220
0
  if (js::GetProxyHandler(obj) != DOMProxyHandler::getInstance()) {
2221
0
    MOZ_ASSERT(xpc::WrapperFactory::IsXrayWrapper(obj));
2222
0
    obj = js::UncheckedUnwrap(obj);
2223
0
  }
2224
0
  MOZ_ASSERT(IsProxy(obj));
2225
0
  return static_cast<mozilla::dom::GridLines*>(js::GetProxyReservedSlot(obj, DOM_OBJECT_SLOT).toPrivate());
2226
0
}
2227
2228
bool
2229
DOMProxyHandler::getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const
2230
0
{
2231
0
  bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
2232
0
  uint32_t index = GetArrayIndexFromId(cx, id);
2233
0
  if (IsArrayIndex(index)) {
2234
0
    mozilla::dom::GridLines* self = UnwrapProxy(proxy);
2235
0
    bool found = false;
2236
0
    auto result(StrongOrRawPtr<mozilla::dom::GridLine>(self->IndexedGetter(index, found)));
2237
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
2238
0
2239
0
    if (found) {
2240
0
      if (!result) {
2241
0
        desc.value().setNull();
2242
0
        FillPropertyDescriptor(desc, proxy, true);
2243
0
        return true;
2244
0
      }
2245
0
      if (!GetOrCreateDOMReflector(cx, result, desc.value())) {
2246
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
2247
0
        return false;
2248
0
      }
2249
0
      FillPropertyDescriptor(desc, proxy, true);
2250
0
      return true;
2251
0
    }
2252
0
  }
2253
0
2254
0
  JS::Rooted<JSObject*> expando(cx);
2255
0
  if (!isXray && (expando = GetExpandoObject(proxy))) {
2256
0
    if (!JS_GetOwnPropertyDescriptorById(cx, expando, id, desc)) {
2257
0
      return false;
2258
0
    }
2259
0
    if (desc.object()) {
2260
0
      // Pretend the property lives on the wrapper.
2261
0
      desc.object().set(proxy);
2262
0
      return true;
2263
0
    }
2264
0
  }
2265
0
2266
0
  desc.object().set(nullptr);
2267
0
  return true;
2268
0
}
2269
2270
bool
2271
DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const
2272
0
{
2273
0
  if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
2274
0
    *defined = true;
2275
0
    return opresult.failNoIndexedSetter();
2276
0
  }
2277
0
  return mozilla::dom::DOMProxyHandler::defineProperty(cx, proxy, id, desc, opresult, defined);
2278
0
}
2279
2280
2281
bool
2282
DOMProxyHandler::ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const
2283
0
{
2284
0
  bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
2285
0
2286
0
  uint32_t length = UnwrapProxy(proxy)->Length();
2287
0
  MOZ_ASSERT(int32_t(length) >= 0);
2288
0
  for (int32_t i = 0; i < int32_t(length); ++i) {
2289
0
    if (!props.append(INT_TO_JSID(i))) {
2290
0
      return false;
2291
0
    }
2292
0
  }
2293
0
2294
0
  JS::Rooted<JSObject*> expando(cx);
2295
0
  if (!isXray && (expando = DOMProxyHandler::GetExpandoObject(proxy)) &&
2296
0
      !js::GetPropertyKeys(cx, expando, flags, &props)) {
2297
0
    return false;
2298
0
  }
2299
0
2300
0
  return true;
2301
0
}
2302
2303
bool
2304
DOMProxyHandler::hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const
2305
0
{
2306
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
2307
0
            "Should not have a XrayWrapper here");
2308
0
2309
0
  uint32_t index = GetArrayIndexFromId(cx, id);
2310
0
  if (IsArrayIndex(index)) {
2311
0
    bool found = false;
2312
0
    mozilla::dom::GridLines* self = UnwrapProxy(proxy);
2313
0
    auto result(StrongOrRawPtr<mozilla::dom::GridLine>(self->IndexedGetter(index, found)));
2314
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
2315
0
    (void)result;
2316
0
2317
0
    *bp = found;
2318
0
    return true;
2319
0
  }
2320
0
2321
0
2322
0
  JS::Rooted<JSObject*> expando(cx, GetExpandoObject(proxy));
2323
0
  if (expando) {
2324
0
    bool b = true;
2325
0
    bool ok = JS_HasPropertyById(cx, expando, id, &b);
2326
0
    *bp = !!b;
2327
0
    if (!ok || *bp) {
2328
0
      return ok;
2329
0
    }
2330
0
  }
2331
0
2332
0
  *bp = false;
2333
0
  return true;
2334
0
}
2335
2336
bool
2337
DOMProxyHandler::get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const
2338
0
{
2339
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
2340
0
              "Should not have a XrayWrapper here");
2341
0
2342
0
  uint32_t index = GetArrayIndexFromId(cx, id);
2343
0
  if (IsArrayIndex(index)) {
2344
0
    mozilla::dom::GridLines* self = UnwrapProxy(proxy);
2345
0
    bool found = false;
2346
0
    auto result(StrongOrRawPtr<mozilla::dom::GridLine>(self->IndexedGetter(index, found)));
2347
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
2348
0
2349
0
    if (found) {
2350
0
      if (!result) {
2351
0
        vp.setNull();
2352
0
        return true;
2353
0
      }
2354
0
      if (!GetOrCreateDOMReflector(cx, result, vp)) {
2355
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
2356
0
        return false;
2357
0
      }
2358
0
      return true;
2359
0
    }
2360
0
    // Even if we don't have this index, we don't forward the
2361
0
    // get on to our expando object.
2362
0
  } else {
2363
0
    { // Scope for expando
2364
0
      JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
2365
0
      if (expando) {
2366
0
        bool hasProp;
2367
0
        if (!JS_HasPropertyById(cx, expando, id, &hasProp)) {
2368
0
          return false;
2369
0
        }
2370
0
2371
0
        if (hasProp) {
2372
0
          // Forward the get to the expando object, but our receiver is whatever our
2373
0
          // receiver is.
2374
0
          return JS_ForwardGetPropertyTo(cx, expando, id, receiver, vp);
2375
0
        }
2376
0
      }
2377
0
    }
2378
0
  }
2379
0
2380
0
  bool foundOnPrototype;
2381
0
  if (!GetPropertyOnPrototype(cx, proxy, receiver, id, &foundOnPrototype, vp)) {
2382
0
    return false;
2383
0
  }
2384
0
2385
0
  if (foundOnPrototype) {
2386
0
    return true;
2387
0
  }
2388
0
2389
0
  vp.setUndefined();
2390
0
  return true;
2391
0
}
2392
2393
const char*
2394
DOMProxyHandler::className(JSContext* cx, JS::Handle<JSObject*> proxy) const
2395
0
{
2396
0
  return "GridLines";
2397
0
}
2398
2399
bool
2400
DOMProxyHandler::finalizeInBackground(const JS::Value& priv) const
2401
0
{
2402
0
  return false;
2403
0
}
2404
2405
void
2406
DOMProxyHandler::finalize(JSFreeOp* fop, JSObject* proxy) const
2407
0
{
2408
0
  mozilla::dom::GridLines* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridLines>(proxy);
2409
0
  if (self) {
2410
0
    ClearWrapper(self, self, proxy);
2411
0
    AddForDeferredFinalization<mozilla::dom::GridLines>(self);
2412
0
  }
2413
0
}
2414
2415
const DOMProxyHandler*
2416
DOMProxyHandler::getInstance()
2417
0
{
2418
0
  static const DOMProxyHandler instance;
2419
0
  return &instance;
2420
0
}
2421
2422
bool
2423
DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const
2424
0
{
2425
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
2426
0
            "Should not have a XrayWrapper here");
2427
0
2428
0
  uint32_t index = GetArrayIndexFromId(cx, id);
2429
0
  if (IsArrayIndex(index)) {
2430
0
    bool deleteSucceeded;
2431
0
    bool found = false;
2432
0
    mozilla::dom::GridLines* self = UnwrapProxy(proxy);
2433
0
    auto result(StrongOrRawPtr<mozilla::dom::GridLine>(self->IndexedGetter(index, found)));
2434
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
2435
0
    (void)result;
2436
0
    deleteSucceeded = !found;
2437
0
    return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete();
2438
0
  }
2439
0
2440
0
  return dom::DOMProxyHandler::delete_(cx, proxy, id, opresult);
2441
0
}
2442
2443
bool
2444
DOMProxyHandler::getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const
2445
0
{
2446
0
  JS::Rooted<JS::Value> temp(cx);
2447
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
2448
0
             "Should not have a XrayWrapper here");
2449
0
2450
0
  mozilla::dom::GridLines* self = UnwrapProxy(proxy);
2451
0
  uint32_t length = self->Length();
2452
0
  // Compute the end of the indices we'll get ourselves
2453
0
  uint32_t ourEnd = std::max(begin, std::min(end, length));
2454
0
2455
0
  for (uint32_t index = begin; index < ourEnd; ++index) {
2456
0
    bool found = false;
2457
0
    auto result(StrongOrRawPtr<mozilla::dom::GridLine>(self->IndexedGetter(index, found)));
2458
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
2459
0
2460
0
    MOZ_ASSERT(found);
2461
0
    if (!result) {
2462
0
      temp.setNull();
2463
0
      if (!adder->append(cx, temp)) return false;
2464
0
      continue;
2465
0
    }
2466
0
    if (!GetOrCreateDOMReflector(cx, result, &temp)) {
2467
0
      MOZ_ASSERT(JS_IsExceptionPending(cx));
2468
0
      return false;
2469
0
    }
2470
0
    if (!adder->append(cx, temp)) return false;
2471
0
    continue;
2472
0
  }
2473
0
2474
0
  if (end > ourEnd) {
2475
0
    JS::Rooted<JSObject*> proto(cx);
2476
0
    if (!js::GetObjectProto(cx, proxy, &proto)) {
2477
0
      return false;
2478
0
    }
2479
0
    return js::GetElementsWithAdder(cx, proto, proxy, ourEnd, end, adder);
2480
0
  }
2481
0
2482
0
  return true;
2483
0
}
2484
2485
size_t
2486
DOMProxyHandler::objectMoved(JSObject* obj, JSObject* old) const
2487
0
{
2488
0
  mozilla::dom::GridLines* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridLines>(obj);
2489
0
  if (self) {
2490
0
    UpdateWrapper(self, self, obj, old);
2491
0
  }
2492
0
2493
0
  return 0;
2494
0
}
2495
2496
static const DOMJSClass sClass = {
2497
  PROXY_CLASS_DEF("GridLines",
2498
                  JSCLASS_IS_DOMJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(1)),
2499
  { prototypes::id::GridLines, 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 },
2500
  IsBaseOf<nsISupports, mozilla::dom::GridLines >::value,
2501
  sNativePropertyHooks,
2502
  FindAssociatedGlobalForNative<mozilla::dom::GridLines>::Get,
2503
  GetProtoObjectHandle,
2504
  GetCCParticipant<mozilla::dom::GridLines>::Get()
2505
};
2506
2507
bool
2508
Wrap(JSContext* aCx, mozilla::dom::GridLines* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
2509
0
{
2510
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::GridLines>::value,
2511
0
                "Shouldn't have wrappercached things that are not refcounted.");
2512
0
  MOZ_ASSERT(static_cast<mozilla::dom::GridLines*>(aObject) ==
2513
0
             reinterpret_cast<mozilla::dom::GridLines*>(aObject),
2514
0
             "Multiple inheritance for mozilla::dom::GridLines is broken.");
2515
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
2516
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
2517
0
  MOZ_ASSERT(!aCache->GetWrapper(),
2518
0
             "You should probably not be using Wrap() directly; use "
2519
0
             "GetOrCreateDOMReflector instead");
2520
0
2521
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
2522
0
             "nsISupports must be on our primary inheritance chain");
2523
0
2524
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
2525
0
  if (!global) {
2526
0
    return false;
2527
0
  }
2528
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
2529
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
2530
0
2531
0
  // That might have ended up wrapping us already, due to the wonders
2532
0
  // of XBL.  Check for that, and bail out as needed.
2533
0
  aReflector.set(aCache->GetWrapper());
2534
0
  if (aReflector) {
2535
#ifdef DEBUG
2536
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
2537
#endif // DEBUG
2538
    return true;
2539
0
  }
2540
0
2541
0
  JSAutoRealm ar(aCx, global);
2542
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
2543
0
  if (!canonicalProto) {
2544
0
    return false;
2545
0
  }
2546
0
  JS::Rooted<JSObject*> proto(aCx);
2547
0
  if (aGivenProto) {
2548
0
    proto = aGivenProto;
2549
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
2550
0
    // coming in, we changed compartments to that of "parent" so may need
2551
0
    // to wrap the proto here.
2552
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
2553
0
      if (!JS_WrapObject(aCx, &proto)) {
2554
0
        return false;
2555
0
      }
2556
0
    }
2557
0
  } else {
2558
0
    proto = canonicalProto;
2559
0
  }
2560
0
2561
0
  BindingJSObjectCreator<mozilla::dom::GridLines> creator(aCx);
2562
0
  creator.CreateProxyObject(aCx, &sClass.mBase, DOMProxyHandler::getInstance(),
2563
0
                            proto, aObject, JS::UndefinedHandleValue, aReflector);
2564
0
  if (!aReflector) {
2565
0
    return false;
2566
0
  }
2567
0
2568
0
  aCache->SetWrapper(aReflector);
2569
0
  creator.InitializationSucceeded();
2570
0
2571
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
2572
0
             aCache->GetWrapperPreserveColor() == aReflector);
2573
0
  // If proto != canonicalProto, we have to preserve our wrapper;
2574
0
  // otherwise we won't be able to properly recreate it later, since
2575
0
  // we won't know what proto to use.  Note that we don't check
2576
0
  // aGivenProto here, since it's entirely possible (and even
2577
0
  // somewhat common) to have a non-null aGivenProto which is the
2578
0
  // same as canonicalProto.
2579
0
  if (proto != canonicalProto) {
2580
0
    PreserveWrapper(aObject);
2581
0
  }
2582
0
2583
0
  return true;
2584
0
}
2585
2586
static bool
2587
ResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::MutableHandle<JS::PropertyDescriptor> desc)
2588
0
{
2589
0
  return js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, desc);
2590
0
}
2591
2592
static bool
2593
EnumerateOwnProperties(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::AutoIdVector& props)
2594
0
{
2595
0
  return js::GetProxyHandler(obj)->ownPropertyKeys(cx, wrapper, props);
2596
0
}
2597
2598
const NativePropertyHooks sNativePropertyHooks[] = { {
2599
  ResolveOwnProperty,
2600
  EnumerateOwnProperties,
2601
  nullptr,
2602
  { sNativeProperties.Upcast(), nullptr },
2603
  prototypes::id::GridLines,
2604
  constructors::id::GridLines,
2605
  nullptr,
2606
  &DefaultXrayExpandoObjectClass
2607
} };
2608
2609
void
2610
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
2611
0
{
2612
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
2613
0
  if (!parentProto) {
2614
0
    return;
2615
0
  }
2616
0
2617
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
2618
0
  if (!constructorProto) {
2619
0
    return;
2620
0
  }
2621
0
2622
0
  static bool sIdsInited = false;
2623
0
  if (!sIdsInited && NS_IsMainThread()) {
2624
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
2625
0
      return;
2626
0
    }
2627
0
    sIdsInited = true;
2628
0
  }
2629
0
2630
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::GridLines);
2631
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::GridLines);
2632
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
2633
0
                              &sPrototypeClass.mBase, protoCache,
2634
0
                              nullptr,
2635
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
2636
0
                              interfaceCache,
2637
0
                              sNativeProperties.Upcast(),
2638
0
                              nullptr,
2639
0
                              "GridLines", aDefineOnGlobal,
2640
0
                              nullptr,
2641
0
                              false);
2642
0
}
2643
2644
JSObject*
2645
GetConstructorObject(JSContext* aCx)
2646
0
{
2647
0
  return GetConstructorObjectHandle(aCx);
2648
0
}
2649
2650
} // namespace GridLines_Binding
2651
2652
2653
2654
namespace GridTrack_Binding {
2655
2656
MOZ_CAN_RUN_SCRIPT static bool
2657
get_start(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridTrack* self, JSJitGetterCallArgs args)
2658
0
{
2659
0
  AUTO_PROFILER_LABEL_FAST("get GridTrack.start", DOM, cx);
2660
0
2661
0
  double result(self->Start());
2662
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2663
0
  args.rval().set(JS_NumberValue(double(result)));
2664
0
  return true;
2665
0
}
2666
2667
static const JSJitInfo start_getterinfo = {
2668
  { (JSJitGetterOp)get_start },
2669
  { prototypes::id::GridTrack },
2670
  { PrototypeTraits<prototypes::id::GridTrack>::Depth },
2671
  JSJitInfo::Getter,
2672
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2673
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
2674
  true,  /* isInfallible. False in setters. */
2675
  false,  /* isMovable.  Not relevant for setters. */
2676
  false, /* isEliminatable.  Not relevant for setters. */
2677
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2678
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2679
  false,  /* isTypedMethod.  Only relevant for methods. */
2680
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2681
};
2682
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2683
static_assert(0 < 1, "There is no slot for us");
2684
2685
MOZ_CAN_RUN_SCRIPT static bool
2686
get_breadth(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridTrack* self, JSJitGetterCallArgs args)
2687
0
{
2688
0
  AUTO_PROFILER_LABEL_FAST("get GridTrack.breadth", DOM, cx);
2689
0
2690
0
  double result(self->Breadth());
2691
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2692
0
  args.rval().set(JS_NumberValue(double(result)));
2693
0
  return true;
2694
0
}
2695
2696
static const JSJitInfo breadth_getterinfo = {
2697
  { (JSJitGetterOp)get_breadth },
2698
  { prototypes::id::GridTrack },
2699
  { PrototypeTraits<prototypes::id::GridTrack>::Depth },
2700
  JSJitInfo::Getter,
2701
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2702
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
2703
  true,  /* isInfallible. False in setters. */
2704
  false,  /* isMovable.  Not relevant for setters. */
2705
  false, /* isEliminatable.  Not relevant for setters. */
2706
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2707
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2708
  false,  /* isTypedMethod.  Only relevant for methods. */
2709
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2710
};
2711
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2712
static_assert(0 < 1, "There is no slot for us");
2713
2714
MOZ_CAN_RUN_SCRIPT static bool
2715
get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridTrack* self, JSJitGetterCallArgs args)
2716
0
{
2717
0
  AUTO_PROFILER_LABEL_FAST("get GridTrack.type", DOM, cx);
2718
0
2719
0
  GridDeclaration result(self->Type());
2720
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2721
0
  if (!ToJSValue(cx, result, args.rval())) {
2722
0
    return false;
2723
0
  }
2724
0
  return true;
2725
0
}
2726
2727
static const JSJitInfo type_getterinfo = {
2728
  { (JSJitGetterOp)get_type },
2729
  { prototypes::id::GridTrack },
2730
  { PrototypeTraits<prototypes::id::GridTrack>::Depth },
2731
  JSJitInfo::Getter,
2732
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2733
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2734
  false,  /* isInfallible. False in setters. */
2735
  false,  /* isMovable.  Not relevant for setters. */
2736
  false, /* isEliminatable.  Not relevant for setters. */
2737
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2738
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2739
  false,  /* isTypedMethod.  Only relevant for methods. */
2740
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2741
};
2742
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2743
static_assert(0 < 1, "There is no slot for us");
2744
2745
MOZ_CAN_RUN_SCRIPT static bool
2746
get_state(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridTrack* self, JSJitGetterCallArgs args)
2747
0
{
2748
0
  AUTO_PROFILER_LABEL_FAST("get GridTrack.state", DOM, cx);
2749
0
2750
0
  GridTrackState result(self->State());
2751
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2752
0
  if (!ToJSValue(cx, result, args.rval())) {
2753
0
    return false;
2754
0
  }
2755
0
  return true;
2756
0
}
2757
2758
static const JSJitInfo state_getterinfo = {
2759
  { (JSJitGetterOp)get_state },
2760
  { prototypes::id::GridTrack },
2761
  { PrototypeTraits<prototypes::id::GridTrack>::Depth },
2762
  JSJitInfo::Getter,
2763
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2764
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2765
  false,  /* isInfallible. False in setters. */
2766
  false,  /* isMovable.  Not relevant for setters. */
2767
  false, /* isEliminatable.  Not relevant for setters. */
2768
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2769
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2770
  false,  /* isTypedMethod.  Only relevant for methods. */
2771
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2772
};
2773
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2774
static_assert(0 < 1, "There is no slot for us");
2775
2776
static bool
2777
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
2778
0
{
2779
0
  mozilla::dom::GridTrack* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridTrack>(obj);
2780
0
  // We don't want to preserve if we don't have a wrapper, and we
2781
0
  // obviously can't preserve if we're not initialized.
2782
0
  if (self && self->GetWrapperPreserveColor()) {
2783
0
    PreserveWrapper(self);
2784
0
  }
2785
0
  return true;
2786
0
}
2787
2788
static void
2789
_finalize(js::FreeOp* fop, JSObject* obj)
2790
0
{
2791
0
  mozilla::dom::GridTrack* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridTrack>(obj);
2792
0
  if (self) {
2793
0
    ClearWrapper(self, self, obj);
2794
0
    AddForDeferredFinalization<mozilla::dom::GridTrack>(self);
2795
0
  }
2796
0
}
2797
2798
static size_t
2799
_objectMoved(JSObject* obj, JSObject* old)
2800
0
{
2801
0
  mozilla::dom::GridTrack* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridTrack>(obj);
2802
0
  if (self) {
2803
0
    UpdateWrapper(self, self, obj, old);
2804
0
  }
2805
0
2806
0
  return 0;
2807
0
}
2808
2809
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
2810
#if defined(__clang__)
2811
#pragma clang diagnostic push
2812
#pragma clang diagnostic ignored "-Wmissing-braces"
2813
#endif
2814
static const JSPropertySpec sAttributes_specs[] = {
2815
  { "start", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &start_getterinfo, nullptr, nullptr },
2816
  { "breadth", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &breadth_getterinfo, nullptr, nullptr },
2817
  { "type", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &type_getterinfo, nullptr, nullptr },
2818
  { "state", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &state_getterinfo, nullptr, nullptr },
2819
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
2820
};
2821
#if defined(__clang__)
2822
#pragma clang diagnostic pop
2823
#endif
2824
2825
2826
static const Prefable<const JSPropertySpec> sAttributes[] = {
2827
  { nullptr, &sAttributes_specs[0] },
2828
  { nullptr, nullptr }
2829
};
2830
2831
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
2832
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
2833
static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
2834
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
2835
2836
2837
static uint16_t sNativeProperties_sortedPropertyIndices[4];
2838
static PropertyInfo sNativeProperties_propertyInfos[4];
2839
2840
static const NativePropertiesN<1> sNativeProperties = {
2841
  false, 0,
2842
  false, 0,
2843
  false, 0,
2844
  true,  0 /* sAttributes */,
2845
  false, 0,
2846
  false, 0,
2847
  false, 0,
2848
  -1,
2849
  4,
2850
  sNativeProperties_sortedPropertyIndices,
2851
  {
2852
    { sAttributes, &sNativeProperties_propertyInfos[0] }
2853
  }
2854
};
2855
static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
2856
    "We have a property info count that is oversized");
2857
2858
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
2859
  {
2860
    "Function",
2861
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
2862
    &sBoringInterfaceObjectClassClassOps,
2863
    JS_NULL_CLASS_SPEC,
2864
    JS_NULL_CLASS_EXT,
2865
    &sInterfaceObjectClassObjectOps
2866
  },
2867
  eInterface,
2868
  true,
2869
  prototypes::id::GridTrack,
2870
  PrototypeTraits<prototypes::id::GridTrack>::Depth,
2871
  sNativePropertyHooks,
2872
  "function GridTrack() {\n    [native code]\n}",
2873
  JS::GetRealmFunctionPrototype
2874
};
2875
2876
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
2877
  {
2878
    "GridTrackPrototype",
2879
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
2880
    JS_NULL_CLASS_OPS,
2881
    JS_NULL_CLASS_SPEC,
2882
    JS_NULL_CLASS_EXT,
2883
    JS_NULL_OBJECT_OPS
2884
  },
2885
  eInterfacePrototype,
2886
  false,
2887
  prototypes::id::GridTrack,
2888
  PrototypeTraits<prototypes::id::GridTrack>::Depth,
2889
  sNativePropertyHooks,
2890
  "[object GridTrackPrototype]",
2891
  JS::GetRealmObjectPrototype
2892
};
2893
2894
bool
2895
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
2896
0
{
2897
0
  return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
2898
0
}
2899
2900
static const js::ClassOps sClassOps = {
2901
  _addProperty, /* addProperty */
2902
  nullptr,               /* delProperty */
2903
  nullptr,               /* enumerate */
2904
  nullptr, /* newEnumerate */
2905
  nullptr, /* resolve */
2906
  nullptr, /* mayResolve */
2907
  _finalize, /* finalize */
2908
  nullptr, /* call */
2909
  nullptr,               /* hasInstance */
2910
  nullptr,               /* construct */
2911
  nullptr, /* trace */
2912
};
2913
2914
static const js::ClassExtension sClassExtension = {
2915
  nullptr, /* weakmapKeyDelegateOp */
2916
  _objectMoved /* objectMovedOp */
2917
};
2918
2919
static const DOMJSClass sClass = {
2920
  { "GridTrack",
2921
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
2922
    &sClassOps,
2923
    JS_NULL_CLASS_SPEC,
2924
    &sClassExtension,
2925
    JS_NULL_OBJECT_OPS
2926
  },
2927
  { prototypes::id::GridTrack, 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 },
2928
  IsBaseOf<nsISupports, mozilla::dom::GridTrack >::value,
2929
  sNativePropertyHooks,
2930
  FindAssociatedGlobalForNative<mozilla::dom::GridTrack>::Get,
2931
  GetProtoObjectHandle,
2932
  GetCCParticipant<mozilla::dom::GridTrack>::Get()
2933
};
2934
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
2935
              "Must have the right minimal number of reserved slots.");
2936
static_assert(1 >= 1,
2937
              "Must have enough reserved slots.");
2938
2939
const JSClass*
2940
GetJSClass()
2941
0
{
2942
0
  return sClass.ToJSClass();
2943
0
}
2944
2945
bool
2946
Wrap(JSContext* aCx, mozilla::dom::GridTrack* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
2947
0
{
2948
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::GridTrack>::value,
2949
0
                "Shouldn't have wrappercached things that are not refcounted.");
2950
0
  MOZ_ASSERT(static_cast<mozilla::dom::GridTrack*>(aObject) ==
2951
0
             reinterpret_cast<mozilla::dom::GridTrack*>(aObject),
2952
0
             "Multiple inheritance for mozilla::dom::GridTrack is broken.");
2953
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
2954
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
2955
0
  MOZ_ASSERT(!aCache->GetWrapper(),
2956
0
             "You should probably not be using Wrap() directly; use "
2957
0
             "GetOrCreateDOMReflector instead");
2958
0
2959
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
2960
0
             "nsISupports must be on our primary inheritance chain");
2961
0
2962
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
2963
0
  if (!global) {
2964
0
    return false;
2965
0
  }
2966
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
2967
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
2968
0
2969
0
  // That might have ended up wrapping us already, due to the wonders
2970
0
  // of XBL.  Check for that, and bail out as needed.
2971
0
  aReflector.set(aCache->GetWrapper());
2972
0
  if (aReflector) {
2973
#ifdef DEBUG
2974
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
2975
#endif // DEBUG
2976
    return true;
2977
0
  }
2978
0
2979
0
  JSAutoRealm ar(aCx, global);
2980
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
2981
0
  if (!canonicalProto) {
2982
0
    return false;
2983
0
  }
2984
0
  JS::Rooted<JSObject*> proto(aCx);
2985
0
  if (aGivenProto) {
2986
0
    proto = aGivenProto;
2987
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
2988
0
    // coming in, we changed compartments to that of "parent" so may need
2989
0
    // to wrap the proto here.
2990
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
2991
0
      if (!JS_WrapObject(aCx, &proto)) {
2992
0
        return false;
2993
0
      }
2994
0
    }
2995
0
  } else {
2996
0
    proto = canonicalProto;
2997
0
  }
2998
0
2999
0
  BindingJSObjectCreator<mozilla::dom::GridTrack> creator(aCx);
3000
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
3001
0
  if (!aReflector) {
3002
0
    return false;
3003
0
  }
3004
0
3005
0
  aCache->SetWrapper(aReflector);
3006
0
  creator.InitializationSucceeded();
3007
0
3008
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
3009
0
             aCache->GetWrapperPreserveColor() == aReflector);
3010
0
  // If proto != canonicalProto, we have to preserve our wrapper;
3011
0
  // otherwise we won't be able to properly recreate it later, since
3012
0
  // we won't know what proto to use.  Note that we don't check
3013
0
  // aGivenProto here, since it's entirely possible (and even
3014
0
  // somewhat common) to have a non-null aGivenProto which is the
3015
0
  // same as canonicalProto.
3016
0
  if (proto != canonicalProto) {
3017
0
    PreserveWrapper(aObject);
3018
0
  }
3019
0
3020
0
  return true;
3021
0
}
3022
3023
const NativePropertyHooks sNativePropertyHooks[] = { {
3024
  nullptr,
3025
  nullptr,
3026
  nullptr,
3027
  { sNativeProperties.Upcast(), nullptr },
3028
  prototypes::id::GridTrack,
3029
  constructors::id::GridTrack,
3030
  nullptr,
3031
  &DefaultXrayExpandoObjectClass
3032
} };
3033
3034
void
3035
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
3036
0
{
3037
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
3038
0
  if (!parentProto) {
3039
0
    return;
3040
0
  }
3041
0
3042
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
3043
0
  if (!constructorProto) {
3044
0
    return;
3045
0
  }
3046
0
3047
0
  static bool sIdsInited = false;
3048
0
  if (!sIdsInited && NS_IsMainThread()) {
3049
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
3050
0
      return;
3051
0
    }
3052
0
    sIdsInited = true;
3053
0
  }
3054
0
3055
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::GridTrack);
3056
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::GridTrack);
3057
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
3058
0
                              &sPrototypeClass.mBase, protoCache,
3059
0
                              nullptr,
3060
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
3061
0
                              interfaceCache,
3062
0
                              sNativeProperties.Upcast(),
3063
0
                              nullptr,
3064
0
                              "GridTrack", aDefineOnGlobal,
3065
0
                              nullptr,
3066
0
                              false);
3067
0
}
3068
3069
JSObject*
3070
GetConstructorObject(JSContext* aCx)
3071
0
{
3072
0
  return GetConstructorObjectHandle(aCx);
3073
0
}
3074
3075
} // namespace GridTrack_Binding
3076
3077
3078
3079
namespace GridTracks_Binding {
3080
3081
MOZ_CAN_RUN_SCRIPT static bool
3082
get_length(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridTracks* self, JSJitGetterCallArgs args)
3083
0
{
3084
0
  AUTO_PROFILER_LABEL_FAST("get GridTracks.length", DOM, cx);
3085
0
3086
0
  uint32_t result(self->Length());
3087
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3088
0
  args.rval().setNumber(result);
3089
0
  return true;
3090
0
}
3091
3092
static const JSJitInfo length_getterinfo = {
3093
  { (JSJitGetterOp)get_length },
3094
  { prototypes::id::GridTracks },
3095
  { PrototypeTraits<prototypes::id::GridTracks>::Depth },
3096
  JSJitInfo::Getter,
3097
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3098
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
3099
  true,  /* isInfallible. False in setters. */
3100
  false,  /* isMovable.  Not relevant for setters. */
3101
  false, /* isEliminatable.  Not relevant for setters. */
3102
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3103
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3104
  false,  /* isTypedMethod.  Only relevant for methods. */
3105
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3106
};
3107
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3108
static_assert(0 < 1, "There is no slot for us");
3109
3110
MOZ_CAN_RUN_SCRIPT static bool
3111
item(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridTracks* self, const JSJitMethodCallArgs& args)
3112
0
{
3113
0
  AUTO_PROFILER_LABEL_FAST("GridTracks.item", DOM, cx);
3114
0
3115
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
3116
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "GridTracks.item");
3117
0
  }
3118
0
  uint32_t arg0;
3119
0
  if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
3120
0
    return false;
3121
0
  }
3122
0
  auto result(StrongOrRawPtr<mozilla::dom::GridTrack>(self->Item(arg0)));
3123
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3124
0
  if (!result) {
3125
0
    args.rval().setNull();
3126
0
    return true;
3127
0
  }
3128
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
3129
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
3130
0
    return false;
3131
0
  }
3132
0
  return true;
3133
0
}
3134
3135
static const JSJitInfo item_methodinfo = {
3136
  { (JSJitGetterOp)item },
3137
  { prototypes::id::GridTracks },
3138
  { PrototypeTraits<prototypes::id::GridTracks>::Depth },
3139
  JSJitInfo::Method,
3140
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3141
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
3142
  false,  /* isInfallible. False in setters. */
3143
  false,  /* isMovable.  Not relevant for setters. */
3144
  false, /* isEliminatable.  Not relevant for setters. */
3145
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3146
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3147
  false,  /* isTypedMethod.  Only relevant for methods. */
3148
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3149
};
3150
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3151
static_assert(0 < 1, "There is no slot for us");
3152
3153
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
3154
#if defined(__clang__)
3155
#pragma clang diagnostic push
3156
#pragma clang diagnostic ignored "-Wmissing-braces"
3157
#endif
3158
static const JSFunctionSpec sMethods_specs[] = {
3159
  JS_FNSPEC("item", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&item_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
3160
  JS_SYM_FNSPEC(iterator, nullptr, nullptr, 0, 0, "ArrayValues"),
3161
  JS_FS_END
3162
};
3163
#if defined(__clang__)
3164
#pragma clang diagnostic pop
3165
#endif
3166
3167
3168
static const Prefable<const JSFunctionSpec> sMethods[] = {
3169
  { nullptr, &sMethods_specs[0] },
3170
  { nullptr, nullptr }
3171
};
3172
3173
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
3174
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
3175
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
3176
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
3177
3178
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
3179
#if defined(__clang__)
3180
#pragma clang diagnostic push
3181
#pragma clang diagnostic ignored "-Wmissing-braces"
3182
#endif
3183
static const JSPropertySpec sAttributes_specs[] = {
3184
  { "length", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &length_getterinfo, nullptr, nullptr },
3185
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
3186
};
3187
#if defined(__clang__)
3188
#pragma clang diagnostic pop
3189
#endif
3190
3191
3192
static const Prefable<const JSPropertySpec> sAttributes[] = {
3193
  { nullptr, &sAttributes_specs[0] },
3194
  { nullptr, nullptr }
3195
};
3196
3197
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
3198
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
3199
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
3200
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
3201
3202
3203
static uint16_t sNativeProperties_sortedPropertyIndices[3];
3204
static PropertyInfo sNativeProperties_propertyInfos[3];
3205
3206
static const NativePropertiesN<2> sNativeProperties = {
3207
  false, 0,
3208
  false, 0,
3209
  true,  0 /* sMethods */,
3210
  true,  1 /* sAttributes */,
3211
  false, 0,
3212
  false, 0,
3213
  false, 0,
3214
  -1,
3215
  3,
3216
  sNativeProperties_sortedPropertyIndices,
3217
  {
3218
    { sMethods, &sNativeProperties_propertyInfos[0] },
3219
    { sAttributes, &sNativeProperties_propertyInfos[2] }
3220
  }
3221
};
3222
static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
3223
    "We have a property info count that is oversized");
3224
3225
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
3226
  {
3227
    "Function",
3228
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
3229
    &sBoringInterfaceObjectClassClassOps,
3230
    JS_NULL_CLASS_SPEC,
3231
    JS_NULL_CLASS_EXT,
3232
    &sInterfaceObjectClassObjectOps
3233
  },
3234
  eInterface,
3235
  true,
3236
  prototypes::id::GridTracks,
3237
  PrototypeTraits<prototypes::id::GridTracks>::Depth,
3238
  sNativePropertyHooks,
3239
  "function GridTracks() {\n    [native code]\n}",
3240
  JS::GetRealmFunctionPrototype
3241
};
3242
3243
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
3244
  {
3245
    "GridTracksPrototype",
3246
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
3247
    JS_NULL_CLASS_OPS,
3248
    JS_NULL_CLASS_SPEC,
3249
    JS_NULL_CLASS_EXT,
3250
    JS_NULL_OBJECT_OPS
3251
  },
3252
  eInterfacePrototype,
3253
  false,
3254
  prototypes::id::GridTracks,
3255
  PrototypeTraits<prototypes::id::GridTracks>::Depth,
3256
  sNativePropertyHooks,
3257
  "[object GridTracksPrototype]",
3258
  JS::GetRealmObjectPrototype
3259
};
3260
3261
bool
3262
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
3263
0
{
3264
0
  return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
3265
0
}
3266
3267
static_assert(IsBaseOf<nsISupports, mozilla::dom::GridTracks >::value,
3268
                  "We don't support non-nsISupports native classes for "
3269
                  "proxy-based bindings yet");
3270
3271
3272
class DOMProxyHandler : public mozilla::dom::DOMProxyHandler
3273
{
3274
public:
3275
  explicit constexpr DOMProxyHandler()
3276
0
  {
3277
0
  }
3278
3279
  virtual bool
3280
  getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const override;
3281
3282
  virtual bool
3283
  defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const override;
3284
3285
  using mozilla::dom::DOMProxyHandler::defineProperty;
3286
3287
  virtual bool
3288
  ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const override;
3289
3290
  virtual bool
3291
  hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const override;
3292
3293
  virtual bool
3294
  get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const override;
3295
3296
  virtual const char*
3297
  className(JSContext* cx, JS::Handle<JSObject*> proxy) const override;
3298
3299
  virtual bool
3300
  finalizeInBackground(const JS::Value& priv) const override;
3301
3302
  virtual void
3303
  finalize(JSFreeOp* fop, JSObject* proxy) const override;
3304
3305
  static const DOMProxyHandler*
3306
  getInstance();
3307
3308
  virtual bool
3309
  delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const override;
3310
3311
  virtual bool
3312
  getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const override;
3313
3314
  virtual size_t
3315
  objectMoved(JSObject* obj, JSObject* old) const override;
3316
};
3317
3318
MOZ_ALWAYS_INLINE bool
3319
IsProxy(JSObject* obj)
3320
0
{
3321
0
  return js::IsProxy(obj) && js::GetProxyHandler(obj) == DOMProxyHandler::getInstance();
3322
0
}
3323
3324
MOZ_ALWAYS_INLINE mozilla::dom::GridTracks*
3325
UnwrapProxy(JSObject* obj)
3326
0
{
3327
0
  MOZ_ASSERT(js::IsProxy(obj));
3328
0
  if (js::GetProxyHandler(obj) != DOMProxyHandler::getInstance()) {
3329
0
    MOZ_ASSERT(xpc::WrapperFactory::IsXrayWrapper(obj));
3330
0
    obj = js::UncheckedUnwrap(obj);
3331
0
  }
3332
0
  MOZ_ASSERT(IsProxy(obj));
3333
0
  return static_cast<mozilla::dom::GridTracks*>(js::GetProxyReservedSlot(obj, DOM_OBJECT_SLOT).toPrivate());
3334
0
}
3335
3336
bool
3337
DOMProxyHandler::getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const
3338
0
{
3339
0
  bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
3340
0
  uint32_t index = GetArrayIndexFromId(cx, id);
3341
0
  if (IsArrayIndex(index)) {
3342
0
    mozilla::dom::GridTracks* self = UnwrapProxy(proxy);
3343
0
    bool found = false;
3344
0
    auto result(StrongOrRawPtr<mozilla::dom::GridTrack>(self->IndexedGetter(index, found)));
3345
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
3346
0
3347
0
    if (found) {
3348
0
      if (!result) {
3349
0
        desc.value().setNull();
3350
0
        FillPropertyDescriptor(desc, proxy, true);
3351
0
        return true;
3352
0
      }
3353
0
      if (!GetOrCreateDOMReflector(cx, result, desc.value())) {
3354
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
3355
0
        return false;
3356
0
      }
3357
0
      FillPropertyDescriptor(desc, proxy, true);
3358
0
      return true;
3359
0
    }
3360
0
  }
3361
0
3362
0
  JS::Rooted<JSObject*> expando(cx);
3363
0
  if (!isXray && (expando = GetExpandoObject(proxy))) {
3364
0
    if (!JS_GetOwnPropertyDescriptorById(cx, expando, id, desc)) {
3365
0
      return false;
3366
0
    }
3367
0
    if (desc.object()) {
3368
0
      // Pretend the property lives on the wrapper.
3369
0
      desc.object().set(proxy);
3370
0
      return true;
3371
0
    }
3372
0
  }
3373
0
3374
0
  desc.object().set(nullptr);
3375
0
  return true;
3376
0
}
3377
3378
bool
3379
DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const
3380
0
{
3381
0
  if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
3382
0
    *defined = true;
3383
0
    return opresult.failNoIndexedSetter();
3384
0
  }
3385
0
  return mozilla::dom::DOMProxyHandler::defineProperty(cx, proxy, id, desc, opresult, defined);
3386
0
}
3387
3388
3389
bool
3390
DOMProxyHandler::ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const
3391
0
{
3392
0
  bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
3393
0
3394
0
  uint32_t length = UnwrapProxy(proxy)->Length();
3395
0
  MOZ_ASSERT(int32_t(length) >= 0);
3396
0
  for (int32_t i = 0; i < int32_t(length); ++i) {
3397
0
    if (!props.append(INT_TO_JSID(i))) {
3398
0
      return false;
3399
0
    }
3400
0
  }
3401
0
3402
0
  JS::Rooted<JSObject*> expando(cx);
3403
0
  if (!isXray && (expando = DOMProxyHandler::GetExpandoObject(proxy)) &&
3404
0
      !js::GetPropertyKeys(cx, expando, flags, &props)) {
3405
0
    return false;
3406
0
  }
3407
0
3408
0
  return true;
3409
0
}
3410
3411
bool
3412
DOMProxyHandler::hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const
3413
0
{
3414
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
3415
0
            "Should not have a XrayWrapper here");
3416
0
3417
0
  uint32_t index = GetArrayIndexFromId(cx, id);
3418
0
  if (IsArrayIndex(index)) {
3419
0
    bool found = false;
3420
0
    mozilla::dom::GridTracks* self = UnwrapProxy(proxy);
3421
0
    auto result(StrongOrRawPtr<mozilla::dom::GridTrack>(self->IndexedGetter(index, found)));
3422
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
3423
0
    (void)result;
3424
0
3425
0
    *bp = found;
3426
0
    return true;
3427
0
  }
3428
0
3429
0
3430
0
  JS::Rooted<JSObject*> expando(cx, GetExpandoObject(proxy));
3431
0
  if (expando) {
3432
0
    bool b = true;
3433
0
    bool ok = JS_HasPropertyById(cx, expando, id, &b);
3434
0
    *bp = !!b;
3435
0
    if (!ok || *bp) {
3436
0
      return ok;
3437
0
    }
3438
0
  }
3439
0
3440
0
  *bp = false;
3441
0
  return true;
3442
0
}
3443
3444
bool
3445
DOMProxyHandler::get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const
3446
0
{
3447
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
3448
0
              "Should not have a XrayWrapper here");
3449
0
3450
0
  uint32_t index = GetArrayIndexFromId(cx, id);
3451
0
  if (IsArrayIndex(index)) {
3452
0
    mozilla::dom::GridTracks* self = UnwrapProxy(proxy);
3453
0
    bool found = false;
3454
0
    auto result(StrongOrRawPtr<mozilla::dom::GridTrack>(self->IndexedGetter(index, found)));
3455
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
3456
0
3457
0
    if (found) {
3458
0
      if (!result) {
3459
0
        vp.setNull();
3460
0
        return true;
3461
0
      }
3462
0
      if (!GetOrCreateDOMReflector(cx, result, vp)) {
3463
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
3464
0
        return false;
3465
0
      }
3466
0
      return true;
3467
0
    }
3468
0
    // Even if we don't have this index, we don't forward the
3469
0
    // get on to our expando object.
3470
0
  } else {
3471
0
    { // Scope for expando
3472
0
      JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
3473
0
      if (expando) {
3474
0
        bool hasProp;
3475
0
        if (!JS_HasPropertyById(cx, expando, id, &hasProp)) {
3476
0
          return false;
3477
0
        }
3478
0
3479
0
        if (hasProp) {
3480
0
          // Forward the get to the expando object, but our receiver is whatever our
3481
0
          // receiver is.
3482
0
          return JS_ForwardGetPropertyTo(cx, expando, id, receiver, vp);
3483
0
        }
3484
0
      }
3485
0
    }
3486
0
  }
3487
0
3488
0
  bool foundOnPrototype;
3489
0
  if (!GetPropertyOnPrototype(cx, proxy, receiver, id, &foundOnPrototype, vp)) {
3490
0
    return false;
3491
0
  }
3492
0
3493
0
  if (foundOnPrototype) {
3494
0
    return true;
3495
0
  }
3496
0
3497
0
  vp.setUndefined();
3498
0
  return true;
3499
0
}
3500
3501
const char*
3502
DOMProxyHandler::className(JSContext* cx, JS::Handle<JSObject*> proxy) const
3503
0
{
3504
0
  return "GridTracks";
3505
0
}
3506
3507
bool
3508
DOMProxyHandler::finalizeInBackground(const JS::Value& priv) const
3509
0
{
3510
0
  return false;
3511
0
}
3512
3513
void
3514
DOMProxyHandler::finalize(JSFreeOp* fop, JSObject* proxy) const
3515
0
{
3516
0
  mozilla::dom::GridTracks* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridTracks>(proxy);
3517
0
  if (self) {
3518
0
    ClearWrapper(self, self, proxy);
3519
0
    AddForDeferredFinalization<mozilla::dom::GridTracks>(self);
3520
0
  }
3521
0
}
3522
3523
const DOMProxyHandler*
3524
DOMProxyHandler::getInstance()
3525
0
{
3526
0
  static const DOMProxyHandler instance;
3527
0
  return &instance;
3528
0
}
3529
3530
bool
3531
DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const
3532
0
{
3533
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
3534
0
            "Should not have a XrayWrapper here");
3535
0
3536
0
  uint32_t index = GetArrayIndexFromId(cx, id);
3537
0
  if (IsArrayIndex(index)) {
3538
0
    bool deleteSucceeded;
3539
0
    bool found = false;
3540
0
    mozilla::dom::GridTracks* self = UnwrapProxy(proxy);
3541
0
    auto result(StrongOrRawPtr<mozilla::dom::GridTrack>(self->IndexedGetter(index, found)));
3542
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
3543
0
    (void)result;
3544
0
    deleteSucceeded = !found;
3545
0
    return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete();
3546
0
  }
3547
0
3548
0
  return dom::DOMProxyHandler::delete_(cx, proxy, id, opresult);
3549
0
}
3550
3551
bool
3552
DOMProxyHandler::getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const
3553
0
{
3554
0
  JS::Rooted<JS::Value> temp(cx);
3555
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
3556
0
             "Should not have a XrayWrapper here");
3557
0
3558
0
  mozilla::dom::GridTracks* self = UnwrapProxy(proxy);
3559
0
  uint32_t length = self->Length();
3560
0
  // Compute the end of the indices we'll get ourselves
3561
0
  uint32_t ourEnd = std::max(begin, std::min(end, length));
3562
0
3563
0
  for (uint32_t index = begin; index < ourEnd; ++index) {
3564
0
    bool found = false;
3565
0
    auto result(StrongOrRawPtr<mozilla::dom::GridTrack>(self->IndexedGetter(index, found)));
3566
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
3567
0
3568
0
    MOZ_ASSERT(found);
3569
0
    if (!result) {
3570
0
      temp.setNull();
3571
0
      if (!adder->append(cx, temp)) return false;
3572
0
      continue;
3573
0
    }
3574
0
    if (!GetOrCreateDOMReflector(cx, result, &temp)) {
3575
0
      MOZ_ASSERT(JS_IsExceptionPending(cx));
3576
0
      return false;
3577
0
    }
3578
0
    if (!adder->append(cx, temp)) return false;
3579
0
    continue;
3580
0
  }
3581
0
3582
0
  if (end > ourEnd) {
3583
0
    JS::Rooted<JSObject*> proto(cx);
3584
0
    if (!js::GetObjectProto(cx, proxy, &proto)) {
3585
0
      return false;
3586
0
    }
3587
0
    return js::GetElementsWithAdder(cx, proto, proxy, ourEnd, end, adder);
3588
0
  }
3589
0
3590
0
  return true;
3591
0
}
3592
3593
size_t
3594
DOMProxyHandler::objectMoved(JSObject* obj, JSObject* old) const
3595
0
{
3596
0
  mozilla::dom::GridTracks* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridTracks>(obj);
3597
0
  if (self) {
3598
0
    UpdateWrapper(self, self, obj, old);
3599
0
  }
3600
0
3601
0
  return 0;
3602
0
}
3603
3604
static const DOMJSClass sClass = {
3605
  PROXY_CLASS_DEF("GridTracks",
3606
                  JSCLASS_IS_DOMJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(1)),
3607
  { prototypes::id::GridTracks, 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 },
3608
  IsBaseOf<nsISupports, mozilla::dom::GridTracks >::value,
3609
  sNativePropertyHooks,
3610
  FindAssociatedGlobalForNative<mozilla::dom::GridTracks>::Get,
3611
  GetProtoObjectHandle,
3612
  GetCCParticipant<mozilla::dom::GridTracks>::Get()
3613
};
3614
3615
bool
3616
Wrap(JSContext* aCx, mozilla::dom::GridTracks* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
3617
0
{
3618
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::GridTracks>::value,
3619
0
                "Shouldn't have wrappercached things that are not refcounted.");
3620
0
  MOZ_ASSERT(static_cast<mozilla::dom::GridTracks*>(aObject) ==
3621
0
             reinterpret_cast<mozilla::dom::GridTracks*>(aObject),
3622
0
             "Multiple inheritance for mozilla::dom::GridTracks is broken.");
3623
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
3624
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
3625
0
  MOZ_ASSERT(!aCache->GetWrapper(),
3626
0
             "You should probably not be using Wrap() directly; use "
3627
0
             "GetOrCreateDOMReflector instead");
3628
0
3629
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
3630
0
             "nsISupports must be on our primary inheritance chain");
3631
0
3632
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
3633
0
  if (!global) {
3634
0
    return false;
3635
0
  }
3636
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
3637
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
3638
0
3639
0
  // That might have ended up wrapping us already, due to the wonders
3640
0
  // of XBL.  Check for that, and bail out as needed.
3641
0
  aReflector.set(aCache->GetWrapper());
3642
0
  if (aReflector) {
3643
#ifdef DEBUG
3644
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
3645
#endif // DEBUG
3646
    return true;
3647
0
  }
3648
0
3649
0
  JSAutoRealm ar(aCx, global);
3650
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
3651
0
  if (!canonicalProto) {
3652
0
    return false;
3653
0
  }
3654
0
  JS::Rooted<JSObject*> proto(aCx);
3655
0
  if (aGivenProto) {
3656
0
    proto = aGivenProto;
3657
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
3658
0
    // coming in, we changed compartments to that of "parent" so may need
3659
0
    // to wrap the proto here.
3660
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
3661
0
      if (!JS_WrapObject(aCx, &proto)) {
3662
0
        return false;
3663
0
      }
3664
0
    }
3665
0
  } else {
3666
0
    proto = canonicalProto;
3667
0
  }
3668
0
3669
0
  BindingJSObjectCreator<mozilla::dom::GridTracks> creator(aCx);
3670
0
  creator.CreateProxyObject(aCx, &sClass.mBase, DOMProxyHandler::getInstance(),
3671
0
                            proto, aObject, JS::UndefinedHandleValue, aReflector);
3672
0
  if (!aReflector) {
3673
0
    return false;
3674
0
  }
3675
0
3676
0
  aCache->SetWrapper(aReflector);
3677
0
  creator.InitializationSucceeded();
3678
0
3679
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
3680
0
             aCache->GetWrapperPreserveColor() == aReflector);
3681
0
  // If proto != canonicalProto, we have to preserve our wrapper;
3682
0
  // otherwise we won't be able to properly recreate it later, since
3683
0
  // we won't know what proto to use.  Note that we don't check
3684
0
  // aGivenProto here, since it's entirely possible (and even
3685
0
  // somewhat common) to have a non-null aGivenProto which is the
3686
0
  // same as canonicalProto.
3687
0
  if (proto != canonicalProto) {
3688
0
    PreserveWrapper(aObject);
3689
0
  }
3690
0
3691
0
  return true;
3692
0
}
3693
3694
static bool
3695
ResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::MutableHandle<JS::PropertyDescriptor> desc)
3696
0
{
3697
0
  return js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, desc);
3698
0
}
3699
3700
static bool
3701
EnumerateOwnProperties(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::AutoIdVector& props)
3702
0
{
3703
0
  return js::GetProxyHandler(obj)->ownPropertyKeys(cx, wrapper, props);
3704
0
}
3705
3706
const NativePropertyHooks sNativePropertyHooks[] = { {
3707
  ResolveOwnProperty,
3708
  EnumerateOwnProperties,
3709
  nullptr,
3710
  { sNativeProperties.Upcast(), nullptr },
3711
  prototypes::id::GridTracks,
3712
  constructors::id::GridTracks,
3713
  nullptr,
3714
  &DefaultXrayExpandoObjectClass
3715
} };
3716
3717
void
3718
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
3719
0
{
3720
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
3721
0
  if (!parentProto) {
3722
0
    return;
3723
0
  }
3724
0
3725
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
3726
0
  if (!constructorProto) {
3727
0
    return;
3728
0
  }
3729
0
3730
0
  static bool sIdsInited = false;
3731
0
  if (!sIdsInited && NS_IsMainThread()) {
3732
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
3733
0
      return;
3734
0
    }
3735
0
    sIdsInited = true;
3736
0
  }
3737
0
3738
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::GridTracks);
3739
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::GridTracks);
3740
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
3741
0
                              &sPrototypeClass.mBase, protoCache,
3742
0
                              nullptr,
3743
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
3744
0
                              interfaceCache,
3745
0
                              sNativeProperties.Upcast(),
3746
0
                              nullptr,
3747
0
                              "GridTracks", aDefineOnGlobal,
3748
0
                              nullptr,
3749
0
                              false);
3750
0
}
3751
3752
JSObject*
3753
GetConstructorObject(JSContext* aCx)
3754
0
{
3755
0
  return GetConstructorObjectHandle(aCx);
3756
0
}
3757
3758
} // namespace GridTracks_Binding
3759
3760
3761
3762
} // namespace dom
3763
} // namespace mozilla