Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/TreeColumnsBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM TreeColumns.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "TreeColumnsBinding.h"
4
#include "WrapperFactory.h"
5
#include "mozilla/OwningNonNull.h"
6
#include "mozilla/dom/BindingUtils.h"
7
#include "mozilla/dom/DOMJSClass.h"
8
#include "mozilla/dom/DOMJSProxyHandler.h"
9
#include "mozilla/dom/Element.h"
10
#include "mozilla/dom/NonRefcountedDOMObject.h"
11
#include "mozilla/dom/Nullable.h"
12
#include "mozilla/dom/PrimitiveConversions.h"
13
#include "mozilla/dom/TreeBoxObject.h"
14
#include "mozilla/dom/XrayExpandoClass.h"
15
#include "nsContentUtils.h"
16
#include "nsISupports.h"
17
#include "nsTreeColumns.h"
18
#include "xpcjsid.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 TreeColumns_Binding {
28
29
MOZ_CAN_RUN_SCRIPT static bool
30
get_tree(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, JSJitGetterCallArgs args)
31
0
{
32
0
  AUTO_PROFILER_LABEL_FAST("get TreeColumns.tree", DOM, cx);
33
0
34
0
  auto result(StrongOrRawPtr<mozilla::dom::TreeBoxObject>(self->GetTree()));
35
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
36
0
  if (!result) {
37
0
    args.rval().setNull();
38
0
    return true;
39
0
  }
40
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
41
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
42
0
    return false;
43
0
  }
44
0
  return true;
