Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/FlexBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM Flex.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "FlexBinding.h"
4
#include "WrapperFactory.h"
5
#include "jsapi.h"
6
#include "mozilla/FloatingPoint.h"
7
#include "mozilla/OwningNonNull.h"
8
#include "mozilla/dom/BindingUtils.h"
9
#include "mozilla/dom/DOMJSClass.h"
10
#include "mozilla/dom/Flex.h"
11
#include "mozilla/dom/FlexItem.h"
12
#include "mozilla/dom/FlexLine.h"
13
#include "mozilla/dom/NonRefcountedDOMObject.h"
14
#include "mozilla/dom/Nullable.h"
15
#include "mozilla/dom/PrimitiveConversions.h"
16
#include "mozilla/dom/XrayExpandoClass.h"
17
#include "nsContentUtils.h"
18
#include "nsINode.h"
19
20
namespace mozilla {
21
namespace dom {
22
23
namespace binding_detail {}; // Just to make sure it's known as a namespace
24
using namespace mozilla::dom::binding_detail;
25
26
27
namespace FlexLineGrowthStateValues {
28
extern const EnumEntry strings[4] = {
29
  {"unchanged", 9},
30
  {"shrinking", 9},
31
  {"growing", 7},
32
  { nullptr, 0 }
33
};
34
} // namespace FlexLineGrowthStateValues
35
36
bool
37
ToJSValue(JSContext* aCx, FlexLineGrowthState aArgument, JS::MutableHandle<JS::Value> aValue)
38
0
{
39
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(FlexLineGrowthStateValues::strings));
40
0
  JSString* resultStr =
41
0
    JS_NewStringCopyN(aCx, FlexLineGrowthStateValues::strings[uint32_t(aArgument)].value,
42
0
                      FlexLineGrowthStateValues::strings[uint32_t(aArgument)].length);
43
0
  if (!resultStr) {
44
0
    return false;
45
0
  }
46
0
  aValue.setString(resultStr);
47
0
  return true;
48
0
}
49
50
51
namespace Flex_Binding {
52
53
MOZ_CAN_RUN_SCRIPT static bool
54
getLines(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Flex* self, const JSJitMethodCallArgs& args)
55
0
{
56
0
  AUTO_PROFILER_LABEL_FAST("Flex.getLines", DOM, cx);
57
0
58
0
  nsTArray<StrongPtrForMember<mozilla::dom::FlexLine>::Type> result;
59
0
  self->GetLines(result);
60
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
61
0
62
0
  uint32_t length = result.Length();
63
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
64
0
  if (!returnArray) {
65
0
    return false;
66
0
  }
67
0
  // Scope for 'tmp'
68
0
  {
69
0
    JS::Rooted<JS::Value> tmp(cx);
70
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
71
0
      // Control block to let us common up the JS_DefineElement calls when there
72
0
      // are different ways to succeed at wrapping the object.
73
0
      do {
74
0
        if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) {
75
0
          MOZ_ASSERT(JS_IsExceptionPending(cx));
76
0
          return false;
77
0
        }
78
0
        break;
79
0
      } while (false);
80
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
81
0
                            JSPROP_ENUMERATE)) {
82
0
        return false;
83
0
      }
84
0
    }
85
0
  }
86
0
  args.rval().setObject(*returnArray);
87
0
  return true;
88
0
}
89
90
static const JSJitInfo getLines_methodinfo = {
91
  { (JSJitGetterOp)getLines },
92
  { prototypes::id::Flex },
93
  { PrototypeTraits<prototypes::id::Flex>::Depth },
94
  JSJitInfo::Method,
95
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
96
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
97
  false,  /* isInfallible. False in setters. */
98
  false,  /* isMovable.  Not relevant for setters. */
99
  false, /* isEliminatable.  Not relevant for setters. */
100
  false, /* isAlwaysInSlot.  Only relevant for getters. */
101
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
102
  false,  /* isTypedMethod.  Only relevant for methods. */
103
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
104
};
105
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
106
static_assert(0 < 1, "There is no slot for us");
107
108
static bool
109
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
110
0
{
111
0
  mozilla::dom::Flex* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Flex>(obj);
112
0
  // We don't want to preserve if we don't have a wrapper, and we
113
0
  // obviously can't preserve if we're not initialized.
114
0
  if (self && self->GetWrapperPreserveColor()) {
115
0
    PreserveWrapper(self);
116
0
  }
117
0
  return true;
118
0
}
119
120
static void
121
_finalize(js::FreeOp* fop, JSObject* obj)
122
0
{
123
0
  mozilla::dom::Flex* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Flex>(obj);
124
0
  if (self) {
125
0
    ClearWrapper(self, self, obj);
126
0
    AddForDeferredFinalization<mozilla::dom::Flex>(self);
127
0
  }
128
0
}
129
130
static size_t
131
_objectMoved(JSObject* obj, JSObject* old)
132
0
{
133
0
  mozilla::dom::Flex* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Flex>(obj);
134
0
  if (self) {
135
0
    UpdateWrapper(self, self, obj, old);
136
0
  }
137
0
138
0
  return 0;
139
0
}
140
141
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
142
#if defined(__clang__)
143
#pragma clang diagnostic push
144
#pragma clang diagnostic ignored "-Wmissing-braces"
145
#endif
146
static const JSFunctionSpec sMethods_specs[] = {
147
  JS_FNSPEC("getLines", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getLines_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
148
  JS_FS_END
149
};
150
#if defined(__clang__)
151
#pragma clang diagnostic pop
152
#endif
153
154
155
static const Prefable<const JSFunctionSpec> sMethods[] = {
156
  { nullptr, &sMethods_specs[0] },
157
  { nullptr, nullptr }
158
};
159
160
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
161
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
162
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
163
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
164
165
166
static uint16_t sNativeProperties_sortedPropertyIndices[1];
167
static PropertyInfo sNativeProperties_propertyInfos[1];
168
169
static const NativePropertiesN<1> sNativeProperties = {
170
  false, 0,
171
  false, 0,
172
  true,  0 /* sMethods */,
173
  false, 0,
174
  false, 0,
175
  false, 0,
176
  false, 0,
177
  -1,
178
  1,
179
  sNativeProperties_sortedPropertyIndices,
180
  {
181
    { sMethods, &sNativeProperties_propertyInfos[0] }
182
  }
183
};
184
static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
185
    "We have a property info count that is oversized");
