Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/AnonymousContentBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM AnonymousContent.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AnonymousContentBinding.h"
4
#include "KeyframeAnimationOptionsBinding.h"
5
#include "WrapperFactory.h"
6
#include "mozilla/OwningNonNull.h"
7
#include "mozilla/dom/Animation.h"
8
#include "mozilla/dom/AnonymousContent.h"
9
#include "mozilla/dom/BindingUtils.h"
10
#include "mozilla/dom/DOMJSClass.h"
11
#include "mozilla/dom/DOMRect.h"
12
#include "mozilla/dom/NonRefcountedDOMObject.h"
13
#include "mozilla/dom/Nullable.h"
14
#include "mozilla/dom/UnionConversions.h"
15
#include "mozilla/dom/XrayExpandoClass.h"
16
#include "nsContentUtils.h"
17
#include "nsISupports.h"
18
19
namespace mozilla {
20
namespace dom {
21
22
namespace binding_detail {}; // Just to make sure it's known as a namespace
23
using namespace mozilla::dom::binding_detail;
24
25
26
namespace AnonymousContent_Binding {
27
28
MOZ_CAN_RUN_SCRIPT static bool
29
getTextContentForElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnonymousContent* self, const JSJitMethodCallArgs& args)
30
0
{
31
0
  AUTO_PROFILER_LABEL_FAST("AnonymousContent.getTextContentForElement", DOM, cx);
32
0
33
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
34
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnonymousContent.getTextContentForElement");
35
0
  }
36
0
  binding_detail::FakeString arg0;
37
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
38
0
    return false;
39
0
  }
40
0
  FastErrorResult rv;
41
0
  DOMString result;
42
0
  self->GetTextContentForElement(NonNullHelper(Constify(arg0)), result, rv);
43
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
44
0
    return false;
45
0
  }
46
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
47
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
48
0
    return false;
49
0
  }
50
0
  return true;
51
0
}
52
53
static const JSJitInfo getTextContentForElement_methodinfo = {
54
  { (JSJitGetterOp)getTextContentForElement },
55
  { prototypes::id::AnonymousContent },
56
  { PrototypeTraits<prototypes::id::AnonymousContent>::Depth },
57
  JSJitInfo::Method,
58
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
59
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
60
  false,  /* isInfallible. False in setters. */
61
  false,  /* isMovable.  Not relevant for setters. */
62
  false, /* isEliminatable.  Not relevant for setters. */
63
  false, /* isAlwaysInSlot.  Only relevant for getters. */
64
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
65
  false,  /* isTypedMethod.  Only relevant for methods. */
66
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
67
};
68
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
69
static_assert(0 < 1, "There is no slot for us");
70
71
MOZ_CAN_RUN_SCRIPT static bool
72
setTextContentForElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnonymousContent* self, const JSJitMethodCallArgs& args)
73
0
{
74
0
  AUTO_PROFILER_LABEL_FAST("AnonymousContent.setTextContentForElement", DOM, cx);
75
0
76
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
77
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnonymousContent.setTextContentForElement");
78
0
  }
79
0
  binding_detail::FakeString arg0;
80
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
81
0
    return false;
82
0
  }
83
0
  binding_detail::FakeString arg1;
84
0
  if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
85
0
    return false;
86
0
  }
87
0
  FastErrorResult rv;
88
0
  self->SetTextContentForElement(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv);
89
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
90
0
    return false;
91
0
  }
92
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
93
0
  args.rval().setUndefined();
94
0
  return true;
95
0
}
96
97
static const JSJitInfo setTextContentForElement_methodinfo = {
98
  { (JSJitGetterOp)setTextContentForElement },
99
  { prototypes::id::AnonymousContent },
100
  { PrototypeTraits<prototypes::id::AnonymousContent>::Depth },
101
  JSJitInfo::Method,
102
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
103
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
104
  false,  /* isInfallible. False in setters. */
105
  false,  /* isMovable.  Not relevant for setters. */
106
  false, /* isEliminatable.  Not relevant for setters. */
107
  false, /* isAlwaysInSlot.  Only relevant for getters. */
108
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
109
  false,  /* isTypedMethod.  Only relevant for methods. */
110
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
111
};
112
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
113
static_assert(0 < 1, "There is no slot for us");
114
115
MOZ_CAN_RUN_SCRIPT static bool
116
getAttributeForElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnonymousContent* self, const JSJitMethodCallArgs& args)
117
0
{
118
0
  AUTO_PROFILER_LABEL_FAST("AnonymousContent.getAttributeForElement", DOM, cx);
119
0
120
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
121
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnonymousContent.getAttributeForElement");
122
0
  }