45
0
}
46
47
static const JSJitInfo tree_getterinfo = {
48
  { (JSJitGetterOp)get_tree },
49
  { prototypes::id::TreeColumns },
50
  { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
51
  JSJitInfo::Getter,
52
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
53
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
54
  false,  /* isInfallible. False in setters. */
55
  false,  /* isMovable.  Not relevant for setters. */
56
  false, /* isEliminatable.  Not relevant for setters. */
57
  false, /* isAlwaysInSlot.  Only relevant for getters. */
58
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
59
  false,  /* isTypedMethod.  Only relevant for methods. */
60
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
61
};
62
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
63
static_assert(0 < 1, "There is no slot for us");
64
65
MOZ_CAN_RUN_SCRIPT static bool
66
get_count(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, JSJitGetterCallArgs args)
67
0
{
68
0
  AUTO_PROFILER_LABEL_FAST("get TreeColumns.count", DOM, cx);
69
0
70
0
  uint32_t result(self->Count());
71
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
72
0
  args.rval().setNumber(result);
73
0
  return true;
74
0
}
75
76
static const JSJitInfo count_getterinfo = {
77
  { (JSJitGetterOp)get_count },
78
  { prototypes::id::TreeColumns },
79
  { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
80
  JSJitInfo::Getter,
81
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
82
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
83
  true,  /* isInfallible. False in setters. */
84
  false,  /* isMovable.  Not relevant for setters. */
85
  false, /* isEliminatable.  Not relevant for setters. */
86
  false, /* isAlwaysInSlot.  Only relevant for getters. */
87
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
88
  false,  /* isTypedMethod.  Only relevant for methods. */
89
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
90
};
91
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
92
static_assert(0 < 1, "There is no slot for us");
93
94
MOZ_CAN_RUN_SCRIPT static bool
95
get_length(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, JSJitGetterCallArgs args)
96
0
{
97
0
  AUTO_PROFILER_LABEL_FAST("get TreeColumns.length", DOM, cx);
98
0
99
0
  uint32_t result(self->Length());
100
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
101
0
  args.rval().setNumber(result);
102
0
  return true;
103
0
}
104
105
static const JSJitInfo length_getterinfo = {
106
  { (JSJitGetterOp)get_length },
107
  { prototypes::id::TreeColumns },
108
  { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
109
  JSJitInfo::Getter,
110
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
111
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
112
  true,  /* isInfallible. False in setters. */
113
  false,  /* isMovable.  Not relevant for setters. */
114
  false, /* isEliminatable.  Not relevant for setters. */
115
  false, /* isAlwaysInSlot.  Only relevant for getters. */
116
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
117
  false,  /* isTypedMethod.  Only relevant for methods. */
118
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
119
};
120
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
121
static_assert(0 < 1, "There is no slot for us");
122
123
MOZ_CAN_RUN_SCRIPT static bool
124
getFirstColumn(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
125
0
{
126
0
  AUTO_PROFILER_LABEL_FAST("TreeColumns.getFirstColumn", DOM, cx);
127
0
128
0
  auto result(StrongOrRawPtr<nsTreeColumn>(self->GetFirstColumn()));
129
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
130
0
  if (!result) {
131
0
    args.rval().setNull();
132
0
    return true;
133
0
  }
134
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
135
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
136
0
    return false;
137
0
  }
138
0
  return true;
139
0
}
140
141
static const JSJitInfo getFirstColumn_methodinfo = {
142
  { (JSJitGetterOp)getFirstColumn },
143
  { prototypes::id::TreeColumns },
144
  { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
145
  JSJitInfo::Method,
146
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
147
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
148
  false,  /* isInfallible. False in setters. */
149
  false,  /* isMovable.  Not relevant for setters. */
150
  false, /* isEliminatable.  Not relevant for setters. */
151
  false, /* isAlwaysInSlot.  Only relevant for getters. */
152
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
153
  false,  /* isTypedMethod.  Only relevant for methods. */
154
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
155
};
156
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
157
static_assert(0 < 1, "There is no slot for us");
158
159
MOZ_CAN_RUN_SCRIPT static bool
160
getLastColumn(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
161
0
{
162
0
  AUTO_PROFILER_LABEL_FAST("TreeColumns.getLastColumn", DOM, cx);
163
0
164
0
  auto result(StrongOrRawPtr<nsTreeColumn>(self->GetLastColumn()));
165
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
166
0
  if (!result) {
167
0
    args.rval().setNull();
168
0
    return true;
169
0
  }
170
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
171
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
172
0
    return false;
173
0
  }
174
0
  return true;
175
0
}
176
177
static const JSJitInfo getLastColumn_methodinfo = {
178
  { (JSJitGetterOp)getLastColumn },
179
  { prototypes::id::TreeColumns },
180
  { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
181
  JSJitInfo::Method,
182
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
183
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
184
  false,  /* isInfallible. False in setters. */
185
  false,  /* isMovable.  Not relevant for setters. */
186
  false, /* isEliminatable.  Not relevant for setters. */
187
  false, /* isAlwaysInSlot.  Only relevant for getters. */
188
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
189
  false,  /* isTypedMethod.  Only relevant for methods. */
190
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
191
};
192
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
193
static_assert(0 < 1, "There is no slot for us");
194
195
MOZ_CAN_RUN_SCRIPT static bool
196
getPrimaryColumn(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
197
0
{
198
0
  AUTO_PROFILER_LABEL_FAST("TreeColumns.getPrimaryColumn", DOM, cx);
199
0
200
0
  auto result(StrongOrRawPtr<nsTreeColumn>(self->GetPrimaryColumn()));
201
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
202
0
  if (!result) {
203
0
    args.rval().setNull();
204
0
    return true;
205
0
  }
206
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
207
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
208
0
    return false;
209
0
  }
210
0
  return true;
211
0
}
212
213
static const JSJitInfo getPrimaryColumn_methodinfo = {
214
  { (JSJitGetterOp)getPrimaryColumn },
215
  { prototypes::id::TreeColumns },
216
  { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
217
  JSJitInfo::Method,
218
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
219
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
220
  false,  /* isInfallible. False in setters. */
221
  false,  /* isMovable.  Not relevant for setters. */
222
  false, /* isEliminatable.  Not relevant for setters. */
223
  false, /* isAlwaysInSlot.  Only relevant for getters. */
224
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
225
  false,  /* isTypedMethod.  Only relevant for methods. */
226
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
227
};
228
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
229
static_assert(0 < 1, "There is no slot for us");
230
231
MOZ_CAN_RUN_SCRIPT static bool
232
getSortedColumn(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
233
0
{
234
0
  AUTO_PROFILER_LABEL_FAST("TreeColumns.getSortedColumn", DOM, cx);
235
0
236
0
  auto result(StrongOrRawPtr<nsTreeColumn>(self->GetSortedColumn()));
237
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
238
0
  if (!result) {
239
0
    args.rval().setNull();
240
0
    return true;
241
0
  }
242
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
243
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
244
0
    return false;
245
0
  }
246
0
  return true;
247
0
}
248
249
static const JSJitInfo getSortedColumn_methodinfo = {
250
  { (JSJitGetterOp)getSortedColumn },
251
  { prototypes::id::TreeColumns },
252
  { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
253
  JSJitInfo::Method,
254
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
255
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
256
  false,  /* isInfallible. False in setters. */
257
  false,  /* isMovable.  Not relevant for setters. */
258
  false, /* isEliminatable.  Not relevant for setters. */
259
  false, /* isAlwaysInSlot.  Only relevant for getters. */
260
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
261
  false,  /* isTypedMethod.  Only relevant for methods. */
262
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
263
};
264
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
265
static_assert(0 < 1, "There is no slot for us");
266
267
MOZ_CAN_RUN_SCRIPT static bool
268
getKeyColumn(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
269
0
{
270
0
  AUTO_PROFILER_LABEL_FAST("TreeColumns.getKeyColumn", DOM, cx);
271
0
272
0
  auto result(StrongOrRawPtr<nsTreeColumn>(self->GetKeyColumn()));
273
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
274
0
  if (!result) {
275
0
    args.rval().setNull();
276
0
    return true;
277
0
  }
278
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
279
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
280
0
    return false;
281
0
  }
282
0
  return true;
283
0
}
284
285
static const JSJitInfo getKeyColumn_methodinfo = {
286
  { (JSJitGetterOp)getKeyColumn },
287
  { prototypes::id::TreeColumns },
288
  { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
289
  JSJitInfo::Method,
290
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
291
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
292
  false,  /* isInfallible. False in setters. */
293
  false,  /* isMovable.  Not relevant for setters. */
294
  false, /* isEliminatable.  Not relevant for setters. */
295
  false, /* isAlwaysInSlot.  Only relevant for getters. */
296
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
297
  false,  /* isTypedMethod.  Only relevant for methods. */
298
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
299
};
300
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
301
static_assert(0 < 1, "There is no slot for us");
302
303
MOZ_CAN_RUN_SCRIPT static bool
304
getColumnFor(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
305
0
{
306
0
  AUTO_PROFILER_LABEL_FAST("TreeColumns.getColumnFor", DOM, cx);
307
0
308
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
309
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "TreeColumns.getColumnFor");
310
0
  }
311
0
  mozilla::dom::Element* arg0;
312
0
  if (args[0].isObject()) {
313
0
    {
314
0
      nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
315
0
      if (NS_FAILED(rv)) {
316
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of TreeColumns.getColumnFor", "Element");
317
0
        return false;
318
0
      }
319
0
    }
320
0
  } else if (args[0].isNullOrUndefined()) {
321
0
    arg0 = nullptr;
322
0
  } else {
323
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of TreeColumns.getColumnFor");
324
0
    return false;
325
0
  }
326
0
  auto result(StrongOrRawPtr<nsTreeColumn>(self->GetColumnFor(MOZ_KnownLive(Constify(arg0)))));
327
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
328
0
  if (!result) {
329
0
    args.rval().setNull();
330
0
    return true;
331
0
  }
332
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
333
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
334
0
    return false;
335
0
  }
336
0
  return true;
337
0
}
338
339
static const JSJitInfo getColumnFor_methodinfo = {
340
  { (JSJitGetterOp)getColumnFor },
341
  { prototypes::id::TreeColumns },
342
  { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
343
  JSJitInfo::Method,
344
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
345
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
346
  false,  /* isInfallible. False in setters. */
347
  false,  /* isMovable.  Not relevant for setters. */
348
  false, /* isEliminatable.  Not relevant for setters. */
349
  false, /* isAlwaysInSlot.  Only relevant for getters. */
350
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
351
  false,  /* isTypedMethod.  Only relevant for methods. */
352
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
353
};
354
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
355
static_assert(0 < 1, "There is no slot for us");
356
357
MOZ_CAN_RUN_SCRIPT static bool
358
getNamedColumn(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
359
0
{
360
0
  AUTO_PROFILER_LABEL_FAST("TreeColumns.getNamedColumn", DOM, cx);
361
0
362
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
363
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "TreeColumns.getNamedColumn");
364
0
  }
365
0
  binding_detail::FakeString arg0;
366
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
367
0
    return false;
368
0
  }
369
0
  auto result(StrongOrRawPtr<nsTreeColumn>(self->GetNamedColumn(NonNullHelper(Constify(arg0)))));
370
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
371
0
  if (!result) {
372
0
    args.rval().setNull();
373
0
    return true;
374
0
  }
375
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
376
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
377
0
    return false;
378
0
  }
379
0
  return true;
380
0
}
381
382
static const JSJitInfo getNamedColumn_methodinfo = {
383
  { (JSJitGetterOp)getNamedColumn },
384
  { prototypes::id::TreeColumns },
385
  { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
386
  JSJitInfo::Method,
387
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
388
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
389
  false,  /* isInfallible. False in setters. */
390
  false,  /* isMovable.  Not relevant for setters. */
391
  false, /* isEliminatable.  Not relevant for setters. */
392
  false, /* isAlwaysInSlot.  Only relevant for getters. */
393
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
394
  false,  /* isTypedMethod.  Only relevant for methods. */
395
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
396
};
397
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
398
static_assert(0 < 1, "There is no slot for us");
399
400
MOZ_CAN_RUN_SCRIPT static bool
401
getColumnAt(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
402
0
{
403
0
  AUTO_PROFILER_LABEL_FAST("TreeColumns.getColumnAt", DOM, cx);
404
0
405
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
406
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "TreeColumns.getColumnAt");
407
0
  }
408
0
  uint32_t arg0;
409
0
  if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
410
0
    return false;
411
0
  }
412
0
  auto result(StrongOrRawPtr<nsTreeColumn>(self->GetColumnAt(arg0)));
413
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
414
0
  if (!result) {
415
0
    args.rval().setNull();
416
0
    return true;
417
0
  }
418
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
419
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
420
0
    return false;
421
0
  }
422
0
  return true;
423
0
}
424
425
static const JSJitInfo getColumnAt_methodinfo = {
426
  { (JSJitGetterOp)getColumnAt },
427
  { prototypes::id::TreeColumns },
428
  { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
429
  JSJitInfo::Method,
430
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
431
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
432
  false,  /* isInfallible. False in setters. */
433
  false,  /* isMovable.  Not relevant for setters. */
434
  false, /* isEliminatable.  Not relevant for setters. */
435
  false, /* isAlwaysInSlot.  Only relevant for getters. */
436
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
437
  false,  /* isTypedMethod.  Only relevant for methods. */
438
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
439
};
440
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
441
static_assert(0 < 1, "There is no slot for us");
442
443
MOZ_CAN_RUN_SCRIPT static bool
444
invalidateColumns(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
445
0
{
446
0
  AUTO_PROFILER_LABEL_FAST("TreeColumns.invalidateColumns", DOM, cx);
447
0
448
0
  self->InvalidateColumns();
449
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
450
0
  args.rval().setUndefined();
451
0
  return true;
452
0
}
453
454
static const JSJitInfo invalidateColumns_methodinfo = {
455
  { (JSJitGetterOp)invalidateColumns },
456
  { prototypes::id::TreeColumns },
457
  { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
458
  JSJitInfo::Method,
459
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
460
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
461
  true,  /* isInfallible. False in setters. */
462
  false,  /* isMovable.  Not relevant for setters. */
463
  false, /* isEliminatable.  Not relevant for setters. */
464
  false, /* isAlwaysInSlot.  Only relevant for getters. */
465
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
466
  false,  /* isTypedMethod.  Only relevant for methods. */
467
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
468
};
469
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
470
static_assert(0 < 1, "There is no slot for us");
471
472
MOZ_CAN_RUN_SCRIPT static bool
473
restoreNaturalOrder(JSContext* cx, JS::Handle<JSObject*> obj, nsTreeColumns* self, const JSJitMethodCallArgs& args)
474
0
{
475
0
  AUTO_PROFILER_LABEL_FAST("TreeColumns.restoreNaturalOrder", DOM, cx);
476
0
477
0
  self->RestoreNaturalOrder();
478
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
479
0
  args.rval().setUndefined();
480
0
  return true;
481
0
}
482
483
static const JSJitInfo restoreNaturalOrder_methodinfo = {
484
  { (JSJitGetterOp)restoreNaturalOrder },
485
  { prototypes::id::TreeColumns },
486
  { PrototypeTraits<prototypes::id::TreeColumns>::Depth },
487
  JSJitInfo::Method,
488
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
489
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
490
  true,  /* isInfallible. False in setters. */
491
  false,  /* isMovable.  Not relevant for setters. */
492
  false, /* isEliminatable.  Not relevant for setters. */
493
  false, /* isAlwaysInSlot.  Only relevant for getters. */
494
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
495
  false,  /* isTypedMethod.  Only relevant for methods. */
496
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
497
};
498
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
499
static_assert(0 < 1, "There is no slot for us");
500
501
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
502
#if defined(__clang__)
503
#pragma clang diagnostic push
504
#pragma clang diagnostic ignored "-Wmissing-braces"
505
#endif
506
static const JSFunctionSpec sMethods_specs[] = {
507
  JS_FNSPEC("getFirstColumn", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getFirstColumn_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
508
  JS_FNSPEC("getLastColumn", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getLastColumn_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
509
  JS_FNSPEC("getPrimaryColumn", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getPrimaryColumn_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
510
  JS_FNSPEC("getSortedColumn", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getSortedColumn_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
511
  JS_FNSPEC("getKeyColumn", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getKeyColumn_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
512
  JS_FNSPEC("getColumnFor", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getColumnFor_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
513
  JS_FNSPEC("getNamedColumn", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getNamedColumn_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
514
  JS_FNSPEC("getColumnAt", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getColumnAt_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
515
  JS_FNSPEC("invalidateColumns", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&invalidateColumns_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
516
  JS_FNSPEC("restoreNaturalOrder", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&restoreNaturalOrder_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
517
  JS_SYM_FNSPEC(iterator, nullptr, nullptr, 0, 0, "ArrayValues"),
518
  JS_FS_END
519
};
520
#if defined(__clang__)
521
#pragma clang diagnostic pop
522
#endif
523
524
525
static const Prefable<const JSFunctionSpec> sMethods[] = {
526
  { nullptr, &sMethods_specs[0] },
527
  { nullptr, nullptr }
528
};
529
530
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
531
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
532
static_assert(11 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
533
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
534
535
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
536
#if defined(__clang__)
537
#pragma clang diagnostic push
538
#pragma clang diagnostic ignored "-Wmissing-braces"
539
#endif
540
static const JSFunctionSpec sChromeMethods_specs[] = {
541
  JS_FNSPEC("QueryInterface", QueryInterface, nullptr, 1, 0, nullptr),
542
  JS_FS_END
543
};
544
#if defined(__clang__)
545
#pragma clang diagnostic pop
546
#endif
547
548
549
static const Prefable<const JSFunctionSpec> sChromeMethods[] = {
550
  { nullptr, &sChromeMethods_specs[0] },
551
  { nullptr, nullptr }
552
};
553
554
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
555
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
556
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
557
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
558
559
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
560
#if defined(__clang__)
561
#pragma clang diagnostic push
562
#pragma clang diagnostic ignored "-Wmissing-braces"
563
#endif
564
static const JSPropertySpec sAttributes_specs[] = {
565
  { "tree", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &tree_getterinfo, nullptr, nullptr },
566
  { "count", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &count_getterinfo, nullptr, nullptr },
567
  { "length", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &length_getterinfo, nullptr, nullptr },
568
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
569
};
570
#if defined(__clang__)
571
#pragma clang diagnostic pop
572
#endif
573
574
575
static const Prefable<const JSPropertySpec> sAttributes[] = {
576
  { nullptr, &sAttributes_specs[0] },
577
  { nullptr, nullptr }
578
};
579
580
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
581
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
582
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
583
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
584
585
586
static uint16_t sNativeProperties_sortedPropertyIndices[14];
587
static PropertyInfo sNativeProperties_propertyInfos[14];
588
589
static const NativePropertiesN<2> sNativeProperties = {
590
  false, 0,
591
  false, 0,
592
  true,  0 /* sMethods */,
593
  true,  1 /* sAttributes */,
594
  false, 0,
595
  false, 0,
596
  false, 0,
597
  -1,
598
  14,
599
  sNativeProperties_sortedPropertyIndices,
600
  {
601
    { sMethods, &sNativeProperties_propertyInfos[0] },
602
    { sAttributes, &sNativeProperties_propertyInfos[11] }
603
  }
604
};
605
static_assert(14 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
606
    "We have a property info count that is oversized");
607
608
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
609
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
610
611
static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
612
  false, 0,
613
  false, 0,
614
  true,  0 /* sChromeMethods */,
615
  false, 0,
616
  false, 0,
617
  false, 0,
618
  false, 0,
619
  -1,
620
  1,
621
  sChromeOnlyNativeProperties_sortedPropertyIndices,
622
  {
623
    { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }
624
  }
625
};
626
static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
627
    "We have a property info count that is oversized");
628
629
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
630
  {
631
    "Function",
632
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
633
    &sBoringInterfaceObjectClassClassOps,
634
    JS_NULL_CLASS_SPEC,
635
    JS_NULL_CLASS_EXT,
636
    &sInterfaceObjectClassObjectOps
637
  },
638
  eInterface,
639
  true,
640
  prototypes::id::TreeColumns,
641
  PrototypeTraits<prototypes::id::TreeColumns>::Depth,
642
  sNativePropertyHooks,
643
  "function TreeColumns() {\n    [native code]\n}",
644
  JS::GetRealmFunctionPrototype
645
};
646
647
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
648
  {
649
    "TreeColumnsPrototype",
650
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
651
    JS_NULL_CLASS_OPS,
652
    JS_NULL_CLASS_SPEC,
653
    JS_NULL_CLASS_EXT,
654
    JS_NULL_OBJECT_OPS
655
  },
656
  eInterfacePrototype,
657
  false,
658
  prototypes::id::TreeColumns,
659
  PrototypeTraits<prototypes::id::TreeColumns>::Depth,
660
  sNativePropertyHooks,
661
  "[object TreeColumnsPrototype]",
662
  JS::GetRealmObjectPrototype
663
};
664
665
bool
666
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
667
0
{
668
0
  return IsChromeOrXBL(aCx, aObj);
669
0
}
670
671
static_assert(IsBaseOf<nsISupports, nsTreeColumns >::value,
672
                  "We don't support non-nsISupports native classes for "
673
                  "proxy-based bindings yet");
674
675
676
class DOMProxyHandler : public mozilla::dom::DOMProxyHandler
677
{
678
public:
679
  explicit constexpr DOMProxyHandler()
680
0
  {
681
0
  }
682
683
  virtual bool
684
  getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const override;
685
686
  virtual bool
687
  defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const override;
688
689
  using mozilla::dom::DOMProxyHandler::defineProperty;
690
691
  virtual bool
692
  ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const override;
693
694
  virtual bool
695
  hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const override;
696
697
  virtual bool
698
  get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const override;
699
700
  virtual const char*
701
  className(JSContext* cx, JS::Handle<JSObject*> proxy) const override;
702
703
  virtual bool
704
  finalizeInBackground(const JS::Value& priv) const override;
705
706
  virtual void
707
  finalize(JSFreeOp* fop, JSObject* proxy) const override;
708
709
  static const DOMProxyHandler*
710
  getInstance();
711
712
  virtual bool
713
  delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const override;
714
715
  virtual bool
716
  getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const override;
717
718
  virtual size_t
719
  objectMoved(JSObject* obj, JSObject* old) const override;
720
};
721
722
MOZ_ALWAYS_INLINE bool
723
IsProxy(JSObject* obj)
724
0
{
725
0
  return js::IsProxy(obj) && js::GetProxyHandler(obj) == DOMProxyHandler::getInstance();
726
0
}
727
728
MOZ_ALWAYS_INLINE nsTreeColumns*
729
UnwrapProxy(JSObject* obj)
730
0
{
731
0
  MOZ_ASSERT(js::IsProxy(obj));
732
0
  if (js::GetProxyHandler(obj) != DOMProxyHandler::getInstance()) {
733
0
    MOZ_ASSERT(xpc::WrapperFactory::IsXrayWrapper(obj));
734
0
    obj = js::UncheckedUnwrap(obj);
735
0
  }
736
0
  MOZ_ASSERT(IsProxy(obj));
737
0
  return static_cast<nsTreeColumns*>(js::GetProxyReservedSlot(obj, DOM_OBJECT_SLOT).toPrivate());
738
0
}
739
740
bool
741
DOMProxyHandler::getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const
742
0
{
743
0
  bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
744
0
  uint32_t index = GetArrayIndexFromId(cx, id);
745
0
  if (IsArrayIndex(index)) {
746
0
    nsTreeColumns* self = UnwrapProxy(proxy);
747
0
    bool found = false;
748
0
    auto result(StrongOrRawPtr<nsTreeColumn>(self->IndexedGetter(index, found)));
749
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
750
0
751
0
    if (found) {
752
0
      if (!result) {
753
0
        desc.value().setNull();
754
0
        FillPropertyDescriptor(desc, proxy, true);
755
0
        return true;
756
0
      }
757
0
      if (!GetOrCreateDOMReflector(cx, result, desc.value())) {
758
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
759
0
        return false;
760
0
      }
761
0
      FillPropertyDescriptor(desc, proxy, true);
762
0
      return true;
763
0
    }
764
0
  }
765
0
766
0
  JS::Rooted<JSObject*> expando(cx);
767
0
  if (!isXray && (expando = GetExpandoObject(proxy))) {
768
0
    if (!JS_GetOwnPropertyDescriptorById(cx, expando, id, desc)) {
769
0
      return false;
770
0
    }
771
0
    if (desc.object()) {
772
0
      // Pretend the property lives on the wrapper.
773
0
      desc.object().set(proxy);
774
0
      return true;
775
0
    }
776
0
  }
777
0
778
0
  bool callNamedGetter = false;
779
0
  if (!IsArrayIndex(index) && !ignoreNamedProps) {
780
0
    bool hasOnProto;
781
0
    if (!HasPropertyOnPrototype(cx, proxy, id, &hasOnProto)) {
782
0
      return false;
783
0
    }
784
0
    callNamedGetter = !hasOnProto;
785
0
  }
786
0
  if (callNamedGetter) {
787
0
    FakeString name;
788
0
    bool isSymbol;
789
0
    if (!ConvertIdToString(cx, id, name, isSymbol)) {
790
0
      return false;
791
0
    }
792
0
    if (!isSymbol) {
793
0
      nsTreeColumns* self = UnwrapProxy(proxy);
794
0
      bool found = false;
795
0
      auto result(StrongOrRawPtr<nsTreeColumn>(self->NamedGetter(NonNullHelper(Constify(name)), found)));
796
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
797
0
798
0
      if (found) {
799
0
        if (!result) {
800
0
          desc.value().setNull();
801
0
          FillPropertyDescriptor(desc, proxy, true, true);
802
0
          return true;
803
0
        }
804
0
        if (!GetOrCreateDOMReflector(cx, result, desc.value())) {
805
0
          MOZ_ASSERT(JS_IsExceptionPending(cx));
806
0
          return false;
807
0
        }
808
0
        FillPropertyDescriptor(desc, proxy, true, true);
809
0
        return true;
810
0
      }
811
0
    }
812
0
  }
813
0
814
0
  desc.object().set(nullptr);
815
0
  return true;
816
0
}
817
818
bool
819
DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const
820
0
{
821
0
  if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
822
0
    *defined = true;
823
0
    return opresult.failNoIndexedSetter();
824
0
  }
825
0
  bool found = false;
826
0
  FakeString name;
827
0
  bool isSymbol;
828
0
  if (!ConvertIdToString(cx, id, name, isSymbol)) {
829
0
    return false;
830
0
  }
831
0
  if (!isSymbol) {
832
0
    nsTreeColumns* self = UnwrapProxy(proxy);
833
0
    auto result(StrongOrRawPtr<nsTreeColumn>(self->NamedGetter(NonNullHelper(Constify(name)), found)));
834
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
835
0
    (void)result;
836
0
  }
837
0
838
0
  if (found) {
839
0
    *defined = true;
840
0
    return opresult.failNoNamedSetter();
841
0
  }
842
0
  return mozilla::dom::DOMProxyHandler::defineProperty(cx, proxy, id, desc, opresult, defined);
843
0
}
844
845
846
bool
847
DOMProxyHandler::ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const
848
0
{
849
0
  bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
850
0
851
0
  uint32_t length = UnwrapProxy(proxy)->Length();
852
0
  MOZ_ASSERT(int32_t(length) >= 0);
853
0
  for (int32_t i = 0; i < int32_t(length); ++i) {
854
0
    if (!props.append(INT_TO_JSID(i))) {
855
0
      return false;
856
0
    }
857
0
  }
858
0
859
0
  nsTArray<nsString> names;
860
0
  UnwrapProxy(proxy)->GetSupportedNames(names);
861
0
  if (!AppendNamedPropertyIds(cx, proxy, names, false, props)) {
862
0
    return false;
863
0
  }
864
0
865
0
  JS::Rooted<JSObject*> expando(cx);
866
0
  if (!isXray && (expando = DOMProxyHandler::GetExpandoObject(proxy)) &&
867
0
      !js::GetPropertyKeys(cx, expando, flags, &props)) {
868
0
    return false;
869
0
  }
870
0
871
0
  return true;
872
0
}
873
874
bool
875
DOMProxyHandler::hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const
876
0
{
877
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
878
0
            "Should not have a XrayWrapper here");
879
0
880
0
  uint32_t index = GetArrayIndexFromId(cx, id);
881
0
  if (IsArrayIndex(index)) {
882
0
    bool found = false;
883
0
    nsTreeColumns* self = UnwrapProxy(proxy);
884
0
    auto result(StrongOrRawPtr<nsTreeColumn>(self->IndexedGetter(index, found)));
885
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
886
0
    (void)result;
887
0
888
0
    *bp = found;
889
0
    return true;
890
0
  }
891
0
892
0
893
0
  JS::Rooted<JSObject*> expando(cx, GetExpandoObject(proxy));
894
0
  if (expando) {
895
0
    bool b = true;
896
0
    bool ok = JS_HasPropertyById(cx, expando, id, &b);
897
0
    *bp = !!b;
898
0
    if (!ok || *bp) {
899
0
      return ok;
900
0
    }
901
0
  }
902
0
903
0
  bool hasOnProto;
904
0
  if (!HasPropertyOnPrototype(cx, proxy, id, &hasOnProto)) {
905
0
    return false;
906
0
  }
907
0
  if (!hasOnProto) {
908
0
    bool found = false;
909
0
    FakeString name;
910
0
    bool isSymbol;
911
0
    if (!ConvertIdToString(cx, id, name, isSymbol)) {
912
0
      return false;
913
0
    }
914
0
    if (!isSymbol) {
915
0
      nsTreeColumns* self = UnwrapProxy(proxy);
916
0
      auto result(StrongOrRawPtr<nsTreeColumn>(self->NamedGetter(NonNullHelper(Constify(name)), found)));
917
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
918
0
      (void)result;
919
0
    }
920
0
921
0
    *bp = found;
922
0
    return true;
923
0
  }
924
0
  *bp = false;
925
0
  return true;
926
0
}
927
928
bool
929
DOMProxyHandler::get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const
930
0
{
931
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
932
0
              "Should not have a XrayWrapper here");
933
0
934
0
  uint32_t index = GetArrayIndexFromId(cx, id);
935
0
  if (IsArrayIndex(index)) {
936
0
    nsTreeColumns* self = UnwrapProxy(proxy);
937
0
    bool found = false;
938
0
    auto result(StrongOrRawPtr<nsTreeColumn>(self->IndexedGetter(index, found)));
939
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
940
0
941
0
    if (found) {
942
0
      if (!result) {
943
0
        vp.setNull();
944
0
        return true;
945
0
      }
946
0
      if (!GetOrCreateDOMReflector(cx, result, vp)) {
947
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
948
0
        return false;
949
0
      }
950
0
      return true;
951
0
    }
952
0
    // Even if we don't have this index, we don't forward the
953
0
    // get on to our expando object.
954
0
  } else {
955
0
    { // Scope for expando
956
0
      JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
957
0
      if (expando) {
958
0
        bool hasProp;
959
0
        if (!JS_HasPropertyById(cx, expando, id, &hasProp)) {
960
0
          return false;
961
0
        }
962
0
963
0
        if (hasProp) {
964
0
          // Forward the get to the expando object, but our receiver is whatever our
965
0
          // receiver is.
966
0
          return JS_ForwardGetPropertyTo(cx, expando, id, receiver, vp);
967
0
        }
968
0
      }
969
0
    }
970
0
  }
971
0
972
0
  bool foundOnPrototype;
973
0
  if (!GetPropertyOnPrototype(cx, proxy, receiver, id, &foundOnPrototype, vp)) {
974
0
    return false;
975
0
  }
976
0
977
0
  if (foundOnPrototype) {
978
0
    return true;
979
0
  }
980
0
981
0
  if (!IsArrayIndex(index)) {
982
0
    FakeString name;
983
0
    bool isSymbol;
984
0
    if (!ConvertIdToString(cx, id, name, isSymbol)) {
985
0
      return false;
986
0
    }
987
0
    if (!isSymbol) {
988
0
      nsTreeColumns* self = UnwrapProxy(proxy);
989
0
      bool found = false;
990
0
      auto result(StrongOrRawPtr<nsTreeColumn>(self->NamedGetter(NonNullHelper(Constify(name)), found)));
991
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
992
0
993
0
      if (found) {
994
0
        if (!result) {
995
0
          vp.setNull();
996
0
          return true;
997
0
        }
998
0
        if (!GetOrCreateDOMReflector(cx, result, vp)) {
999
0
          MOZ_ASSERT(JS_IsExceptionPending(cx));
1000
0
          return false;
1001
0
        }
1002
0
        return true;
1003
0
      }
1004
0
    }
1005
0
  }
1006
0
1007
0
  vp.setUndefined();
1008
0
  return true;
1009
0
}
1010
1011
const char*
1012
DOMProxyHandler::className(JSContext* cx, JS::Handle<JSObject*> proxy) const
1013
0
{
1014
0
  return "TreeColumns";
1015
0
}
1016
1017
bool
1018
DOMProxyHandler::finalizeInBackground(const JS::Value& priv) const
1019
0
{
1020
0
  return false;
1021
0
}
1022
1023
void
1024
DOMProxyHandler::finalize(JSFreeOp* fop, JSObject* proxy) const
1025
0
{
1026
0
  nsTreeColumns* self = UnwrapPossiblyNotInitializedDOMObject<nsTreeColumns>(proxy);
1027
0
  if (self) {
1028
0
    ClearWrapper(self, self, proxy);
1029
0
    AddForDeferredFinalization<nsTreeColumns>(self);
1030
0
  }
1031
0
}
1032
1033
const DOMProxyHandler*
1034
DOMProxyHandler::getInstance()
1035
0
{
1036
0
  static const DOMProxyHandler instance;
1037
0
  return &instance;
1038
0
}
1039
1040
bool
1041
DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const
1042
0
{
1043
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
1044
0
            "Should not have a XrayWrapper here");
1045
0
1046
0
  uint32_t index = GetArrayIndexFromId(cx, id);
1047
0
  if (IsArrayIndex(index)) {
1048
0
    bool deleteSucceeded;
1049
0
    bool found = false;
1050
0
    nsTreeColumns* self = UnwrapProxy(proxy);
1051
0
    auto result(StrongOrRawPtr<nsTreeColumn>(self->IndexedGetter(index, found)));
1052
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
1053
0
    (void)result;
1054
0
    deleteSucceeded = !found;
1055
0
    return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete();
1056
0
  }
1057
0
  // Try named delete only if the named property visibility
1058
0
  // algorithm says the property is visible.
1059
0
  bool tryNamedDelete = true;
1060
0
  { // Scope for expando
1061
0
    JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
1062
0
    if (expando) {
1063
0
      bool hasProp;
1064
0
      if (!JS_HasPropertyById(cx, expando, id, &hasProp)) {
1065
0
        return false;
1066
0
      }
1067
0
      tryNamedDelete = !hasProp;
1068
0
    }
1069
0
  }
1070
0
  if (tryNamedDelete) {
1071
0
    bool hasOnProto;
1072
0
    if (!HasPropertyOnPrototype(cx, proxy, id, &hasOnProto)) {
1073
0
      return false;
1074
0
    }
1075
0
    tryNamedDelete = !hasOnProto;
1076
0
  }
1077
0
  if (tryNamedDelete) {
1078
0
    bool found = false;
1079
0
    bool deleteSucceeded;
1080
0
    FakeString name;
1081
0
    bool isSymbol;
1082
0
    if (!ConvertIdToString(cx, id, name, isSymbol)) {
1083
0
      return false;
1084
0
    }
1085
0
    if (!isSymbol) {
1086
0
      nsTreeColumns* self = UnwrapProxy(proxy);
1087
0
      auto result(StrongOrRawPtr<nsTreeColumn>(self->NamedGetter(NonNullHelper(Constify(name)), found)));
1088
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
1089
0
      (void)result;
1090
0
    }
1091
0
    deleteSucceeded = !found;
1092
0
    if (found) {
1093
0
      return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete();
1094
0
    }
1095
0
  }
1096
0
1097
0
  return dom::DOMProxyHandler::delete_(cx, proxy, id, opresult);
1098
0
}
1099
1100
bool
1101
DOMProxyHandler::getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const
1102
0
{
1103
0
  JS::Rooted<JS::Value> temp(cx);
1104
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
1105
0
             "Should not have a XrayWrapper here");
1106
0
1107
0
  nsTreeColumns* self = UnwrapProxy(proxy);
1108
0
  uint32_t length = self->Length();
1109
0
  // Compute the end of the indices we'll get ourselves
1110
0
  uint32_t ourEnd = std::max(begin, std::min(end, length));
1111
0
1112
0
  for (uint32_t index = begin; index < ourEnd; ++index) {
1113
0
    bool found = false;
1114
0
    auto result(StrongOrRawPtr<nsTreeColumn>(self->IndexedGetter(index, found)));
1115
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
1116
0
1117
0
    MOZ_ASSERT(found);
1118
0
    if (!result) {
1119
0
      temp.setNull();
1120
0
      if (!adder->append(cx, temp)) return false;
1121
0
      continue;
1122
0
    }
1123
0
    if (!GetOrCreateDOMReflector(cx, result, &temp)) {
1124
0
      MOZ_ASSERT(JS_IsExceptionPending(cx));
1125
0
      return false;
1126
0
    }
1127
0
    if (!adder->append(cx, temp)) return false;
1128
0
    continue;
1129
0
  }
1130
0
1131
0
  if (end > ourEnd) {
1132
0
    JS::Rooted<JSObject*> proto(cx);
1133
0
    if (!js::GetObjectProto(cx, proxy, &proto)) {
1134
0
      return false;
1135
0
    }
1136
0
    return js::GetElementsWithAdder(cx, proto, proxy, ourEnd, end, adder);
1137
0
  }
1138
0
1139
0
  return true;
1140
0
}
1141
1142
size_t
1143
DOMProxyHandler::objectMoved(JSObject* obj, JSObject* old) const
1144
0
{
1145
0
  nsTreeColumns* self = UnwrapPossiblyNotInitializedDOMObject<nsTreeColumns>(obj);
1146
0
  if (self) {
1147
0
    UpdateWrapper(self, self, obj, old);
1148
0
  }
1149
0
1150
0
  return 0;
1151
0
}
1152
1153
static const DOMJSClass sClass = {
1154
  PROXY_CLASS_DEF("TreeColumns",
1155
                  JSCLASS_IS_DOMJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(1)),
1156
  { prototypes::id::TreeColumns, 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 },
1157
  IsBaseOf<nsISupports, nsTreeColumns >::value,
1158
  sNativePropertyHooks,
1159
  FindAssociatedGlobalForNative<nsTreeColumns>::Get,
1160
  GetProtoObjectHandle,
1161
  GetCCParticipant<nsTreeColumns>::Get()
1162
};
1163
1164
bool
1165
Wrap(JSContext* aCx, nsTreeColumns* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1166
0
{
1167
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, nsTreeColumns>::value,
1168
0
                "Shouldn't have wrappercached things that are not refcounted.");
1169
0
  MOZ_ASSERT(static_cast<nsTreeColumns*>(aObject) ==
1170
0
             reinterpret_cast<nsTreeColumns*>(aObject),
1171
0
             "Multiple inheritance for nsTreeColumns is broken.");
1172
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1173
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1174
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1175
0
             "You should probably not be using Wrap() directly; use "
1176
0
             "GetOrCreateDOMReflector instead");
1177
0
1178
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1179
0
             "nsISupports must be on our primary inheritance chain");
1180
0
1181
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1182
0
  if (!global) {
1183
0
    return false;
1184
0
  }
1185
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1186
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1187
0
1188
0
  // That might have ended up wrapping us already, due to the wonders
1189
0
  // of XBL.  Check for that, and bail out as needed.
1190
0
  aReflector.set(aCache->GetWrapper());
1191
0
  if (aReflector) {
1192
#ifdef DEBUG
1193
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1194
#endif // DEBUG
1195
    return true;
1196
0
  }
1197
0
1198
0
  JSAutoRealm ar(aCx, global);
1199
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1200
0
  if (!canonicalProto) {
1201
0
    return false;
1202
0
  }
1203
0
  JS::Rooted<JSObject*> proto(aCx);
1204
0
  if (aGivenProto) {
1205
0
    proto = aGivenProto;
1206
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1207
0
    // coming in, we changed compartments to that of "parent" so may need
1208
0
    // to wrap the proto here.
1209
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1210
0
      if (!JS_WrapObject(aCx, &proto)) {
1211
0
        return false;
1212
0
      }
1213
0
    }
1214
0
  } else {
1215
0
    proto = canonicalProto;
1216
0
  }
1217
0
1218
0
  BindingJSObjectCreator<nsTreeColumns> creator(aCx);
1219
0
  creator.CreateProxyObject(aCx, &sClass.mBase, DOMProxyHandler::getInstance(),
1220
0
                            proto, aObject, JS::UndefinedHandleValue, aReflector);
1221
0
  if (!aReflector) {
1222
0
    return false;
1223
0
  }
1224
0
1225
0
  aCache->SetWrapper(aReflector);
1226
0
  creator.InitializationSucceeded();
1227
0
1228
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1229
0
             aCache->GetWrapperPreserveColor() == aReflector);
1230
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1231
0
  // otherwise we won't be able to properly recreate it later, since
1232
0
  // we won't know what proto to use.  Note that we don't check
1233
0
  // aGivenProto here, since it's entirely possible (and even
1234
0
  // somewhat common) to have a non-null aGivenProto which is the
1235
0
  // same as canonicalProto.
1236
0
  if (proto != canonicalProto) {
1237
0
    PreserveWrapper(aObject);
1238
0
  }
1239
0
1240
0
  return true;
1241
0
}
1242
1243
static bool
1244
ResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::MutableHandle<JS::PropertyDescriptor> desc)
1245
0
{
1246
0
  return js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, desc);
1247
0
}
1248
1249
static bool
1250
EnumerateOwnProperties(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::AutoIdVector& props)
1251
0
{
1252
0
  return js::GetProxyHandler(obj)->ownPropertyKeys(cx, wrapper, props);
1253
0
}
1254
1255
const NativePropertyHooks sNativePropertyHooks[] = { {
1256
  ResolveOwnProperty,
1257
  EnumerateOwnProperties,
1258
  nullptr,
1259
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
1260
  prototypes::id::TreeColumns,
1261
  constructors::id::TreeColumns,
1262
  nullptr,
1263
  &DefaultXrayExpandoObjectClass
1264
} };
1265
1266
void
1267
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1268
0
{
1269
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
1270
0
  if (!parentProto) {
1271
0
    return;
1272
0
  }
1273
0
1274
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
1275
0
  if (!constructorProto) {
1276
0
    return;
1277
0
  }
1278
0
1279
0
  static bool sIdsInited = false;
1280
0
  if (!sIdsInited && NS_IsMainThread()) {
1281
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1282
0
      return;
1283
0
    }
1284
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
1285
0
      return;
1286
0
    }
1287
0
    sIdsInited = true;
1288
0
  }
1289
0
1290
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::TreeColumns);
1291
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::TreeColumns);
1292
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1293
0
                              &sPrototypeClass.mBase, protoCache,
1294
0
                              nullptr,
1295
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1296
0
                              interfaceCache,
1297
0
                              sNativeProperties.Upcast(),
1298
0
                              sChromeOnlyNativeProperties.Upcast(),
1299
0
                              "TreeColumns", aDefineOnGlobal,
1300
0
                              nullptr,
1301
0
                              false);
1302
0
}
1303
1304
JSObject*
1305
GetConstructorObject(JSContext* aCx)
1306
0
{
1307
0
  return GetConstructorObjectHandle(aCx);
1308
0
}
1309
1310
} // namespace TreeColumns_Binding
1311
1312
1313
1314
} // namespace dom
1315
} // namespace mozilla