186
187
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
188
  {
189
    "Function",
190
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
191
    &sBoringInterfaceObjectClassClassOps,
192
    JS_NULL_CLASS_SPEC,
193
    JS_NULL_CLASS_EXT,
194
    &sInterfaceObjectClassObjectOps
195
  },
196
  eInterface,
197
  true,
198
  prototypes::id::Flex,
199
  PrototypeTraits<prototypes::id::Flex>::Depth,
200
  sNativePropertyHooks,
201
  "function Flex() {\n    [native code]\n}",
202
  JS::GetRealmFunctionPrototype
203
};
204
205
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
206
  {
207
    "FlexPrototype",
208
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
209
    JS_NULL_CLASS_OPS,
210
    JS_NULL_CLASS_SPEC,
211
    JS_NULL_CLASS_EXT,
212
    JS_NULL_OBJECT_OPS
213
  },
214
  eInterfacePrototype,
215
  false,
216
  prototypes::id::Flex,
217
  PrototypeTraits<prototypes::id::Flex>::Depth,
218
  sNativePropertyHooks,
219
  "[object FlexPrototype]",
220
  JS::GetRealmObjectPrototype
221
};
222
223
bool
224
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
225
0
{
226
0
  return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
227
0
}
228
229
static const js::ClassOps sClassOps = {
230
  _addProperty, /* addProperty */
231
  nullptr,               /* delProperty */
232
  nullptr,               /* enumerate */
233
  nullptr, /* newEnumerate */
234
  nullptr, /* resolve */
235
  nullptr, /* mayResolve */
236
  _finalize, /* finalize */
237
  nullptr, /* call */
238
  nullptr,               /* hasInstance */
239
  nullptr,               /* construct */
240
  nullptr, /* trace */
241
};
242
243
static const js::ClassExtension sClassExtension = {
244
  nullptr, /* weakmapKeyDelegateOp */
245
  _objectMoved /* objectMovedOp */
246
};
247
248
static const DOMJSClass sClass = {
249
  { "Flex",
250
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
251
    &sClassOps,
252
    JS_NULL_CLASS_SPEC,
253
    &sClassExtension,
254
    JS_NULL_OBJECT_OPS
255
  },
256
  { prototypes::id::Flex, 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 },
257
  IsBaseOf<nsISupports, mozilla::dom::Flex >::value,
258
  sNativePropertyHooks,
259
  FindAssociatedGlobalForNative<mozilla::dom::Flex>::Get,
260
  GetProtoObjectHandle,
261
  GetCCParticipant<mozilla::dom::Flex>::Get()
262
};
263
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
264
              "Must have the right minimal number of reserved slots.");
265
static_assert(1 >= 1,
266
              "Must have enough reserved slots.");
267
268
const JSClass*
269
GetJSClass()
270
0
{
271
0
  return sClass.ToJSClass();
272
0
}
273
274
bool
275
Wrap(JSContext* aCx, mozilla::dom::Flex* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
276
0
{
277
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::Flex>::value,
278
0
                "Shouldn't have wrappercached things that are not refcounted.");
279
0
  MOZ_ASSERT(static_cast<mozilla::dom::Flex*>(aObject) ==
280
0
             reinterpret_cast<mozilla::dom::Flex*>(aObject),
281
0
             "Multiple inheritance for mozilla::dom::Flex is broken.");
282
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
283
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
284
0
  MOZ_ASSERT(!aCache->GetWrapper(),
285
0
             "You should probably not be using Wrap() directly; use "
286
0
             "GetOrCreateDOMReflector instead");
287
0
288
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
289
0
             "nsISupports must be on our primary inheritance chain");
290
0
291
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
292
0
  if (!global) {
293
0
    return false;
294
0
  }
295
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
296
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
297
0
298
0
  // That might have ended up wrapping us already, due to the wonders
299
0
  // of XBL.  Check for that, and bail out as needed.
300
0
  aReflector.set(aCache->GetWrapper());
301
0
  if (aReflector) {
302
#ifdef DEBUG
303
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
304
#endif // DEBUG
305
    return true;
306
0
  }
307
0
308
0
  JSAutoRealm ar(aCx, global);
309
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
310
0
  if (!canonicalProto) {
311
0
    return false;
312
0
  }
313
0
  JS::Rooted<JSObject*> proto(aCx);
314
0
  if (aGivenProto) {
315
0
    proto = aGivenProto;
316
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
317
0
    // coming in, we changed compartments to that of "parent" so may need
318
0
    // to wrap the proto here.
319
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
320
0
      if (!JS_WrapObject(aCx, &proto)) {
321
0
        return false;
322
0
      }
323
0
    }
324
0
  } else {
325
0
    proto = canonicalProto;
326
0
  }
327
0
328
0
  BindingJSObjectCreator<mozilla::dom::Flex> creator(aCx);
329
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
330
0
  if (!aReflector) {
331
0
    return false;
332
0
  }
333
0
334
0
  aCache->SetWrapper(aReflector);
335
0
  creator.InitializationSucceeded();
336
0
337
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
338
0
             aCache->GetWrapperPreserveColor() == aReflector);
339
0
  // If proto != canonicalProto, we have to preserve our wrapper;
340
0
  // otherwise we won't be able to properly recreate it later, since
341
0
  // we won't know what proto to use.  Note that we don't check
342
0
  // aGivenProto here, since it's entirely possible (and even
343
0
  // somewhat common) to have a non-null aGivenProto which is the
344
0
  // same as canonicalProto.
345
0
  if (proto != canonicalProto) {
346
0
    PreserveWrapper(aObject);
347
0
  }
348
0
349
0
  return true;
350
0
}
351
352
const NativePropertyHooks sNativePropertyHooks[] = { {
353
  nullptr,
354
  nullptr,
355
  nullptr,
356
  { sNativeProperties.Upcast(), nullptr },
357
  prototypes::id::Flex,
358
  constructors::id::Flex,
359
  nullptr,
360
  &DefaultXrayExpandoObjectClass
361
} };
362
363
void
364
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
365
0
{
366
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
367
0
  if (!parentProto) {
368
0
    return;
369
0
  }
370
0
371
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
372
0
  if (!constructorProto) {
373
0
    return;
374
0
  }
375
0
376
0
  static bool sIdsInited = false;
377
0
  if (!sIdsInited && NS_IsMainThread()) {
378
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
379
0
      return;
380
0
    }
381
0
    sIdsInited = true;
382
0
  }
383
0
384
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::Flex);
385
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::Flex);
386
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
387
0
                              &sPrototypeClass.mBase, protoCache,