123
0
  binding_detail::FakeString arg0;
124
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
125
0
    return false;
126
0
  }
127
0
  binding_detail::FakeString arg1;
128
0
  if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
129
0
    return false;
130
0
  }
131
0
  FastErrorResult rv;
132
0
  DOMString result;
133
0
  self->GetAttributeForElement(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), result, rv);
134
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
135
0
    return false;
136
0
  }
137
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
138
0
  if (!xpc::StringToJsval(cx, result, args.rval())) {
139
0
    return false;
140
0
  }
141
0
  return true;
142
0
}
143
144
static const JSJitInfo getAttributeForElement_methodinfo = {
145
  { (JSJitGetterOp)getAttributeForElement },
146
  { prototypes::id::AnonymousContent },
147
  { PrototypeTraits<prototypes::id::AnonymousContent>::Depth },
148
  JSJitInfo::Method,
149
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
150
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
151
  false,  /* isInfallible. False in setters. */
152
  false,  /* isMovable.  Not relevant for setters. */
153
  false, /* isEliminatable.  Not relevant for setters. */
154
  false, /* isAlwaysInSlot.  Only relevant for getters. */
155
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
156
  false,  /* isTypedMethod.  Only relevant for methods. */
157
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
158
};
159
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
160
static_assert(0 < 1, "There is no slot for us");
161
162
MOZ_CAN_RUN_SCRIPT static bool
163
setAttributeForElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnonymousContent* self, const JSJitMethodCallArgs& args)
164
0
{
165
0
  AUTO_PROFILER_LABEL_FAST("AnonymousContent.setAttributeForElement", DOM, cx);
166
0
167
0
  if (MOZ_UNLIKELY(args.length() < 3)) {
168
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnonymousContent.setAttributeForElement");
169
0
  }
170
0
  binding_detail::FakeString arg0;
171
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
172
0
    return false;
173
0
  }
174
0
  binding_detail::FakeString arg1;
175
0
  if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
176
0
    return false;
177
0
  }
178
0
  binding_detail::FakeString arg2;
179
0
  if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2)) {
180
0
    return false;
181
0
  }
182
0
  FastErrorResult rv;
183
0
  nsIPrincipal* subjectPrincipal;
184
0
  {
185
0
    JS::Realm* realm = js::GetContextRealm(cx);
186
0
    MOZ_ASSERT(realm);
187
0
    JSPrincipals* principals = JS::GetRealmPrincipals(realm);
188
0
    nsIPrincipal* principal = nsJSPrincipals::get(principals);
189
0
    if (nsContentUtils::IsSystemPrincipal(principal)) {
190
0
      principal = nullptr;
191
0
    }
192
0
193
0
    subjectPrincipal = principal;
194
0
  }
195
0
  self->SetAttributeForElement(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), NonNullHelper(Constify(arg2)), subjectPrincipal, rv);
196
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
197
0
    return false;
198
0
  }
199
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
200
0
  args.rval().setUndefined();
201
0
  return true;
202
0
}
203
204
static const JSJitInfo setAttributeForElement_methodinfo = {
205
  { (JSJitGetterOp)setAttributeForElement },
206
  { prototypes::id::AnonymousContent },
207
  { PrototypeTraits<prototypes::id::AnonymousContent>::Depth },
208
  JSJitInfo::Method,
209
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
210
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
211
  false,  /* isInfallible. False in setters. */
212
  false,  /* isMovable.  Not relevant for setters. */
213
  false, /* isEliminatable.  Not relevant for setters. */
214
  false, /* isAlwaysInSlot.  Only relevant for getters. */
215
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
216
  false,  /* isTypedMethod.  Only relevant for methods. */
217
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
218
};
219
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
220
static_assert(0 < 1, "There is no slot for us");
221
222
MOZ_CAN_RUN_SCRIPT static bool
223
removeAttributeForElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnonymousContent* self, const JSJitMethodCallArgs& args)
224
0
{
225
0
  AUTO_PROFILER_LABEL_FAST("AnonymousContent.removeAttributeForElement", DOM, cx);
226
0
227
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
228
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnonymousContent.removeAttributeForElement");
229
0
  }