388
0
                              nullptr,
389
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
390
0
                              interfaceCache,
391
0
                              sNativeProperties.Upcast(),
392
0
                              nullptr,
393
0
                              "Flex", aDefineOnGlobal,
394
0
                              nullptr,
395
0
                              false);
396
0
}
397
398
JSObject*
399
GetConstructorObject(JSContext* aCx)
400
0
{
401
0
  return GetConstructorObjectHandle(aCx);
402
0
}
403
404
} // namespace Flex_Binding
405
406
407
408
namespace FlexItem_Binding {
409
410
MOZ_CAN_RUN_SCRIPT static bool
411
get_node(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FlexItem* self, JSJitGetterCallArgs args)
412
0
{
413
0
  AUTO_PROFILER_LABEL_FAST("get FlexItem.node", DOM, cx);
414
0
415
0
  auto result(StrongOrRawPtr<nsINode>(self->GetNode()));
416
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
417
0
  if (!result) {
418
0
    args.rval().setNull();
419
0
    return true;
420
0
  }
421
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
422
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
423
0
    return false;
424
0
  }
425
0
  return true;
426
0
}
427
428
static const JSJitInfo node_getterinfo = {
429
  { (JSJitGetterOp)get_node },
430
  { prototypes::id::FlexItem },
431
  { PrototypeTraits<prototypes::id::FlexItem>::Depth },
432
  JSJitInfo::Getter,
433
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
434
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
435
  false,  /* isInfallible. False in setters. */
436
  false,  /* isMovable.  Not relevant for setters. */
437
  false, /* isEliminatable.  Not relevant for setters. */
438
  false, /* isAlwaysInSlot.  Only relevant for getters. */
439
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
440
  false,  /* isTypedMethod.  Only relevant for methods. */
441
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
442
};
443
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
444
static_assert(0 < 1, "There is no slot for us");
445
446
MOZ_CAN_RUN_SCRIPT static bool
447
get_mainBaseSize(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FlexItem* self, JSJitGetterCallArgs args)
448
0
{
449
0
  AUTO_PROFILER_LABEL_FAST("get FlexItem.mainBaseSize", DOM, cx);
450
0
451
0
  double result(self->MainBaseSize());
452
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
453
0
  args.rval().set(JS_NumberValue(double(result)));
454
0
  return true;
455
0
}
456
457
static const JSJitInfo mainBaseSize_getterinfo = {
458
  { (JSJitGetterOp)get_mainBaseSize },
459
  { prototypes::id::FlexItem },
460
  { PrototypeTraits<prototypes::id::FlexItem>::Depth },
461
  JSJitInfo::Getter,
462
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
463
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
464
  true,  /* isInfallible. False in setters. */
465
  false,  /* isMovable.  Not relevant for setters. */
466
  false, /* isEliminatable.  Not relevant for setters. */
467
  false, /* isAlwaysInSlot.  Only relevant for getters. */
468
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
469
  false,  /* isTypedMethod.  Only relevant for methods. */
470
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
471
};
472
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
473
static_assert(0 < 1, "There is no slot for us");
474
475
MOZ_CAN_RUN_SCRIPT static bool
476
get_mainDeltaSize(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FlexItem* self, JSJitGetterCallArgs args)
477
0
{
478
0
  AUTO_PROFILER_LABEL_FAST("get FlexItem.mainDeltaSize", DOM, cx);
479
0
480
0
  double result(self->MainDeltaSize());
481
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
482
0
  args.rval().set(JS_NumberValue(double(result)));
483
0
  return true;
484
0
}
485
486
static const JSJitInfo mainDeltaSize_getterinfo = {
487
  { (JSJitGetterOp)get_mainDeltaSize },
488
  { prototypes::id::FlexItem },
489
  { PrototypeTraits<prototypes::id::FlexItem>::Depth },
490
  JSJitInfo::Getter,
491
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
492
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
493
  true,  /* isInfallible. False in setters. */
494
  false,  /* isMovable.  Not relevant for setters. */
495
  false, /* isEliminatable.  Not relevant for setters. */
496
  false, /* isAlwaysInSlot.  Only relevant for getters. */
497
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
498
  false,  /* isTypedMethod.  Only relevant for methods. */
499
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
500
};
501
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
502
static_assert(0 < 1, "There is no slot for us");
503
504
MOZ_CAN_RUN_SCRIPT static bool
505
get_mainMinSize(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FlexItem* self, JSJitGetterCallArgs args)
506
0
{
507
0
  AUTO_PROFILER_LABEL_FAST("get FlexItem.mainMinSize", DOM, cx);
508
0
509
0
  double result(self->MainMinSize());
510
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
511
0
  args.rval().set(JS_NumberValue(double(result)));
512
0
  return true;
513
0
}
514
515
static const JSJitInfo mainMinSize_getterinfo = {
516
  { (JSJitGetterOp)get_mainMinSize },
517
  { prototypes::id::FlexItem },
518
  { PrototypeTraits<prototypes::id::FlexItem>::Depth },
519
  JSJitInfo::Getter,
520
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
521
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
522
  true,  /* isInfallible. False in setters. */
523
  false,  /* isMovable.  Not relevant for setters. */
524
  false, /* isEliminatable.  Not relevant for setters. */
525
  false, /* isAlwaysInSlot.  Only relevant for getters. */
526
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
527
  false,  /* isTypedMethod.  Only relevant for methods. */
528
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
529
};
530
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
531
static_assert(0 < 1, "There is no slot for us");
532
533
MOZ_CAN_RUN_SCRIPT static bool
534
get_mainMaxSize(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FlexItem* self, JSJitGetterCallArgs args)
535
0
{
536
0
  AUTO_PROFILER_LABEL_FAST("get FlexItem.mainMaxSize", DOM, cx);
537
0
538
0
  double result(self->MainMaxSize());
539
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
540
0
  args.rval().set(JS_NumberValue(double(result)));
541
0
  return true;
542
0
}
543
544
static const JSJitInfo mainMaxSize_getterinfo = {
545
  { (JSJitGetterOp)get_mainMaxSize },
546
  { prototypes::id::FlexItem },
547
  { PrototypeTraits<prototypes::id::FlexItem>::Depth },
548
  JSJitInfo::Getter,
549
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
550
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
551
  true,  /* isInfallible. False in setters. */
552
  false,  /* isMovable.  Not relevant for setters. */
553
  false, /* isEliminatable.  Not relevant for setters. */
554
  false, /* isAlwaysInSlot.  Only relevant for getters. */
555
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
556
  false,  /* isTypedMethod.  Only relevant for methods. */
557
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
558
};
559
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
560
static_assert(0 < 1, "There is no slot for us");
561
562
MOZ_CAN_RUN_SCRIPT static bool
563
get_crossMinSize(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FlexItem* self, JSJitGetterCallArgs args)
564
0
{
565
0
  AUTO_PROFILER_LABEL_FAST("get FlexItem.crossMinSize", DOM, cx);
566
0
567
0
  double result(self->CrossMinSize());
568
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
569
0
  args.rval().set(JS_NumberValue(double(result)));
570
0
  return true;
571
0
}
572
573
static const JSJitInfo crossMinSize_getterinfo = {
574
  { (JSJitGetterOp)get_crossMinSize },
575
  { prototypes::id::FlexItem },
576
  { PrototypeTraits<prototypes::id::FlexItem>::Depth },
577
  JSJitInfo::Getter,
578
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
579
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
580
  true,  /* isInfallible. False in setters. */
581
  false,  /* isMovable.  Not relevant for setters. */
582
  false, /* isEliminatable.  Not relevant for setters. */
583
  false, /* isAlwaysInSlot.  Only relevant for getters. */
584
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
585
  false,  /* isTypedMethod.  Only relevant for methods. */
586
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
587
};
588
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
589
static_assert(0 < 1, "There is no slot for us");
590
591
MOZ_CAN_RUN_SCRIPT static bool
592
get_crossMaxSize(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FlexItem* self, JSJitGetterCallArgs args)
593
0
{
594
0
  AUTO_PROFILER_LABEL_FAST("get FlexItem.crossMaxSize", DOM, cx);
595
0
596
0
  double result(self->CrossMaxSize());
597
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
598
0
  args.rval().set(JS_NumberValue(double(result)));
599
0
  return true;
600
0
}
601
602
static const JSJitInfo crossMaxSize_getterinfo = {
603
  { (JSJitGetterOp)get_crossMaxSize },
604
  { prototypes::id::FlexItem },
605
  { PrototypeTraits<prototypes::id::FlexItem>::Depth },
606
  JSJitInfo::Getter,
607
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
608
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
609
  true,  /* isInfallible. False in setters. */
610
  false,  /* isMovable.  Not relevant for setters. */
611
  false, /* isEliminatable.  Not relevant for setters. */
612
  false, /* isAlwaysInSlot.  Only relevant for getters. */
613
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
614
  false,  /* isTypedMethod.  Only relevant for methods. */
615
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
616
};
617
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
618
static_assert(0 < 1, "There is no slot for us");
619
620
static bool
621
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
622
0
{
623
0
  mozilla::dom::FlexItem* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FlexItem>(obj);
624
0
  // We don't want to preserve if we don't have a wrapper, and we
625
0
  // obviously can't preserve if we're not initialized.
626
0
  if (self && self->GetWrapperPreserveColor()) {
627
0
    PreserveWrapper(self);
628
0
  }
629
0
  return true;
630
0
}
631
632
static void
633
_finalize(js::FreeOp* fop, JSObject* obj)
634
0
{
635
0
  mozilla::dom::FlexItem* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FlexItem>(obj);
636
0
  if (self) {
637
0
    ClearWrapper(self, self, obj);
638
0
    AddForDeferredFinalization<mozilla::dom::FlexItem>(self);
639
0
  }
640
0
}
641
642
static size_t
643
_objectMoved(JSObject* obj, JSObject* old)
644
0
{
645
0
  mozilla::dom::FlexItem* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FlexItem>(obj);
646
0
  if (self) {
647
0
    UpdateWrapper(self, self, obj, old);
648
0
  }
649
0
650
0
  return 0;
651
0
}
652
653
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
654
#if defined(__clang__)
655
#pragma clang diagnostic push
656
#pragma clang diagnostic ignored "-Wmissing-braces"
657
#endif
658
static const JSPropertySpec sAttributes_specs[] = {
659
  { "node", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &node_getterinfo, nullptr, nullptr },
660
  { "mainBaseSize", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mainBaseSize_getterinfo, nullptr, nullptr },
661
  { "mainDeltaSize", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mainDeltaSize_getterinfo, nullptr, nullptr },
662
  { "mainMinSize", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mainMinSize_getterinfo, nullptr, nullptr },
663
  { "mainMaxSize", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mainMaxSize_getterinfo, nullptr, nullptr },
664
  { "crossMinSize", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &crossMinSize_getterinfo, nullptr, nullptr },
665
  { "crossMaxSize", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &crossMaxSize_getterinfo, nullptr, nullptr },
666
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
667
};
668
#if defined(__clang__)
669
#pragma clang diagnostic pop
670
#endif
671
672
673
static const Prefable<const JSPropertySpec> sAttributes[] = {
674
  { nullptr, &sAttributes_specs[0] },
675
  { nullptr, nullptr }
676
};
677
678
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
679
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
680
static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
681
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
682
683
684
static uint16_t sNativeProperties_sortedPropertyIndices[7];
685
static PropertyInfo sNativeProperties_propertyInfos[7];
686
687
static const NativePropertiesN<1> sNativeProperties = {
688
  false, 0,
689
  false, 0,
690
  false, 0,
691
  true,  0 /* sAttributes */,
692
  false, 0,
693
  false, 0,
694
  false, 0,
695
  -1,
696
  7,
697
  sNativeProperties_sortedPropertyIndices,
698
  {
699
    { sAttributes, &sNativeProperties_propertyInfos[0] }
700
  }
701
};
702
static_assert(7 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
703
    "We have a property info count that is oversized");
704
705
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
706
  {
707
    "Function",
708
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
709
    &sBoringInterfaceObjectClassClassOps,
710
    JS_NULL_CLASS_SPEC,
711
    JS_NULL_CLASS_EXT,
712
    &sInterfaceObjectClassObjectOps
713
  },
714
  eInterface,
715
  true,
716
  prototypes::id::FlexItem,
717
  PrototypeTraits<prototypes::id::FlexItem>::Depth,
718
  sNativePropertyHooks,
719
  "function FlexItem() {\n    [native code]\n}",
720
  JS::GetRealmFunctionPrototype
721
};
722
723
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
724
  {
725
    "FlexItemPrototype",
726
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
727
    JS_NULL_CLASS_OPS,
728
    JS_NULL_CLASS_SPEC,
729
    JS_NULL_CLASS_EXT,
730
    JS_NULL_OBJECT_OPS
731
  },
732
  eInterfacePrototype,
733
  false,
734
  prototypes::id::FlexItem,
735
  PrototypeTraits<prototypes::id::FlexItem>::Depth,
736
  sNativePropertyHooks,
737
  "[object FlexItemPrototype]",
738
  JS::GetRealmObjectPrototype
739
};
740
741
bool
742
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
743
0
{
744
0
  return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
745
0
}
746
747
static const js::ClassOps sClassOps = {
748
  _addProperty, /* addProperty */
749
  nullptr,               /* delProperty */
750
  nullptr,               /* enumerate */
751
  nullptr, /* newEnumerate */
752
  nullptr, /* resolve */
753
  nullptr, /* mayResolve */
754
  _finalize, /* finalize */
755
  nullptr, /* call */
756
  nullptr,               /* hasInstance */
757
  nullptr,               /* construct */
758
  nullptr, /* trace */
759
};
760
761
static const js::ClassExtension sClassExtension = {
762
  nullptr, /* weakmapKeyDelegateOp */
763
  _objectMoved /* objectMovedOp */
764
};
765
766
static const DOMJSClass sClass = {
767
  { "FlexItem",
768
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
769
    &sClassOps,
770
    JS_NULL_CLASS_SPEC,
771
    &sClassExtension,
772
    JS_NULL_OBJECT_OPS
773
  },
774
  { prototypes::id::FlexItem, 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 },
775
  IsBaseOf<nsISupports, mozilla::dom::FlexItem >::value,
776
  sNativePropertyHooks,
777
  FindAssociatedGlobalForNative<mozilla::dom::FlexItem>::Get,
778
  GetProtoObjectHandle,
779
  GetCCParticipant<mozilla::dom::FlexItem>::Get()
780
};
781
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
782
              "Must have the right minimal number of reserved slots.");