230
0
  binding_detail::FakeString arg0;
231
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
232
0
    return false;
233
0
  }
234
0
  binding_detail::FakeString arg1;
235
0
  if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
236
0
    return false;
237
0
  }
238
0
  FastErrorResult rv;
239
0
  self->RemoveAttributeForElement(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv);
240
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
241
0
    return false;
242
0
  }
243
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
244
0
  args.rval().setUndefined();
245
0
  return true;
246
0
}
247
248
static const JSJitInfo removeAttributeForElement_methodinfo = {
249
  { (JSJitGetterOp)removeAttributeForElement },
250
  { prototypes::id::AnonymousContent },
251
  { PrototypeTraits<prototypes::id::AnonymousContent>::Depth },
252
  JSJitInfo::Method,
253
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
254
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
255
  false,  /* isInfallible. False in setters. */
256
  false,  /* isMovable.  Not relevant for setters. */
257
  false, /* isEliminatable.  Not relevant for setters. */
258
  false, /* isAlwaysInSlot.  Only relevant for getters. */
259
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
260
  false,  /* isTypedMethod.  Only relevant for methods. */
261
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
262
};
263
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
264
static_assert(0 < 1, "There is no slot for us");
265
266
MOZ_CAN_RUN_SCRIPT static bool
267
getCanvasContext(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnonymousContent* self, const JSJitMethodCallArgs& args)
268
0
{
269
0
  AUTO_PROFILER_LABEL_FAST("AnonymousContent.getCanvasContext", DOM, cx);
270
0
271
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
272
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnonymousContent.getCanvasContext");
273
0
  }
274
0
  binding_detail::FakeString arg0;
275
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
276
0
    return false;
277
0
  }
278
0
  binding_detail::FakeString arg1;
279
0
  if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
280
0
    return false;
281
0
  }
282
0
  FastErrorResult rv;
283
0
  auto result(StrongOrRawPtr<nsISupports>(self->GetCanvasContext(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv)));
284
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
285
0
    return false;
286
0
  }
287
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
288
0
  if (!result) {
289
0
    args.rval().setNull();
290
0
    return true;
291
0
  }
292
0
  if (!WrapObject(cx, result, args.rval())) {
293
0
    return false;
294
0
  }
295
0
  return true;
296
0
}
297
298
static const JSJitInfo getCanvasContext_methodinfo = {
299
  { (JSJitGetterOp)getCanvasContext },
300
  { prototypes::id::AnonymousContent },
301
  { PrototypeTraits<prototypes::id::AnonymousContent>::Depth },
302
  JSJitInfo::Method,
303
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
304
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
305
  false,  /* isInfallible. False in setters. */
306
  false,  /* isMovable.  Not relevant for setters. */
307
  false, /* isEliminatable.  Not relevant for setters. */
308
  false, /* isAlwaysInSlot.  Only relevant for getters. */
309
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
310
  false,  /* isTypedMethod.  Only relevant for methods. */
311
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
312
};
313
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
314
static_assert(0 < 1, "There is no slot for us");
315
316
MOZ_CAN_RUN_SCRIPT static bool
317
setAnimationForElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnonymousContent* self, const JSJitMethodCallArgs& args)
318
0
{
319
0
  AUTO_PROFILER_LABEL_FAST("AnonymousContent.setAnimationForElement", DOM, cx);
320
0
321
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
322
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnonymousContent.setAnimationForElement");
323
0
  }
324
0
  binding_detail::FakeString arg0;
325
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
326
0
    return false;
327
0
  }
328
0
  JS::Rooted<JSObject*> arg1(cx);