783
static_assert(1 >= 1,
784
              "Must have enough reserved slots.");
785
786
const JSClass*
787
GetJSClass()
788
0
{
789
0
  return sClass.ToJSClass();
790
0
}
791
792
bool
793
Wrap(JSContext* aCx, mozilla::dom::FlexItem* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
794
0
{
795
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::FlexItem>::value,
796
0
                "Shouldn't have wrappercached things that are not refcounted.");
797
0
  MOZ_ASSERT(static_cast<mozilla::dom::FlexItem*>(aObject) ==
798
0
             reinterpret_cast<mozilla::dom::FlexItem*>(aObject),
799
0
             "Multiple inheritance for mozilla::dom::FlexItem is broken.");
800
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
801
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
802
0
  MOZ_ASSERT(!aCache->GetWrapper(),
803
0
             "You should probably not be using Wrap() directly; use "
804
0
             "GetOrCreateDOMReflector instead");
805
0
806
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
807
0
             "nsISupports must be on our primary inheritance chain");
808
0
809
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
810
0
  if (!global) {
811
0
    return false;
812
0
  }
813
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
814
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
815
0
816
0
  // That might have ended up wrapping us already, due to the wonders
817
0
  // of XBL.  Check for that, and bail out as needed.
818
0
  aReflector.set(aCache->GetWrapper());
819
0
  if (aReflector) {
820
#ifdef DEBUG
821
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
822
#endif // DEBUG
823
    return true;
824
0
  }
825
0
826
0
  JSAutoRealm ar(aCx, global);
827
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
828
0
  if (!canonicalProto) {
829
0
    return false;
830
0
  }
831
0
  JS::Rooted<JSObject*> proto(aCx);
832
0
  if (aGivenProto) {
833
0
    proto = aGivenProto;
834
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
835
0
    // coming in, we changed compartments to that of "parent" so may need
836
0
    // to wrap the proto here.
837
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
838
0
      if (!JS_WrapObject(aCx, &proto)) {
839
0
        return false;
840
0
      }
841
0
    }
842
0
  } else {
843
0
    proto = canonicalProto;
844
0
  }
845
0
846
0
  BindingJSObjectCreator<mozilla::dom::FlexItem> creator(aCx);
847
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
848
0
  if (!aReflector) {
849
0
    return false;
850
0
  }
851
0
852
0
  aCache->SetWrapper(aReflector);
853
0
  creator.InitializationSucceeded();
854
0
855
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
856
0
             aCache->GetWrapperPreserveColor() == aReflector);
857
0
  // If proto != canonicalProto, we have to preserve our wrapper;
858
0
  // otherwise we won't be able to properly recreate it later, since
859
0
  // we won't know what proto to use.  Note that we don't check
860
0
  // aGivenProto here, since it's entirely possible (and even
861
0
  // somewhat common) to have a non-null aGivenProto which is the
862
0
  // same as canonicalProto.
863
0
  if (proto != canonicalProto) {
864
0
    PreserveWrapper(aObject);
865
0
  }
866
0
867
0
  return true;
868
0
}
869
870
const NativePropertyHooks sNativePropertyHooks[] = { {
871
  nullptr,
872
  nullptr,
873
  nullptr,
874
  { sNativeProperties.Upcast(), nullptr },
875
  prototypes::id::FlexItem,
876
  constructors::id::FlexItem,
877
  nullptr,
878
  &DefaultXrayExpandoObjectClass
879
} };
880
881
void
882
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
883
0
{
884
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
885
0
  if (!parentProto) {
886
0
    return;
887
0
  }
888
0
889
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
890
0
  if (!constructorProto) {
891
0
    return;
892
0
  }
893
0
894
0
  static bool sIdsInited = false;
895
0
  if (!sIdsInited && NS_IsMainThread()) {
896
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
897
0
      return;
898
0
    }
899
0
    sIdsInited = true;
900
0
  }
901
0
902
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::FlexItem);
903
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::FlexItem);
904
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
905
0
                              &sPrototypeClass.mBase, protoCache,
906
0
                              nullptr,
907
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
908
0
                              interfaceCache,
909
0
                              sNativeProperties.Upcast(),
910
0
                              nullptr,
911
0
                              "FlexItem", aDefineOnGlobal,
912
0
                              nullptr,
913
0
                              false);
914
0
}
915
916
JSObject*
917
GetConstructorObject(JSContext* aCx)
918
0
{
919
0
  return GetConstructorObjectHandle(aCx);
920
0
}
921
922
} // namespace FlexItem_Binding
923
924
925
926
namespace FlexLine_Binding {
927
928
MOZ_CAN_RUN_SCRIPT static bool
929
get_growthState(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FlexLine* self, JSJitGetterCallArgs args)
930
0
{
931
0
  AUTO_PROFILER_LABEL_FAST("get FlexLine.growthState", DOM, cx);
932
0
933
0
  FlexLineGrowthState result(self->GrowthState());
934
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
935
0
  if (!ToJSValue(cx, result, args.rval())) {
936
0
    return false;
937
0
  }
938
0
  return true;
939
0
}
940
941
static const JSJitInfo growthState_getterinfo = {
942
  { (JSJitGetterOp)get_growthState },
943
  { prototypes::id::FlexLine },
944
  { PrototypeTraits<prototypes::id::FlexLine>::Depth },
945
  JSJitInfo::Getter,
946
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
947
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
948
  false,  /* isInfallible. False in setters. */
949
  false,  /* isMovable.  Not relevant for setters. */
950
  false, /* isEliminatable.  Not relevant for setters. */
951
  false, /* isAlwaysInSlot.  Only relevant for getters. */
952
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
953
  false,  /* isTypedMethod.  Only relevant for methods. */
954
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
955
};
956
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
957
static_assert(0 < 1, "There is no slot for us");
958
959
MOZ_CAN_RUN_SCRIPT static bool
960
get_crossStart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FlexLine* self, JSJitGetterCallArgs args)
961
0
{
962
0
  AUTO_PROFILER_LABEL_FAST("get FlexLine.crossStart", DOM, cx);
963
0
964
0
  double result(self->CrossStart());
965
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
966
0
  args.rval().set(JS_NumberValue(double(result)));
967
0
  return true;
968
0
}
969
970
static const JSJitInfo crossStart_getterinfo = {
971
  { (JSJitGetterOp)get_crossStart },
972
  { prototypes::id::FlexLine },
973
  { PrototypeTraits<prototypes::id::FlexLine>::Depth },
974
  JSJitInfo::Getter,
975
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
976
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
977
  true,  /* isInfallible. False in setters. */
978
  false,  /* isMovable.  Not relevant for setters. */
979
  false, /* isEliminatable.  Not relevant for setters. */
980
  false, /* isAlwaysInSlot.  Only relevant for getters. */
981
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
982
  false,  /* isTypedMethod.  Only relevant for methods. */
983
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
984
};
985
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
986
static_assert(0 < 1, "There is no slot for us");
987
988
MOZ_CAN_RUN_SCRIPT static bool
989
get_crossSize(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FlexLine* self, JSJitGetterCallArgs args)
990
0
{
991
0
  AUTO_PROFILER_LABEL_FAST("get FlexLine.crossSize", DOM, cx);
992
0
993
0
  double result(self->CrossSize());
994
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
995
0
  args.rval().set(JS_NumberValue(double(result)));
996
0
  return true;
997
0
}
998
999
static const JSJitInfo crossSize_getterinfo = {
1000
  { (JSJitGetterOp)get_crossSize },
1001
  { prototypes::id::FlexLine },
1002
  { PrototypeTraits<prototypes::id::FlexLine>::Depth },
1003
  JSJitInfo::Getter,
1004
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1005
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
1006
  true,  /* isInfallible. False in setters. */
1007
  false,  /* isMovable.  Not relevant for setters. */
1008
  false, /* isEliminatable.  Not relevant for setters. */
1009
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1010
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1011
  false,  /* isTypedMethod.  Only relevant for methods. */
1012
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1013
};
1014
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1015
static_assert(0 < 1, "There is no slot for us");
1016
1017
MOZ_CAN_RUN_SCRIPT static bool
1018
get_firstBaselineOffset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FlexLine* self, JSJitGetterCallArgs args)
1019
0
{
1020
0
  AUTO_PROFILER_LABEL_FAST("get FlexLine.firstBaselineOffset", DOM, cx);
1021
0
1022
0
  double result(self->FirstBaselineOffset());
1023
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1024
0
  args.rval().set(JS_NumberValue(double(result)));
1025
0
  return true;
1026
0
}
1027
1028
static const JSJitInfo firstBaselineOffset_getterinfo = {
1029
  { (JSJitGetterOp)get_firstBaselineOffset },
1030
  { prototypes::id::FlexLine },
1031
  { PrototypeTraits<prototypes::id::FlexLine>::Depth },
1032
  JSJitInfo::Getter,
1033
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1034
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
1035
  true,  /* isInfallible. False in setters. */
1036
  false,  /* isMovable.  Not relevant for setters. */
1037
  false, /* isEliminatable.  Not relevant for setters. */
1038
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1039
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1040
  false,  /* isTypedMethod.  Only relevant for methods. */
1041
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1042
};
1043
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1044
static_assert(0 < 1, "There is no slot for us");
1045
1046
MOZ_CAN_RUN_SCRIPT static bool
1047
get_lastBaselineOffset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FlexLine* self, JSJitGetterCallArgs args)
1048
0
{
1049
0
  AUTO_PROFILER_LABEL_FAST("get FlexLine.lastBaselineOffset", DOM, cx);
1050
0
1051
0
  double result(self->LastBaselineOffset());
1052
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1053
0
  args.rval().set(JS_NumberValue(double(result)));
1054
0
  return true;
1055
0
}
1056
1057
static const JSJitInfo lastBaselineOffset_getterinfo = {
1058
  { (JSJitGetterOp)get_lastBaselineOffset },
1059
  { prototypes::id::FlexLine },
1060
  { PrototypeTraits<prototypes::id::FlexLine>::Depth },
1061
  JSJitInfo::Getter,
1062
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1063
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
1064
  true,  /* isInfallible. False in setters. */
1065
  false,  /* isMovable.  Not relevant for setters. */
1066
  false, /* isEliminatable.  Not relevant for setters. */
1067
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1068
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1069
  false,  /* isTypedMethod.  Only relevant for methods. */
1070
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1071
};
1072
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1073
static_assert(0 < 1, "There is no slot for us");
1074
1075
MOZ_CAN_RUN_SCRIPT static bool
1076
getItems(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FlexLine* self, const JSJitMethodCallArgs& args)
1077
0
{
1078
0
  AUTO_PROFILER_LABEL_FAST("FlexLine.getItems", DOM, cx);
1079
0
1080
0
  nsTArray<StrongPtrForMember<mozilla::dom::FlexItem>::Type> result;
1081
0
  self->GetItems(result);
1082
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1083
0
1084
0
  uint32_t length = result.Length();
1085
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
1086
0
  if (!returnArray) {
1087
0
    return false;
1088
0
  }
1089
0
  // Scope for 'tmp'
1090
0
  {
1091
0
    JS::Rooted<JS::Value> tmp(cx);
1092
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
1093
0
      // Control block to let us common up the JS_DefineElement calls when there
1094
0
      // are different ways to succeed at wrapping the object.
1095
0
      do {
1096
0
        if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) {
1097
0
          MOZ_ASSERT(JS_IsExceptionPending(cx));
1098
0
          return false;
1099
0
        }
1100
0
        break;
1101
0
      } while (false);
1102
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
1103
0
                            JSPROP_ENUMERATE)) {
1104
0
        return false;
1105
0
      }