329
0
  if (args[1].isObject()) {
330
0
    arg1 = &args[1].toObject();
331
0
  } else if (args[1].isNullOrUndefined()) {
332
0
    arg1 = nullptr;
333
0
  } else {
334
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of AnonymousContent.setAnimationForElement");
335
0
    return false;
336
0
  }
337
0
  UnrestrictedDoubleOrKeyframeAnimationOptions arg2;
338
0
  UnrestrictedDoubleOrKeyframeAnimationOptionsArgument arg2_holder(arg2);
339
0
  if (!(args.hasDefined(2))) {
340
0
    if (!arg2.RawSetAsKeyframeAnimationOptions().Init(cx, JS::NullHandleValue, "Member of UnrestrictedDoubleOrKeyframeAnimationOptions")) {
341
0
      return false;
342
0
    }
343
0
  } else {
344
0
    {
345
0
      bool done = false, failed = false, tryNext;
346
0
      if (!done) {
347
0
        done = (failed = !arg2_holder.TrySetToKeyframeAnimationOptions(cx, args[2], tryNext, false)) || !tryNext;
348
0
      }
349
0
      if (!done) {
350
0
        do {
351
0
          done = (failed = !arg2_holder.TrySetToUnrestrictedDouble(cx, args[2], tryNext)) || !tryNext;
352
0
          break;
353
0
        } while (false);
354
0
      }
355
0
      if (failed) {
356
0
        return false;
357
0
      }
358
0
      if (!done) {
359
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 3 of AnonymousContent.setAnimationForElement", "KeyframeAnimationOptions");
360
0
        return false;
361
0
      }
362
0
    }
363
0
  }
364
0
  FastErrorResult rv;
365
0
  auto result(StrongOrRawPtr<mozilla::dom::Animation>(self->SetAnimationForElement(cx, NonNullHelper(Constify(arg0)), arg1, Constify(arg2), rv)));
366
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
367
0
    return false;
368
0
  }
369
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
370
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
371
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
372
0
    return false;
373
0
  }
374
0
  return true;
375
0
}
376
377
static const JSJitInfo setAnimationForElement_methodinfo = {
378
  { (JSJitGetterOp)setAnimationForElement },
379
  { prototypes::id::AnonymousContent },
380
  { PrototypeTraits<prototypes::id::AnonymousContent>::Depth },
381
  JSJitInfo::Method,
382
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
383
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
384
  false,  /* isInfallible. False in setters. */
385
  false,  /* isMovable.  Not relevant for setters. */
386
  false, /* isEliminatable.  Not relevant for setters. */
387
  false, /* isAlwaysInSlot.  Only relevant for getters. */
388
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
389
  false,  /* isTypedMethod.  Only relevant for methods. */
390
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
391
};
392
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
393
static_assert(0 < 1, "There is no slot for us");
394
395
MOZ_CAN_RUN_SCRIPT static bool
396
setCutoutRectsForElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnonymousContent* self, const JSJitMethodCallArgs& args)
397
0
{
398
0
  AUTO_PROFILER_LABEL_FAST("AnonymousContent.setCutoutRectsForElement", DOM, cx);
399
0
400
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
401
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnonymousContent.setCutoutRectsForElement");
402
0
  }
403
0
  binding_detail::FakeString arg0;
404
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
405
0
    return false;
406
0
  }
407
0
  binding_detail::AutoSequence<OwningNonNull<mozilla::dom::DOMRect>> arg1;