1106
0
    }
1107
0
  }
1108
0
  args.rval().setObject(*returnArray);
1109
0
  return true;
1110
0
}
1111
1112
static const JSJitInfo getItems_methodinfo = {
1113
  { (JSJitGetterOp)getItems },
1114
  { prototypes::id::FlexLine },
1115
  { PrototypeTraits<prototypes::id::FlexLine>::Depth },
1116
  JSJitInfo::Method,
1117
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1118
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1119
  false,  /* isInfallible. False in setters. */
1120
  false,  /* isMovable.  Not relevant for setters. */
1121
  false, /* isEliminatable.  Not relevant for setters. */
1122
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1123
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1124
  false,  /* isTypedMethod.  Only relevant for methods. */
1125
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1126
};
1127
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1128
static_assert(0 < 1, "There is no slot for us");
1129
1130
static bool
1131
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1132
0
{
1133
0
  mozilla::dom::FlexLine* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FlexLine>(obj);
1134
0
  // We don't want to preserve if we don't have a wrapper, and we
1135
0
  // obviously can't preserve if we're not initialized.
1136
0
  if (self && self->GetWrapperPreserveColor()) {
1137
0
    PreserveWrapper(self);
1138
0
  }
1139
0
  return true;
1140
0
}
1141
1142
static void
1143
_finalize(js::FreeOp* fop, JSObject* obj)
1144
0
{
1145
0
  mozilla::dom::FlexLine* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FlexLine>(obj);
1146
0
  if (self) {
1147
0
    ClearWrapper(self, self, obj);
1148
0
    AddForDeferredFinalization<mozilla::dom::FlexLine>(self);
1149
0
  }
1150
0
}
1151
1152
static size_t
1153
_objectMoved(JSObject* obj, JSObject* old)
1154
0
{
1155
0
  mozilla::dom::FlexLine* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FlexLine>(obj);
1156
0
  if (self) {
1157
0
    UpdateWrapper(self, self, obj, old);
1158
0
  }
1159
0
1160
0
  return 0;
1161
0
}
1162
1163
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1164
#if defined(__clang__)
1165
#pragma clang diagnostic push
1166
#pragma clang diagnostic ignored "-Wmissing-braces"
1167
#endif
1168
static const JSFunctionSpec sMethods_specs[] = {
1169
  JS_FNSPEC("getItems", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getItems_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1170
  JS_FS_END
1171
};
1172
#if defined(__clang__)
1173
#pragma clang diagnostic pop
1174
#endif
1175
1176
1177
static const Prefable<const JSFunctionSpec> sMethods[] = {
1178
  { nullptr, &sMethods_specs[0] },
1179
  { nullptr, nullptr }
1180
};
1181
1182
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1183
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1184
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1185
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1186
1187
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1188
#if defined(__clang__)
1189
#pragma clang diagnostic push
1190
#pragma clang diagnostic ignored "-Wmissing-braces"
1191
#endif
1192
static const JSPropertySpec sAttributes_specs[] = {
1193
  { "growthState", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &growthState_getterinfo, nullptr, nullptr },
1194
  { "crossStart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &crossStart_getterinfo, nullptr, nullptr },
1195
  { "crossSize", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &crossSize_getterinfo, nullptr, nullptr },
1196
  { "firstBaselineOffset", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &firstBaselineOffset_getterinfo, nullptr, nullptr },
1197
  { "lastBaselineOffset", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &lastBaselineOffset_getterinfo, nullptr, nullptr },
1198
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1199
};
1200
#if defined(__clang__)
1201
#pragma clang diagnostic pop
1202
#endif
1203
1204
1205
static const Prefable<const JSPropertySpec> sAttributes[] = {
1206
  { nullptr, &sAttributes_specs[0] },
1207
  { nullptr, nullptr }
1208
};
1209
1210
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1211
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1212
static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1213
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1214
1215
1216
static uint16_t sNativeProperties_sortedPropertyIndices[6];
1217
static PropertyInfo sNativeProperties_propertyInfos[6];
1218
1219
static const NativePropertiesN<2> sNativeProperties = {
1220
  false, 0,
1221
  false, 0,
1222
  true,  0 /* sMethods */,
1223
  true,  1 /* sAttributes */,
1224
  false, 0,
1225
  false, 0,
1226
  false, 0,
1227
  -1,
1228
  6,
1229
  sNativeProperties_sortedPropertyIndices,
1230
  {
1231
    { sMethods, &sNativeProperties_propertyInfos[0] },
1232
    { sAttributes, &sNativeProperties_propertyInfos[1] }
1233
  }
1234
};
1235
static_assert(6 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1236
    "We have a property info count that is oversized");
1237
1238
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1239
  {
1240
    "Function",
1241
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1242
    &sBoringInterfaceObjectClassClassOps,
1243
    JS_NULL_CLASS_SPEC,
1244
    JS_NULL_CLASS_EXT,
1245
    &sInterfaceObjectClassObjectOps
1246
  },
1247
  eInterface,
1248
  true,
1249
  prototypes::id::FlexLine,
1250
  PrototypeTraits<prototypes::id::FlexLine>::Depth,
1251
  sNativePropertyHooks,
1252
  "function FlexLine() {\n    [native code]\n}",
1253
  JS::GetRealmFunctionPrototype
1254
};
1255
1256
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1257
  {
1258
    "FlexLinePrototype",
1259
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1260
    JS_NULL_CLASS_OPS,
1261
    JS_NULL_CLASS_SPEC,
1262
    JS_NULL_CLASS_EXT,
1263
    JS_NULL_OBJECT_OPS
1264
  },
1265
  eInterfacePrototype,
1266
  false,
1267
  prototypes::id::FlexLine,
1268
  PrototypeTraits<prototypes::id::FlexLine>::Depth,
1269
  sNativePropertyHooks,
1270
  "[object FlexLinePrototype]",
1271
  JS::GetRealmObjectPrototype
1272
};
1273
1274
bool
1275
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
1276
0
{
1277
0
  return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
1278
0
}
1279
1280
static const js::ClassOps sClassOps = {
1281
  _addProperty, /* addProperty */
1282
  nullptr,               /* delProperty */
1283
  nullptr,               /* enumerate */
1284
  nullptr, /* newEnumerate */
1285
  nullptr, /* resolve */
1286
  nullptr, /* mayResolve */
1287
  _finalize, /* finalize */
1288
  nullptr, /* call */
1289
  nullptr,               /* hasInstance */
1290
  nullptr,               /* construct */
1291
  nullptr, /* trace */
1292
};
1293
1294
static const js::ClassExtension sClassExtension = {
1295
  nullptr, /* weakmapKeyDelegateOp */
1296
  _objectMoved /* objectMovedOp */
1297
};
1298
1299
static const DOMJSClass sClass = {
1300
  { "FlexLine",
1301
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1302
    &sClassOps,
1303
    JS_NULL_CLASS_SPEC,
1304
    &sClassExtension,
1305
    JS_NULL_OBJECT_OPS
1306
  },
1307
  { prototypes::id::FlexLine, 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 },
1308
  IsBaseOf<nsISupports, mozilla::dom::FlexLine >::value,
1309
  sNativePropertyHooks,
1310
  FindAssociatedGlobalForNative<mozilla::dom::FlexLine>::Get,
1311
  GetProtoObjectHandle,
1312
  GetCCParticipant<mozilla::dom::FlexLine>::Get()
1313
};
1314
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1315
              "Must have the right minimal number of reserved slots.");