408
0
  if (args[1].isObject()) {
409
0
    JS::ForOfIterator iter(cx);
410
0
    if (!iter.init(args[1], JS::ForOfIterator::AllowNonIterable)) {
411
0
      return false;
412
0
    }
413
0
    if (!iter.valueIsIterable()) {
414
0
      ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 2 of AnonymousContent.setCutoutRectsForElement");
415
0
      return false;
416
0
    }
417
0
    binding_detail::AutoSequence<OwningNonNull<mozilla::dom::DOMRect>> &arr = arg1;
418
0
    JS::Rooted<JS::Value> temp(cx);
419
0
    while (true) {
420
0
      bool done;
421
0
      if (!iter.next(&temp, &done)) {
422
0
        return false;
423
0
      }
424
0
      if (done) {
425
0
        break;
426
0
      }
427
0
      OwningNonNull<mozilla::dom::DOMRect>* slotPtr = arr.AppendElement(mozilla::fallible);
428
0
      if (!slotPtr) {
429
0
        JS_ReportOutOfMemory(cx);
430
0
        return false;
431
0
      }
432
0
      OwningNonNull<mozilla::dom::DOMRect>& slot = *slotPtr;
433
0
      if (temp.isObject()) {
434
0
        static_assert(IsRefcounted<mozilla::dom::DOMRect>::value, "We can only store refcounted classes.");{
435
0
          nsresult rv = UnwrapObject<prototypes::id::DOMRect, mozilla::dom::DOMRect>(&temp, slot);
436
0
          if (NS_FAILED(rv)) {
437
0
            ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Element of argument 2 of AnonymousContent.setCutoutRectsForElement", "DOMRect");
438
0
            return false;
439
0
          }
440
0
        }
441
0
      } else {
442
0
        ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Element of argument 2 of AnonymousContent.setCutoutRectsForElement");
443
0
        return false;
444
0
      }
445
0
    }
446
0
  } else {
447
0
    ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 2 of AnonymousContent.setCutoutRectsForElement");
448
0
    return false;
449
0
  }
450
0
  FastErrorResult rv;
451
0
  self->SetCutoutRectsForElement(NonNullHelper(Constify(arg0)), Constify(arg1), rv);
452
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
453
0
    return false;
454
0
  }
455
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
456
0
  args.rval().setUndefined();
457
0
  return true;
458
0
}
459
460
static const JSJitInfo setCutoutRectsForElement_methodinfo = {
461
  { (JSJitGetterOp)setCutoutRectsForElement },
462
  { prototypes::id::AnonymousContent },
463
  { PrototypeTraits<prototypes::id::AnonymousContent>::Depth },
464
  JSJitInfo::Method,
465
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
466
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
467
  false,  /* isInfallible. False in setters. */
468
  false,  /* isMovable.  Not relevant for setters. */
469
  false, /* isEliminatable.  Not relevant for setters. */
470
  false, /* isAlwaysInSlot.  Only relevant for getters. */
471
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
472
  false,  /* isTypedMethod.  Only relevant for methods. */
473
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
474
};
475
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
476
static_assert(0 < 1, "There is no slot for us");
477
478
MOZ_CAN_RUN_SCRIPT static bool
479
getComputedStylePropertyValue(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnonymousContent* self, const JSJitMethodCallArgs& args)
480
0
{
481
0
  AUTO_PROFILER_LABEL_FAST("AnonymousContent.getComputedStylePropertyValue", DOM, cx);
482
0
483
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
484
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnonymousContent.getComputedStylePropertyValue");
485
0
  }
486
0
  binding_detail::FakeString arg0;
487
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
488
0
    return false;
489
0
  }
490
0
  binding_detail::FakeString arg1;
491
0
  if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
492
0
    return false;
493
0
  }
494
0
  FastErrorResult rv;
495
0
  DOMString result;
496
0
  self->GetComputedStylePropertyValue(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), result, rv);
497
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
498
0
    return false;
499
0
  }
500
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
501
0
  if (!xpc::StringToJsval(cx, result, args.rval())) {
502
0
    return false;
503
0
  }
504
0
  return true;
505
0
}
506
507
static const JSJitInfo getComputedStylePropertyValue_methodinfo = {
508
  { (JSJitGetterOp)getComputedStylePropertyValue },
509
  { prototypes::id::AnonymousContent },
510
  { PrototypeTraits<prototypes::id::AnonymousContent>::Depth },
511
  JSJitInfo::Method,
512
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
513
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
514
  false,  /* isInfallible. False in setters. */
515
  false,  /* isMovable.  Not relevant for setters. */
516
  false, /* isEliminatable.  Not relevant for setters. */
517
  false, /* isAlwaysInSlot.  Only relevant for getters. */
518
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
519
  false,  /* isTypedMethod.  Only relevant for methods. */
520
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
521
};
522
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
523
static_assert(0 < 1, "There is no slot for us");
524
525
static void
526
_finalize(js::FreeOp* fop, JSObject* obj)
527
0
{
528
0
  mozilla::dom::AnonymousContent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AnonymousContent>(obj);
529
0
  if (self) {
530
0
    AddForDeferredFinalization<mozilla::dom::AnonymousContent>(self);
531
0
  }
532
0
}
533
534
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
535
#if defined(__clang__)
536
#pragma clang diagnostic push
537
#pragma clang diagnostic ignored "-Wmissing-braces"
538
#endif
539
static const JSFunctionSpec sMethods_specs[] = {
540
  JS_FNSPEC("getTextContentForElement", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getTextContentForElement_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
541
  JS_FNSPEC("setTextContentForElement", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setTextContentForElement_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
542
  JS_FNSPEC("getAttributeForElement", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getAttributeForElement_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
543
  JS_FNSPEC("setAttributeForElement", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setAttributeForElement_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
544
  JS_FNSPEC("removeAttributeForElement", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&removeAttributeForElement_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
545
  JS_FNSPEC("getCanvasContext", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getCanvasContext_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
546
  JS_FNSPEC("setAnimationForElement", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setAnimationForElement_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
547
  JS_FNSPEC("setCutoutRectsForElement", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setCutoutRectsForElement_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
548
  JS_FNSPEC("getComputedStylePropertyValue", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getComputedStylePropertyValue_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
549
  JS_FS_END
550
};
551
#if defined(__clang__)
552
#pragma clang diagnostic pop
553
#endif
554
555
556
static const Prefable<const JSFunctionSpec> sMethods[] = {
557
  { nullptr, &sMethods_specs[0] },
558
  { nullptr, nullptr }
559
};
560
561
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
562
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
563
static_assert(9 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
564
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
565
566
567
static uint16_t sNativeProperties_sortedPropertyIndices[9];
568
static PropertyInfo sNativeProperties_propertyInfos[9];
569
570
static const NativePropertiesN<1> sNativeProperties = {
571
  false, 0,
572
  false, 0,
573
  true,  0 /* sMethods */,
574
  false, 0,
575
  false, 0,
576
  false, 0,
577
  false, 0,
578
  -1,
579
  9,
580
  sNativeProperties_sortedPropertyIndices,
581
  {
582
    { sMethods, &sNativeProperties_propertyInfos[0] }
583
  }
584
};
585
static_assert(9 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
586
    "We have a property info count that is oversized");
587
588
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
589
  {
590
    "Function",
591
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
592
    &sBoringInterfaceObjectClassClassOps,
593
    JS_NULL_CLASS_SPEC,
594
    JS_NULL_CLASS_EXT,
595
    &sInterfaceObjectClassObjectOps
596
  },
597
  eInterface,
598
  true,
599
  prototypes::id::AnonymousContent,
600
  PrototypeTraits<prototypes::id::AnonymousContent>::Depth,
601
  sNativePropertyHooks,
602
  "function AnonymousContent() {\n    [native code]\n}",
603
  JS::GetRealmFunctionPrototype
604
};
605
606
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
607
  {
608
    "AnonymousContentPrototype",
609
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
610
    JS_NULL_CLASS_OPS,
611
    JS_NULL_CLASS_SPEC,
612
    JS_NULL_CLASS_EXT,
613
    JS_NULL_OBJECT_OPS
614
  },
615
  eInterfacePrototype,
616
  false,
617
  prototypes::id::AnonymousContent,
618
  PrototypeTraits<prototypes::id::AnonymousContent>::Depth,
619
  sNativePropertyHooks,
620
  "[object AnonymousContentPrototype]",
621
  JS::GetRealmObjectPrototype
622
};
623
624
bool
625
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
626
0
{
627
0
  return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
628
0
}
629
630
static const js::ClassOps sClassOps = {
631
  nullptr, /* addProperty */
632
  nullptr,               /* delProperty */
633
  nullptr,               /* enumerate */
634
  nullptr, /* newEnumerate */
635
  nullptr, /* resolve */
636
  nullptr, /* mayResolve */
637
  _finalize, /* finalize */
638
  nullptr, /* call */
639
  nullptr,               /* hasInstance */
640
  nullptr,               /* construct */
641
  nullptr, /* trace */
642
};
643
644
static const js::ClassExtension sClassExtension = {
645
  nullptr, /* weakmapKeyDelegateOp */
646
  nullptr /* objectMovedOp */
647
};
648
649
static const DOMJSClass sClass = {
650
  { "AnonymousContent",
651
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
652
    &sClassOps,
653
    JS_NULL_CLASS_SPEC,
654
    &sClassExtension,
655
    JS_NULL_OBJECT_OPS
656
  },
657
  { prototypes::id::AnonymousContent, 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 },
658
  IsBaseOf<nsISupports, mozilla::dom::AnonymousContent >::value,
659
  sNativePropertyHooks,
660
  FindAssociatedGlobalForNative<mozilla::dom::AnonymousContent>::Get,
661
  GetProtoObjectHandle,
662
  GetCCParticipant<mozilla::dom::AnonymousContent>::Get()
663
};
664
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
665
              "Must have the right minimal number of reserved slots.");
666
static_assert(1 >= 1,
667
              "Must have enough reserved slots.");
668
669
const JSClass*
670
GetJSClass()
671
0
{
672
0
  return sClass.ToJSClass();
673
0
}
674
675
bool
676
Wrap(JSContext* aCx, mozilla::dom::AnonymousContent* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
677
0
{
678
0
  MOZ_ASSERT(static_cast<mozilla::dom::AnonymousContent*>(aObject) ==
679
0
             reinterpret_cast<mozilla::dom::AnonymousContent*>(aObject),
680
0
             "Multiple inheritance for mozilla::dom::AnonymousContent is broken.");
681
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
682
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
683
0
684
0
  JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
685
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
686
0
  if (!canonicalProto) {
687
0
    return false;
688
0
  }
689
0
  JS::Rooted<JSObject*> proto(aCx);
690
0
  if (aGivenProto) {
691
0
    proto = aGivenProto;
692
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
693
0
    // coming in, we changed compartments to that of "parent" so may need
694
0
    // to wrap the proto here.
695
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
696
0
      if (!JS_WrapObject(aCx, &proto)) {
697
0
        return false;
698
0
      }
699
0
    }
700
0
  } else {
701
0
    proto = canonicalProto;
702
0
  }
703
0
704
0
  BindingJSObjectCreator<mozilla::dom::AnonymousContent> creator(aCx);
705
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
706
0
  if (!aReflector) {
707
0
    return false;
708
0
  }
709
0
710
0
711
0
712
0
  creator.InitializationSucceeded();
713
0
  return true;
714
0
}
715
716
const NativePropertyHooks sNativePropertyHooks[] = { {
717
  nullptr,
718
  nullptr,
719
  nullptr,
720
  { sNativeProperties.Upcast(), nullptr },
721
  prototypes::id::AnonymousContent,
722
  constructors::id::AnonymousContent,
723
  nullptr,
724
  &DefaultXrayExpandoObjectClass
725
} };
726
727
void
728
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
729
0
{
730
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
731
0
  if (!parentProto) {
732
0
    return;
733
0
  }
734
0
735
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
736
0
  if (!constructorProto) {
737
0
    return;
738
0
  }
739
0
740
0
  static bool sIdsInited = false;
741
0
  if (!sIdsInited && NS_IsMainThread()) {
742
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
743
0
      return;
744
0
    }
745
0
    sIdsInited = true;
746
0
  }
747
0
748
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AnonymousContent);
749
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::AnonymousContent);
750
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
751
0
                              &sPrototypeClass.mBase, protoCache,
752
0
                              nullptr,
753
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
754
0
                              interfaceCache,
755
0
                              sNativeProperties.Upcast(),
756
0
                              nullptr,
757
0
                              "AnonymousContent", aDefineOnGlobal,
758
0
                              nullptr,
759
0
                              false);
760
0
}
761
762
JSObject*
763
GetConstructorObject(JSContext* aCx)
764
0
{
765
0
  return GetConstructorObjectHandle(aCx);
766
0
}
767
768
} // namespace AnonymousContent_Binding
769
770
771
772
} // namespace dom
773
} // namespace mozilla