1316
static_assert(1 >= 1,
1317
              "Must have enough reserved slots.");
1318
1319
const JSClass*
1320
GetJSClass()
1321
0
{
1322
0
  return sClass.ToJSClass();
1323
0
}
1324
1325
bool
1326
Wrap(JSContext* aCx, mozilla::dom::FlexLine* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1327
0
{
1328
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::FlexLine>::value,
1329
0
                "Shouldn't have wrappercached things that are not refcounted.");
1330
0
  MOZ_ASSERT(static_cast<mozilla::dom::FlexLine*>(aObject) ==
1331
0
             reinterpret_cast<mozilla::dom::FlexLine*>(aObject),
1332
0
             "Multiple inheritance for mozilla::dom::FlexLine is broken.");
1333
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1334
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1335
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1336
0
             "You should probably not be using Wrap() directly; use "
1337
0
             "GetOrCreateDOMReflector instead");
1338
0
1339
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1340
0
             "nsISupports must be on our primary inheritance chain");
1341
0
1342
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1343
0
  if (!global) {
1344
0
    return false;
1345
0
  }
1346
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1347
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1348
0
1349
0
  // That might have ended up wrapping us already, due to the wonders
1350
0
  // of XBL.  Check for that, and bail out as needed.
1351
0
  aReflector.set(aCache->GetWrapper());
1352
0
  if (aReflector) {
1353
#ifdef DEBUG
1354
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1355
#endif // DEBUG
1356
    return true;
1357
0
  }
1358
0
1359
0
  JSAutoRealm ar(aCx, global);
1360
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1361
0
  if (!canonicalProto) {
1362
0
    return false;
1363
0
  }
1364
0
  JS::Rooted<JSObject*> proto(aCx);
1365
0
  if (aGivenProto) {
1366
0
    proto = aGivenProto;
1367
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1368
0
    // coming in, we changed compartments to that of "parent" so may need
1369
0
    // to wrap the proto here.
1370
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1371
0
      if (!JS_WrapObject(aCx, &proto)) {
1372
0
        return false;
1373
0
      }
1374
0
    }
1375
0
  } else {
1376
0
    proto = canonicalProto;
1377
0
  }
1378
0
1379
0
  BindingJSObjectCreator<mozilla::dom::FlexLine> creator(aCx);
1380
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1381
0
  if (!aReflector) {
1382
0
    return false;
1383
0
  }
1384
0
1385
0
  aCache->SetWrapper(aReflector);
1386
0
  creator.InitializationSucceeded();
1387
0
1388
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1389
0
             aCache->GetWrapperPreserveColor() == aReflector);
1390
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1391
0
  // otherwise we won't be able to properly recreate it later, since
1392
0
  // we won't know what proto to use.  Note that we don't check
1393
0
  // aGivenProto here, since it's entirely possible (and even
1394
0
  // somewhat common) to have a non-null aGivenProto which is the
1395
0
  // same as canonicalProto.
1396
0
  if (proto != canonicalProto) {
1397
0
    PreserveWrapper(aObject);
1398
0
  }
1399
0
1400
0
  return true;
1401
0
}
1402
1403
const NativePropertyHooks sNativePropertyHooks[] = { {
1404
  nullptr,
1405
  nullptr,
1406
  nullptr,
1407
  { sNativeProperties.Upcast(), nullptr },
1408
  prototypes::id::FlexLine,
1409
  constructors::id::FlexLine,
1410
  nullptr,
1411
  &DefaultXrayExpandoObjectClass
1412
} };
1413
1414
void
1415
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1416
0
{
1417
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
1418
0
  if (!parentProto) {
1419
0
    return;
1420
0
  }
1421
0
1422
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
1423
0
  if (!constructorProto) {
1424
0
    return;
1425
0
  }
1426
0
1427
0
  static bool sIdsInited = false;
1428
0
  if (!sIdsInited && NS_IsMainThread()) {
1429
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1430
0
      return;
1431
0
    }
1432
0
    sIdsInited = true;
1433
0
  }
1434
0
1435
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::FlexLine);
1436
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::FlexLine);
1437
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1438
0
                              &sPrototypeClass.mBase, protoCache,
1439
0
                              nullptr,
1440
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1441
0
                              interfaceCache,
1442
0
                              sNativeProperties.Upcast(),
1443
0
                              nullptr,
1444
0
                              "FlexLine", aDefineOnGlobal,
1445
0
                              nullptr,
1446
0
                              false);
1447
0
}
1448
1449
JSObject*
1450
GetConstructorObject(JSContext* aCx)
1451
0
{
1452
0
  return GetConstructorObjectHandle(aCx);
1453
0
}
1454
1455
} // namespace FlexLine_Binding
1456
1457
1458
1459
} // namespace dom
1460
} // namespace mozilla