Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/InspectorUtilsBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM InspectorUtils.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AtomList.h"
4
#include "InspectorUtilsBinding.h"
5
#include "WrapperFactory.h"
6
#include "XrayWrapper.h"
7
#include "mozilla/BindingStyleRule.h"
8
#include "mozilla/FloatingPoint.h"
9
#include "mozilla/OwningNonNull.h"
10
#include "mozilla/StyleSheet.h"
11
#include "mozilla/StyleSheetInlines.h"
12
#include "mozilla/css/Rule.h"
13
#include "mozilla/dom/BindingUtils.h"
14
#include "mozilla/dom/CSSFontFaceRule.h"
15
#include "mozilla/dom/CharacterData.h"
16
#include "mozilla/dom/DOMJSClass.h"
17
#include "mozilla/dom/Element.h"
18
#include "mozilla/dom/InspectorFontFace.h"
19
#include "mozilla/dom/InspectorUtils.h"
20
#include "mozilla/dom/NonRefcountedDOMObject.h"
21
#include "mozilla/dom/Nullable.h"
22
#include "mozilla/dom/PrimitiveConversions.h"
23
#include "mozilla/dom/ScriptSettings.h"
24
#include "mozilla/dom/SimpleGlobalObject.h"
25
#include "mozilla/dom/XrayExpandoClass.h"
26
#include "nsContentUtils.h"
27
#include "nsIDocument.h"
28
#include "nsINode.h"
29
#include "nsINodeList.h"
30
#include "nsRange.h"
31
32
namespace mozilla {
33
namespace dom {
34
35
namespace binding_detail {}; // Just to make sure it's known as a namespace
36
using namespace mozilla::dom::binding_detail;
37
38
39
40
InspectorFontFeature::InspectorFontFeature()
41
0
{
42
0
  // Safe to pass a null context if we pass a null value
43
0
  Init(nullptr, JS::NullHandleValue);
44
0
}
45
46
47
48
bool
49
InspectorFontFeature::InitIds(JSContext* cx, InspectorFontFeatureAtoms* atomsCache)
50
0
{
51
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
52
0
53
0
  // Initialize these in reverse order so that any failure leaves the first one
54
0
  // uninitialized.
55
0
  if (!atomsCache->tag_id.init(cx, "tag") ||
56
0
      !atomsCache->script_id.init(cx, "script") ||
57
0
      !atomsCache->languageSystem_id.init(cx, "languageSystem")) {
58
0
    return false;
59
0
  }
60
0
  return true;
61
0
}
62
63
bool
64
InspectorFontFeature::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
65
0
{
66
0
  // Passing a null JSContext is OK only if we're initing from null,
67
0
  // Since in that case we will not have to do any property gets
68
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
69
0
  // checkers by static analysis tools
70
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
71
0
  InspectorFontFeatureAtoms* atomsCache = nullptr;
72
0
  if (cx) {
73
0
    atomsCache = GetAtomCache<InspectorFontFeatureAtoms>(cx);
74
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
75
0
      return false;
76
0
    }
77
0
  }
78
0
79
0
  if (!IsConvertibleToDictionary(val)) {
80
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
81
0
  }
82
0
83
0
  bool isNull = val.isNullOrUndefined();
84
0
  // We only need these if !isNull, in which case we have |cx|.
85
0
  Maybe<JS::Rooted<JSObject *> > object;
86
0
  Maybe<JS::Rooted<JS::Value> > temp;
87
0
  if (!isNull) {
88
0
    MOZ_ASSERT(cx);
89
0
    object.emplace(cx, &val.toObject());
90
0
    temp.emplace(cx);
91
0
  }
92
0
  if (!isNull) {
93
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->languageSystem_id, temp.ptr())) {
94
0
      return false;
95
0
    }
96
0
  }
97
0
  if (!isNull && !temp->isUndefined()) {
98
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mLanguageSystem)) {
99
0
      return false;
100
0
    }
101
0
    mIsAnyMemberPresent = true;
102
0
  } else if (cx) {
103
0
    // Don't error out if we have no cx.  In that
104
0
    // situation the caller is default-constructing us and we'll
105
0
    // just assume they know what they're doing.
106
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
107
0
                             "'languageSystem' member of InspectorFontFeature");
108
0
  }
109
0
110
0
  if (!isNull) {
111
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->script_id, temp.ptr())) {
112
0
      return false;
113
0
    }
114
0
  }
115
0
  if (!isNull && !temp->isUndefined()) {
116
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mScript)) {
117
0
      return false;
118
0
    }
119
0
    mIsAnyMemberPresent = true;
120
0
  } else if (cx) {
121
0
    // Don't error out if we have no cx.  In that
122
0
    // situation the caller is default-constructing us and we'll
123
0
    // just assume they know what they're doing.
124
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
125
0
                             "'script' member of InspectorFontFeature");
126
0
  }
127
0
128
0
  if (!isNull) {
129
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->tag_id, temp.ptr())) {
130
0
      return false;
131
0
    }
132
0
  }
133
0
  if (!isNull && !temp->isUndefined()) {
134
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mTag)) {
135
0
      return false;
136
0
    }
137
0
    mIsAnyMemberPresent = true;
138
0
  } else if (cx) {
139
0
    // Don't error out if we have no cx.  In that
140
0
    // situation the caller is default-constructing us and we'll
141
0
    // just assume they know what they're doing.
142
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
143
0
                             "'tag' member of InspectorFontFeature");
144
0
  }
145
0
  return true;
146
0
}
147
148
bool
149
InspectorFontFeature::Init(const nsAString& aJSON)
150
0
{
151
0
  AutoJSAPI jsapi;
152
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
153
0
  if (!cleanGlobal) {
154
0
    return false;
155
0
  }
156
0
  if (!jsapi.Init(cleanGlobal)) {
157
0
    return false;
158
0
  }
159
0
  JSContext* cx = jsapi.cx();
160
0
  JS::Rooted<JS::Value> json(cx);
161
0
  bool ok = ParseJSON(cx, aJSON, &json);
162
0
  NS_ENSURE_TRUE(ok, false);
163
0
  return Init(cx, json);
164
0
}
165
166
bool
167
InspectorFontFeature::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
168
0
{
169
0
  InspectorFontFeatureAtoms* atomsCache = GetAtomCache<InspectorFontFeatureAtoms>(cx);
170
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
171
0
    return false;
172
0
  }
173
0
174
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
175
0
  if (!obj) {
176
0
    return false;
177
0
  }
178
0
  rval.set(JS::ObjectValue(*obj));
179
0
180
0
  do {
181
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
182
0
    JS::Rooted<JS::Value> temp(cx);
183
0
    nsString const & currentValue = mLanguageSystem;
184
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
185
0
      return false;
186
0
    }
187
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->languageSystem_id, temp, JSPROP_ENUMERATE)) {
188
0
      return false;
189
0
    }
190
0
    break;
191
0
  } while(false);
192
0
193
0
  do {
194
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
195
0
    JS::Rooted<JS::Value> temp(cx);
196
0
    nsString const & currentValue = mScript;
197
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
198
0
      return false;
199
0
    }
200
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->script_id, temp, JSPROP_ENUMERATE)) {
201
0
      return false;
202
0
    }
203
0
    break;
204
0
  } while(false);
205
0
206
0
  do {
207
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
208
0
    JS::Rooted<JS::Value> temp(cx);
209
0
    nsString const & currentValue = mTag;
210
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
211
0
      return false;
212
0
    }
213
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->tag_id, temp, JSPROP_ENUMERATE)) {
214
0
      return false;
215
0
    }
216
0
    break;
217
0
  } while(false);
218
0
219
0
  return true;
220
0
}
221
222
bool
223
InspectorFontFeature::ToJSON(nsAString& aJSON) const
224
0
{
225
0
  AutoJSAPI jsapi;
226
0
  jsapi.Init();
227
0
  JSContext *cx = jsapi.cx();
228
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
229
0
  // because we'll only be creating objects, in ways that have no
230
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
231
0
  // which likewise guarantees no side-effects for the sorts of
232
0
  // things we will pass it.
233
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
234
0
  JS::Rooted<JS::Value> val(cx);
235
0
  if (!ToObjectInternal(cx, &val)) {
236
0
    return false;
237
0
  }
238
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
239
0
  return StringifyToJSON(cx, obj, aJSON);
240
0
}
241
242
void
243
InspectorFontFeature::TraceDictionary(JSTracer* trc)
244
0
{
245
0
}
246
247
InspectorFontFeature&
248
InspectorFontFeature::operator=(const InspectorFontFeature& aOther)
249
0
{
250
0
  DictionaryBase::operator=(aOther);
251
0
  mLanguageSystem = aOther.mLanguageSystem;
252
0
  mScript = aOther.mScript;
253
0
  mTag = aOther.mTag;
254
0
  return *this;
255
0
}
256
257
namespace binding_detail {
258
} // namespace binding_detail
259
260
261
262
InspectorRGBATuple::InspectorRGBATuple()
263
0
{
264
0
  // Safe to pass a null context if we pass a null value
265
0
  Init(nullptr, JS::NullHandleValue);
266
0
}
267
268
269
270
bool
271
InspectorRGBATuple::InitIds(JSContext* cx, InspectorRGBATupleAtoms* atomsCache)
272
0
{
273
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
274
0
275
0
  // Initialize these in reverse order so that any failure leaves the first one
276
0
  // uninitialized.
277
0
  if (!atomsCache->r_id.init(cx, "r") ||
278
0
      !atomsCache->g_id.init(cx, "g") ||
279
0
      !atomsCache->b_id.init(cx, "b") ||
280
0
      !atomsCache->a_id.init(cx, "a")) {
281
0
    return false;
282
0
  }
283
0
  return true;
284
0
}
285
286
bool
287
InspectorRGBATuple::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
288
0
{
289
0
  // Passing a null JSContext is OK only if we're initing from null,
290
0
  // Since in that case we will not have to do any property gets
291
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
292
0
  // checkers by static analysis tools
293
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
294
0
  InspectorRGBATupleAtoms* atomsCache = nullptr;
295
0
  if (cx) {
296
0
    atomsCache = GetAtomCache<InspectorRGBATupleAtoms>(cx);
297
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
298
0
      return false;
299
0
    }
300
0
  }
301
0
302
0
  if (!IsConvertibleToDictionary(val)) {
303
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
304
0
  }
305
0
306
0
  bool isNull = val.isNullOrUndefined();
307
0
  // We only need these if !isNull, in which case we have |cx|.
308
0
  Maybe<JS::Rooted<JSObject *> > object;
309
0
  Maybe<JS::Rooted<JS::Value> > temp;
310
0
  if (!isNull) {
311
0
    MOZ_ASSERT(cx);
312
0
    object.emplace(cx, &val.toObject());
313
0
    temp.emplace(cx);
314
0
  }
315
0
  if (!isNull) {
316
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->a_id, temp.ptr())) {
317
0
      return false;
318
0
    }
319
0
  }
320
0
  if (!isNull && !temp->isUndefined()) {
321
0
    if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mA)) {
322
0
      return false;
323
0
    } else if (!mozilla::IsFinite(mA)) {
324
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "'a' member of InspectorRGBATuple");
325
0
      return false;
326
0
    }
327
0
  } else {
328
0
    mA = 1.0;
329
0
  }
330
0
  mIsAnyMemberPresent = true;
331
0
332
0
  if (!isNull) {
333
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->b_id, temp.ptr())) {
334
0
      return false;
335
0
    }
336
0
  }
337
0
  if (!isNull && !temp->isUndefined()) {
338
0
    if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mB)) {
339
0
      return false;
340
0
    } else if (!mozilla::IsFinite(mB)) {
341
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "'b' member of InspectorRGBATuple");
342
0
      return false;
343
0
    }
344
0
  } else {
345
0
    mB = 0.0;
346
0
  }
347
0
  mIsAnyMemberPresent = true;
348
0
349
0
  if (!isNull) {
350
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->g_id, temp.ptr())) {
351
0
      return false;
352
0
    }
353
0
  }
354
0
  if (!isNull && !temp->isUndefined()) {
355
0
    if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mG)) {
356
0
      return false;
357
0
    } else if (!mozilla::IsFinite(mG)) {
358
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "'g' member of InspectorRGBATuple");
359
0
      return false;
360
0
    }
361
0
  } else {
362
0
    mG = 0.0;
363
0
  }
364
0
  mIsAnyMemberPresent = true;
365
0
366
0
  if (!isNull) {
367
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->r_id, temp.ptr())) {
368
0
      return false;
369
0
    }
370
0
  }
371
0
  if (!isNull && !temp->isUndefined()) {
372
0
    if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mR)) {
373
0
      return false;
374
0
    } else if (!mozilla::IsFinite(mR)) {
375
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "'r' member of InspectorRGBATuple");
376
0
      return false;
377
0
    }
378
0
  } else {
379
0
    mR = 0.0;
380
0
  }
381
0
  mIsAnyMemberPresent = true;
382
0
  return true;
383
0
}
384
385
bool
386
InspectorRGBATuple::Init(const nsAString& aJSON)
387
0
{
388
0
  AutoJSAPI jsapi;
389
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
390
0
  if (!cleanGlobal) {
391
0
    return false;
392
0
  }
393
0
  if (!jsapi.Init(cleanGlobal)) {
394
0
    return false;
395
0
  }
396
0
  JSContext* cx = jsapi.cx();
397
0
  JS::Rooted<JS::Value> json(cx);
398
0
  bool ok = ParseJSON(cx, aJSON, &json);
399
0
  NS_ENSURE_TRUE(ok, false);
400
0
  return Init(cx, json);
401
0
}
402
403
bool
404
InspectorRGBATuple::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
405
0
{
406
0
  InspectorRGBATupleAtoms* atomsCache = GetAtomCache<InspectorRGBATupleAtoms>(cx);
407
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
408
0
    return false;
409
0
  }
410
0
411
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
412
0
  if (!obj) {
413
0
    return false;
414
0
  }
415
0
  rval.set(JS::ObjectValue(*obj));
416
0
417
0
  do {
418
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
419
0
    JS::Rooted<JS::Value> temp(cx);
420
0
    double const & currentValue = mA;
421
0
    temp.set(JS_NumberValue(double(currentValue)));
422
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->a_id, temp, JSPROP_ENUMERATE)) {
423
0
      return false;
424
0
    }
425
0
    break;
426
0
  } while(false);
427
0
428
0
  do {
429
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
430
0
    JS::Rooted<JS::Value> temp(cx);
431
0
    double const & currentValue = mB;
432
0
    temp.set(JS_NumberValue(double(currentValue)));
433
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->b_id, temp, JSPROP_ENUMERATE)) {
434
0
      return false;
435
0
    }
436
0
    break;
437
0
  } while(false);
438
0
439
0
  do {
440
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
441
0
    JS::Rooted<JS::Value> temp(cx);
442
0
    double const & currentValue = mG;
443
0
    temp.set(JS_NumberValue(double(currentValue)));
444
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->g_id, temp, JSPROP_ENUMERATE)) {
445
0
      return false;
446
0
    }
447
0
    break;
448
0
  } while(false);
449
0
450
0
  do {
451
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
452
0
    JS::Rooted<JS::Value> temp(cx);
453
0
    double const & currentValue = mR;
454
0
    temp.set(JS_NumberValue(double(currentValue)));
455
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->r_id, temp, JSPROP_ENUMERATE)) {
456
0
      return false;
457
0
    }
458
0
    break;
459
0
  } while(false);
460
0
461
0
  return true;
462
0
}
463
464
bool
465
InspectorRGBATuple::ToJSON(nsAString& aJSON) const
466
0
{
467
0
  AutoJSAPI jsapi;
468
0
  jsapi.Init();
469
0
  JSContext *cx = jsapi.cx();
470
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
471
0
  // because we'll only be creating objects, in ways that have no
472
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
473
0
  // which likewise guarantees no side-effects for the sorts of
474
0
  // things we will pass it.
475
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
476
0
  JS::Rooted<JS::Value> val(cx);
477
0
  if (!ToObjectInternal(cx, &val)) {
478
0
    return false;
479
0
  }
480
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
481
0
  return StringifyToJSON(cx, obj, aJSON);
482
0
}
483
484
void
485
InspectorRGBATuple::TraceDictionary(JSTracer* trc)
486
0
{
487
0
}
488
489
InspectorRGBATuple&
490
InspectorRGBATuple::operator=(const InspectorRGBATuple& aOther)
491
0
{
492
0
  DictionaryBase::operator=(aOther);
493
0
  mA = aOther.mA;
494
0
  mB = aOther.mB;
495
0
  mG = aOther.mG;
496
0
  mR = aOther.mR;
497
0
  return *this;
498
0
}
499
500
namespace binding_detail {
501
} // namespace binding_detail
502
503
504
505
InspectorVariationAxis::InspectorVariationAxis()
506
0
{
507
0
  // Safe to pass a null context if we pass a null value
508
0
  Init(nullptr, JS::NullHandleValue);
509
0
}
510
511
512
513
bool
514
InspectorVariationAxis::InitIds(JSContext* cx, InspectorVariationAxisAtoms* atomsCache)
515
0
{
516
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
517
0
518
0
  // Initialize these in reverse order so that any failure leaves the first one
519
0
  // uninitialized.
520
0
  if (!atomsCache->tag_id.init(cx, "tag") ||
521
0
      !atomsCache->name_id.init(cx, "name") ||
522
0
      !atomsCache->minValue_id.init(cx, "minValue") ||
523
0
      !atomsCache->maxValue_id.init(cx, "maxValue") ||
524
0
      !atomsCache->defaultValue_id.init(cx, "defaultValue")) {
525
0
    return false;
526
0
  }
527
0
  return true;
528
0
}
529
530
bool
531
InspectorVariationAxis::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
532
0
{
533
0
  // Passing a null JSContext is OK only if we're initing from null,
534
0
  // Since in that case we will not have to do any property gets
535
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
536
0
  // checkers by static analysis tools
537
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
538
0
  InspectorVariationAxisAtoms* atomsCache = nullptr;
539
0
  if (cx) {
540
0
    atomsCache = GetAtomCache<InspectorVariationAxisAtoms>(cx);
541
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
542
0
      return false;
543
0
    }
544
0
  }
545
0
546
0
  if (!IsConvertibleToDictionary(val)) {
547
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
548
0
  }
549
0
550
0
  bool isNull = val.isNullOrUndefined();
551
0
  // We only need these if !isNull, in which case we have |cx|.
552
0
  Maybe<JS::Rooted<JSObject *> > object;
553
0
  Maybe<JS::Rooted<JS::Value> > temp;
554
0
  if (!isNull) {
555
0
    MOZ_ASSERT(cx);
556
0
    object.emplace(cx, &val.toObject());
557
0
    temp.emplace(cx);
558
0
  }
559
0
  if (!isNull) {
560
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->defaultValue_id, temp.ptr())) {
561
0
      return false;
562
0
    }
563
0
  }
564
0
  if (!isNull && !temp->isUndefined()) {
565
0
    if (!ValueToPrimitive<float, eDefault>(cx, temp.ref(), &mDefaultValue)) {
566
0
      return false;
567
0
    } else if (!mozilla::IsFinite(mDefaultValue)) {
568
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "'defaultValue' member of InspectorVariationAxis");
569
0
      return false;
570
0
    }
571
0
    mIsAnyMemberPresent = true;
572
0
  } else if (cx) {
573
0
    // Don't error out if we have no cx.  In that
574
0
    // situation the caller is default-constructing us and we'll
575
0
    // just assume they know what they're doing.
576
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
577
0
                             "'defaultValue' member of InspectorVariationAxis");
578
0
  }
579
0
580
0
  if (!isNull) {
581
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->maxValue_id, temp.ptr())) {
582
0
      return false;
583
0
    }
584
0
  }
585
0
  if (!isNull && !temp->isUndefined()) {
586
0
    if (!ValueToPrimitive<float, eDefault>(cx, temp.ref(), &mMaxValue)) {
587
0
      return false;
588
0
    } else if (!mozilla::IsFinite(mMaxValue)) {
589
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "'maxValue' member of InspectorVariationAxis");
590
0
      return false;
591
0
    }
592
0
    mIsAnyMemberPresent = true;
593
0
  } else if (cx) {
594
0
    // Don't error out if we have no cx.  In that
595
0
    // situation the caller is default-constructing us and we'll
596
0
    // just assume they know what they're doing.
597
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
598
0
                             "'maxValue' member of InspectorVariationAxis");
599
0
  }
600
0
601
0
  if (!isNull) {
602
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->minValue_id, temp.ptr())) {
603
0
      return false;
604
0
    }
605
0
  }
606
0
  if (!isNull && !temp->isUndefined()) {
607
0
    if (!ValueToPrimitive<float, eDefault>(cx, temp.ref(), &mMinValue)) {
608
0
      return false;
609
0
    } else if (!mozilla::IsFinite(mMinValue)) {
610
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "'minValue' member of InspectorVariationAxis");
611
0
      return false;
612
0
    }
613
0
    mIsAnyMemberPresent = true;
614
0
  } else if (cx) {
615
0
    // Don't error out if we have no cx.  In that
616
0
    // situation the caller is default-constructing us and we'll
617
0
    // just assume they know what they're doing.
618
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
619
0
                             "'minValue' member of InspectorVariationAxis");
620
0
  }
621
0
622
0
  if (!isNull) {
623
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->name_id, temp.ptr())) {
624
0
      return false;
625
0
    }
626
0
  }
627
0
  if (!isNull && !temp->isUndefined()) {
628
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mName)) {
629
0
      return false;
630
0
    }
631
0
    mIsAnyMemberPresent = true;
632
0
  } else if (cx) {
633
0
    // Don't error out if we have no cx.  In that
634
0
    // situation the caller is default-constructing us and we'll
635
0
    // just assume they know what they're doing.
636
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
637
0
                             "'name' member of InspectorVariationAxis");
638
0
  }
639
0
640
0
  if (!isNull) {
641
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->tag_id, temp.ptr())) {
642
0
      return false;
643
0
    }
644
0
  }
645
0
  if (!isNull && !temp->isUndefined()) {
646
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mTag)) {
647
0
      return false;
648
0
    }
649
0
    mIsAnyMemberPresent = true;
650
0
  } else if (cx) {
651
0
    // Don't error out if we have no cx.  In that
652
0
    // situation the caller is default-constructing us and we'll
653
0
    // just assume they know what they're doing.
654
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
655
0
                             "'tag' member of InspectorVariationAxis");
656
0
  }
657
0
  return true;
658
0
}
659
660
bool
661
InspectorVariationAxis::Init(const nsAString& aJSON)
662
0
{
663
0
  AutoJSAPI jsapi;
664
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
665
0
  if (!cleanGlobal) {
666
0
    return false;
667
0
  }
668
0
  if (!jsapi.Init(cleanGlobal)) {
669
0
    return false;
670
0
  }
671
0
  JSContext* cx = jsapi.cx();
672
0
  JS::Rooted<JS::Value> json(cx);
673
0
  bool ok = ParseJSON(cx, aJSON, &json);
674
0
  NS_ENSURE_TRUE(ok, false);
675
0
  return Init(cx, json);
676
0
}
677
678
bool
679
InspectorVariationAxis::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
680
0
{
681
0
  InspectorVariationAxisAtoms* atomsCache = GetAtomCache<InspectorVariationAxisAtoms>(cx);
682
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
683
0
    return false;
684
0
  }
685
0
686
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
687
0
  if (!obj) {
688
0
    return false;
689
0
  }
690
0
  rval.set(JS::ObjectValue(*obj));
691
0
692
0
  do {
693
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
694
0
    JS::Rooted<JS::Value> temp(cx);
695
0
    float const & currentValue = mDefaultValue;
696
0
    temp.set(JS_NumberValue(double(currentValue)));
697
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->defaultValue_id, temp, JSPROP_ENUMERATE)) {
698
0
      return false;
699
0
    }
700
0
    break;
701
0
  } while(false);
702
0
703
0
  do {
704
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
705
0
    JS::Rooted<JS::Value> temp(cx);
706
0
    float const & currentValue = mMaxValue;
707
0
    temp.set(JS_NumberValue(double(currentValue)));
708
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->maxValue_id, temp, JSPROP_ENUMERATE)) {
709
0
      return false;
710
0
    }
711
0
    break;
712
0
  } while(false);
713
0
714
0
  do {
715
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
716
0
    JS::Rooted<JS::Value> temp(cx);
717
0
    float const & currentValue = mMinValue;
718
0
    temp.set(JS_NumberValue(double(currentValue)));
719
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->minValue_id, temp, JSPROP_ENUMERATE)) {
720
0
      return false;
721
0
    }
722
0
    break;
723
0
  } while(false);
724
0
725
0
  do {
726
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
727
0
    JS::Rooted<JS::Value> temp(cx);
728
0
    nsString const & currentValue = mName;
729
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
730
0
      return false;
731
0
    }
732
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->name_id, temp, JSPROP_ENUMERATE)) {
733
0
      return false;
734
0
    }
735
0
    break;
736
0
  } while(false);
737
0
738
0
  do {
739
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
740
0
    JS::Rooted<JS::Value> temp(cx);
741
0
    nsString const & currentValue = mTag;
742
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
743
0
      return false;
744
0
    }
745
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->tag_id, temp, JSPROP_ENUMERATE)) {
746
0
      return false;
747
0
    }
748
0
    break;
749
0
  } while(false);
750
0
751
0
  return true;
752
0
}
753
754
bool
755
InspectorVariationAxis::ToJSON(nsAString& aJSON) const
756
0
{
757
0
  AutoJSAPI jsapi;
758
0
  jsapi.Init();
759
0
  JSContext *cx = jsapi.cx();
760
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
761
0
  // because we'll only be creating objects, in ways that have no
762
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
763
0
  // which likewise guarantees no side-effects for the sorts of
764
0
  // things we will pass it.
765
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
766
0
  JS::Rooted<JS::Value> val(cx);
767
0
  if (!ToObjectInternal(cx, &val)) {
768
0
    return false;
769
0
  }
770
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
771
0
  return StringifyToJSON(cx, obj, aJSON);
772
0
}
773
774
void
775
InspectorVariationAxis::TraceDictionary(JSTracer* trc)
776
0
{
777
0
}
778
779
InspectorVariationAxis&
780
InspectorVariationAxis::operator=(const InspectorVariationAxis& aOther)
781
0
{
782
0
  DictionaryBase::operator=(aOther);
783
0
  mDefaultValue = aOther.mDefaultValue;
784
0
  mMaxValue = aOther.mMaxValue;
785
0
  mMinValue = aOther.mMinValue;
786
0
  mName = aOther.mName;
787
0
  mTag = aOther.mTag;
788
0
  return *this;
789
0
}
790
791
namespace binding_detail {
792
} // namespace binding_detail
793
794
795
796
InspectorVariationValue::InspectorVariationValue()
797
0
{
798
0
  // Safe to pass a null context if we pass a null value
799
0
  Init(nullptr, JS::NullHandleValue);
800
0
}
801
802
803
804
bool
805
InspectorVariationValue::InitIds(JSContext* cx, InspectorVariationValueAtoms* atomsCache)
806
0
{
807
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
808
0
809
0
  // Initialize these in reverse order so that any failure leaves the first one
810
0
  // uninitialized.
811
0
  if (!atomsCache->value_id.init(cx, "value") ||
812
0
      !atomsCache->axis_id.init(cx, "axis")) {
813
0
    return false;
814
0
  }
815
0
  return true;
816
0
}
817
818
bool
819
InspectorVariationValue::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
820
0
{
821
0
  // Passing a null JSContext is OK only if we're initing from null,
822
0
  // Since in that case we will not have to do any property gets
823
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
824
0
  // checkers by static analysis tools
825
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
826
0
  InspectorVariationValueAtoms* atomsCache = nullptr;
827
0
  if (cx) {
828
0
    atomsCache = GetAtomCache<InspectorVariationValueAtoms>(cx);
829
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
830
0
      return false;
831
0
    }
832
0
  }
833
0
834
0
  if (!IsConvertibleToDictionary(val)) {
835
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
836
0
  }
837
0
838
0
  bool isNull = val.isNullOrUndefined();
839
0
  // We only need these if !isNull, in which case we have |cx|.
840
0
  Maybe<JS::Rooted<JSObject *> > object;
841
0
  Maybe<JS::Rooted<JS::Value> > temp;
842
0
  if (!isNull) {
843
0
    MOZ_ASSERT(cx);
844
0
    object.emplace(cx, &val.toObject());
845
0
    temp.emplace(cx);
846
0
  }
847
0
  if (!isNull) {
848
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->axis_id, temp.ptr())) {
849
0
      return false;
850
0
    }
851
0
  }
852
0
  if (!isNull && !temp->isUndefined()) {
853
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mAxis)) {
854
0
      return false;
855
0
    }
856
0
    mIsAnyMemberPresent = true;
857
0
  } else if (cx) {
858
0
    // Don't error out if we have no cx.  In that
859
0
    // situation the caller is default-constructing us and we'll
860
0
    // just assume they know what they're doing.
861
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
862
0
                             "'axis' member of InspectorVariationValue");
863
0
  }
864
0
865
0
  if (!isNull) {
866
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->value_id, temp.ptr())) {
867
0
      return false;
868
0
    }
869
0
  }
870
0
  if (!isNull && !temp->isUndefined()) {
871
0
    if (!ValueToPrimitive<float, eDefault>(cx, temp.ref(), &mValue)) {
872
0
      return false;
873
0
    } else if (!mozilla::IsFinite(mValue)) {
874
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "'value' member of InspectorVariationValue");
875
0
      return false;
876
0
    }
877
0
    mIsAnyMemberPresent = true;
878
0
  } else if (cx) {
879
0
    // Don't error out if we have no cx.  In that
880
0
    // situation the caller is default-constructing us and we'll
881
0
    // just assume they know what they're doing.
882
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
883
0
                             "'value' member of InspectorVariationValue");
884
0
  }
885
0
  return true;
886
0
}
887
888
bool
889
InspectorVariationValue::Init(const nsAString& aJSON)
890
0
{
891
0
  AutoJSAPI jsapi;
892
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
893
0
  if (!cleanGlobal) {
894
0
    return false;
895
0
  }
896
0
  if (!jsapi.Init(cleanGlobal)) {
897
0
    return false;
898
0
  }
899
0
  JSContext* cx = jsapi.cx();
900
0
  JS::Rooted<JS::Value> json(cx);
901
0
  bool ok = ParseJSON(cx, aJSON, &json);
902
0
  NS_ENSURE_TRUE(ok, false);
903
0
  return Init(cx, json);
904
0
}
905
906
bool
907
InspectorVariationValue::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
908
0
{
909
0
  InspectorVariationValueAtoms* atomsCache = GetAtomCache<InspectorVariationValueAtoms>(cx);
910
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
911
0
    return false;
912
0
  }
913
0
914
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
915
0
  if (!obj) {
916
0
    return false;
917
0
  }
918
0
  rval.set(JS::ObjectValue(*obj));
919
0
920
0
  do {
921
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
922
0
    JS::Rooted<JS::Value> temp(cx);
923
0
    nsString const & currentValue = mAxis;
924
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
925
0
      return false;
926
0
    }
927
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->axis_id, temp, JSPROP_ENUMERATE)) {
928
0
      return false;
929
0
    }
930
0
    break;
931
0
  } while(false);
932
0
933
0
  do {
934
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
935
0
    JS::Rooted<JS::Value> temp(cx);
936
0
    float const & currentValue = mValue;
937
0
    temp.set(JS_NumberValue(double(currentValue)));
938
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->value_id, temp, JSPROP_ENUMERATE)) {
939
0
      return false;
940
0
    }
941
0
    break;
942
0
  } while(false);
943
0
944
0
  return true;
945
0
}
946
947
bool
948
InspectorVariationValue::ToJSON(nsAString& aJSON) const
949
0
{
950
0
  AutoJSAPI jsapi;
951
0
  jsapi.Init();
952
0
  JSContext *cx = jsapi.cx();
953
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
954
0
  // because we'll only be creating objects, in ways that have no
955
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
956
0
  // which likewise guarantees no side-effects for the sorts of
957
0
  // things we will pass it.
958
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
959
0
  JS::Rooted<JS::Value> val(cx);
960
0
  if (!ToObjectInternal(cx, &val)) {
961
0
    return false;
962
0
  }
963
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
964
0
  return StringifyToJSON(cx, obj, aJSON);
965
0
}
966
967
void
968
InspectorVariationValue::TraceDictionary(JSTracer* trc)
969
0
{
970
0
}
971
972
InspectorVariationValue&
973
InspectorVariationValue::operator=(const InspectorVariationValue& aOther)
974
0
{
975
0
  DictionaryBase::operator=(aOther);
976
0
  mAxis = aOther.mAxis;
977
0
  mValue = aOther.mValue;
978
0
  return *this;
979
0
}
980
981
namespace binding_detail {
982
} // namespace binding_detail
983
984
985
986
PropertyNamesOptions::PropertyNamesOptions()
987
0
{
988
0
  // Safe to pass a null context if we pass a null value
989
0
  Init(nullptr, JS::NullHandleValue);
990
0
}
991
992
993
994
bool
995
PropertyNamesOptions::InitIds(JSContext* cx, PropertyNamesOptionsAtoms* atomsCache)
996
0
{
997
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
998
0
999
0
  // Initialize these in reverse order so that any failure leaves the first one
1000
0
  // uninitialized.
1001
0
  if (!atomsCache->includeShorthands_id.init(cx, "includeShorthands") ||
1002
0
      !atomsCache->includeExperimentals_id.init(cx, "includeExperimentals") ||
1003
0
      !atomsCache->includeAliases_id.init(cx, "includeAliases")) {
1004
0
    return false;
1005
0
  }
1006
0
  return true;
1007
0
}
1008
1009
bool
1010
PropertyNamesOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
1011
0
{
1012
0
  // Passing a null JSContext is OK only if we're initing from null,
1013
0
  // Since in that case we will not have to do any property gets
1014
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
1015
0
  // checkers by static analysis tools
1016
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
1017
0
  PropertyNamesOptionsAtoms* atomsCache = nullptr;
1018
0
  if (cx) {
1019
0
    atomsCache = GetAtomCache<PropertyNamesOptionsAtoms>(cx);
1020
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
1021
0
      return false;
1022
0
    }
1023
0
  }
1024
0
1025
0
  if (!IsConvertibleToDictionary(val)) {
1026
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
1027
0
  }
1028
0
1029
0
  bool isNull = val.isNullOrUndefined();
1030
0
  // We only need these if !isNull, in which case we have |cx|.
1031
0
  Maybe<JS::Rooted<JSObject *> > object;
1032
0
  Maybe<JS::Rooted<JS::Value> > temp;
1033
0
  if (!isNull) {
1034
0
    MOZ_ASSERT(cx);
1035
0
    object.emplace(cx, &val.toObject());
1036
0
    temp.emplace(cx);
1037
0
  }
1038
0
  if (!isNull) {
1039
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->includeAliases_id, temp.ptr())) {
1040
0
      return false;
1041
0
    }
1042
0
  }
1043
0
  if (!isNull && !temp->isUndefined()) {
1044
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mIncludeAliases)) {
1045
0
      return false;
1046
0
    }
1047
0
  } else {
1048
0
    mIncludeAliases = false;
1049
0
  }
1050
0
  mIsAnyMemberPresent = true;
1051
0
1052
0
  if (!isNull) {
1053
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->includeExperimentals_id, temp.ptr())) {
1054
0
      return false;
1055
0
    }
1056
0
  }
1057
0
  if (!isNull && !temp->isUndefined()) {
1058
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mIncludeExperimentals)) {
1059
0
      return false;
1060
0
    }
1061
0
  } else {
1062
0
    mIncludeExperimentals = false;
1063
0
  }
1064
0
  mIsAnyMemberPresent = true;
1065
0
1066
0
  if (!isNull) {
1067
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->includeShorthands_id, temp.ptr())) {
1068
0
      return false;
1069
0
    }
1070
0
  }
1071
0
  if (!isNull && !temp->isUndefined()) {
1072
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mIncludeShorthands)) {
1073
0
      return false;
1074
0
    }
1075
0
  } else {
1076
0
    mIncludeShorthands = true;
1077
0
  }
1078
0
  mIsAnyMemberPresent = true;
1079
0
  return true;
1080
0
}
1081
1082
bool
1083
PropertyNamesOptions::Init(const nsAString& aJSON)
1084
0
{
1085
0
  AutoJSAPI jsapi;
1086
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
1087
0
  if (!cleanGlobal) {
1088
0
    return false;
1089
0
  }
1090
0
  if (!jsapi.Init(cleanGlobal)) {
1091
0
    return false;
1092
0
  }
1093
0
  JSContext* cx = jsapi.cx();
1094
0
  JS::Rooted<JS::Value> json(cx);
1095
0
  bool ok = ParseJSON(cx, aJSON, &json);
1096
0
  NS_ENSURE_TRUE(ok, false);
1097
0
  return Init(cx, json);
1098
0
}
1099
1100
bool
1101
PropertyNamesOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
1102
0
{
1103
0
  PropertyNamesOptionsAtoms* atomsCache = GetAtomCache<PropertyNamesOptionsAtoms>(cx);
1104
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
1105
0
    return false;
1106
0
  }
1107
0
1108
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
1109
0
  if (!obj) {
1110
0
    return false;
1111
0
  }
1112
0
  rval.set(JS::ObjectValue(*obj));
1113
0
1114
0
  do {
1115
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1116
0
    JS::Rooted<JS::Value> temp(cx);
1117
0
    bool const & currentValue = mIncludeAliases;
1118
0
    temp.setBoolean(currentValue);
1119
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->includeAliases_id, temp, JSPROP_ENUMERATE)) {
1120
0
      return false;
1121
0
    }
1122
0
    break;
1123
0
  } while(false);
1124
0
1125
0
  do {
1126
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1127
0
    JS::Rooted<JS::Value> temp(cx);
1128
0
    bool const & currentValue = mIncludeExperimentals;
1129
0
    temp.setBoolean(currentValue);
1130
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->includeExperimentals_id, temp, JSPROP_ENUMERATE)) {
1131
0
      return false;
1132
0
    }
1133
0
    break;
1134
0
  } while(false);
1135
0
1136
0
  do {
1137
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1138
0
    JS::Rooted<JS::Value> temp(cx);
1139
0
    bool const & currentValue = mIncludeShorthands;
1140
0
    temp.setBoolean(currentValue);
1141
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->includeShorthands_id, temp, JSPROP_ENUMERATE)) {
1142
0
      return false;
1143
0
    }
1144
0
    break;
1145
0
  } while(false);
1146
0
1147
0
  return true;
1148
0
}
1149
1150
bool
1151
PropertyNamesOptions::ToJSON(nsAString& aJSON) const
1152
0
{
1153
0
  AutoJSAPI jsapi;
1154
0
  jsapi.Init();
1155
0
  JSContext *cx = jsapi.cx();
1156
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
1157
0
  // because we'll only be creating objects, in ways that have no
1158
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
1159
0
  // which likewise guarantees no side-effects for the sorts of
1160
0
  // things we will pass it.
1161
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
1162
0
  JS::Rooted<JS::Value> val(cx);
1163
0
  if (!ToObjectInternal(cx, &val)) {
1164
0
    return false;
1165
0
  }
1166
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
1167
0
  return StringifyToJSON(cx, obj, aJSON);
1168
0
}
1169
1170
void
1171
PropertyNamesOptions::TraceDictionary(JSTracer* trc)
1172
0
{
1173
0
}
1174
1175
PropertyNamesOptions&
1176
PropertyNamesOptions::operator=(const PropertyNamesOptions& aOther)
1177
0
{
1178
0
  DictionaryBase::operator=(aOther);
1179
0
  mIncludeAliases = aOther.mIncludeAliases;
1180
0
  mIncludeExperimentals = aOther.mIncludeExperimentals;
1181
0
  mIncludeShorthands = aOther.mIncludeShorthands;
1182
0
  return *this;
1183
0
}
1184
1185
namespace binding_detail {
1186
} // namespace binding_detail
1187
1188
1189
1190
PropertyPref::PropertyPref()
1191
0
{
1192
0
  // Safe to pass a null context if we pass a null value
1193
0
  Init(nullptr, JS::NullHandleValue);
1194
0
}
1195
1196
1197
1198
bool
1199
PropertyPref::InitIds(JSContext* cx, PropertyPrefAtoms* atomsCache)
1200
0
{
1201
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
1202
0
1203
0
  // Initialize these in reverse order so that any failure leaves the first one
1204
0
  // uninitialized.
1205
0
  if (!atomsCache->pref_id.init(cx, "pref") ||
1206
0
      !atomsCache->name_id.init(cx, "name")) {
1207
0
    return false;
1208
0
  }
1209
0
  return true;
1210
0
}
1211
1212
bool
1213
PropertyPref::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
1214
0
{
1215
0
  // Passing a null JSContext is OK only if we're initing from null,
1216
0
  // Since in that case we will not have to do any property gets
1217
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
1218
0
  // checkers by static analysis tools
1219
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
1220
0
  PropertyPrefAtoms* atomsCache = nullptr;
1221
0
  if (cx) {
1222
0
    atomsCache = GetAtomCache<PropertyPrefAtoms>(cx);
1223
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
1224
0
      return false;
1225
0
    }
1226
0
  }
1227
0
1228
0
  if (!IsConvertibleToDictionary(val)) {
1229
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
1230
0
  }
1231
0
1232
0
  bool isNull = val.isNullOrUndefined();
1233
0
  // We only need these if !isNull, in which case we have |cx|.
1234
0
  Maybe<JS::Rooted<JSObject *> > object;
1235
0
  Maybe<JS::Rooted<JS::Value> > temp;
1236
0
  if (!isNull) {
1237
0
    MOZ_ASSERT(cx);
1238
0
    object.emplace(cx, &val.toObject());
1239
0
    temp.emplace(cx);
1240
0
  }
1241
0
  if (!isNull) {
1242
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->name_id, temp.ptr())) {
1243
0
      return false;
1244
0
    }
1245
0
  }
1246
0
  if (!isNull && !temp->isUndefined()) {
1247
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mName)) {
1248
0
      return false;
1249
0
    }
1250
0
    mIsAnyMemberPresent = true;
1251
0
  } else if (cx) {
1252
0
    // Don't error out if we have no cx.  In that
1253
0
    // situation the caller is default-constructing us and we'll
1254
0
    // just assume they know what they're doing.
1255
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
1256
0
                             "'name' member of PropertyPref");
1257
0
  }
1258
0
1259
0
  if (!isNull) {
1260
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->pref_id, temp.ptr())) {
1261
0
      return false;
1262
0
    }
1263
0
  }
1264
0
  if (!isNull && !temp->isUndefined()) {
1265
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mPref)) {
1266
0
      return false;
1267
0
    }
1268
0
    mIsAnyMemberPresent = true;
1269
0
  } else if (cx) {
1270
0
    // Don't error out if we have no cx.  In that
1271
0
    // situation the caller is default-constructing us and we'll
1272
0
    // just assume they know what they're doing.
1273
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
1274
0
                             "'pref' member of PropertyPref");
1275
0
  }
1276
0
  return true;
1277
0
}
1278
1279
bool
1280
PropertyPref::Init(const nsAString& aJSON)
1281
0
{
1282
0
  AutoJSAPI jsapi;
1283
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
1284
0
  if (!cleanGlobal) {
1285
0
    return false;
1286
0
  }
1287
0
  if (!jsapi.Init(cleanGlobal)) {
1288
0
    return false;
1289
0
  }
1290
0
  JSContext* cx = jsapi.cx();
1291
0
  JS::Rooted<JS::Value> json(cx);
1292
0
  bool ok = ParseJSON(cx, aJSON, &json);
1293
0
  NS_ENSURE_TRUE(ok, false);
1294
0
  return Init(cx, json);
1295
0
}
1296
1297
bool
1298
PropertyPref::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
1299
0
{
1300
0
  PropertyPrefAtoms* atomsCache = GetAtomCache<PropertyPrefAtoms>(cx);
1301
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
1302
0
    return false;
1303
0
  }
1304
0
1305
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
1306
0
  if (!obj) {
1307
0
    return false;
1308
0
  }
1309
0
  rval.set(JS::ObjectValue(*obj));
1310
0
1311
0
  do {
1312
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1313
0
    JS::Rooted<JS::Value> temp(cx);
1314
0
    nsString const & currentValue = mName;
1315
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
1316
0
      return false;
1317
0
    }
1318
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->name_id, temp, JSPROP_ENUMERATE)) {
1319
0
      return false;
1320
0
    }
1321
0
    break;
1322
0
  } while(false);
1323
0
1324
0
  do {
1325
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1326
0
    JS::Rooted<JS::Value> temp(cx);
1327
0
    nsString const & currentValue = mPref;
1328
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
1329
0
      return false;
1330
0
    }
1331
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->pref_id, temp, JSPROP_ENUMERATE)) {
1332
0
      return false;
1333
0
    }
1334
0
    break;
1335
0
  } while(false);
1336
0
1337
0
  return true;
1338
0
}
1339
1340
bool
1341
PropertyPref::ToJSON(nsAString& aJSON) const
1342
0
{
1343
0
  AutoJSAPI jsapi;
1344
0
  jsapi.Init();
1345
0
  JSContext *cx = jsapi.cx();
1346
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
1347
0
  // because we'll only be creating objects, in ways that have no
1348
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
1349
0
  // which likewise guarantees no side-effects for the sorts of
1350
0
  // things we will pass it.
1351
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
1352
0
  JS::Rooted<JS::Value> val(cx);
1353
0
  if (!ToObjectInternal(cx, &val)) {
1354
0
    return false;
1355
0
  }
1356
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
1357
0
  return StringifyToJSON(cx, obj, aJSON);
1358
0
}
1359
1360
void
1361
PropertyPref::TraceDictionary(JSTracer* trc)
1362
0
{
1363
0
}
1364
1365
PropertyPref&
1366
PropertyPref::operator=(const PropertyPref& aOther)
1367
0
{
1368
0
  DictionaryBase::operator=(aOther);
1369
0
  mName = aOther.mName;
1370
0
  mPref = aOther.mPref;
1371
0
  return *this;
1372
0
}
1373
1374
namespace binding_detail {
1375
} // namespace binding_detail
1376
1377
1378
1379
InspectorVariationInstance::InspectorVariationInstance()
1380
0
{
1381
0
  // Safe to pass a null context if we pass a null value
1382
0
  Init(nullptr, JS::NullHandleValue);
1383
0
}
1384
1385
1386
1387
bool
1388
InspectorVariationInstance::InitIds(JSContext* cx, InspectorVariationInstanceAtoms* atomsCache)
1389
0
{
1390
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
1391
0
1392
0
  // Initialize these in reverse order so that any failure leaves the first one
1393
0
  // uninitialized.
1394
0
  if (!atomsCache->values_id.init(cx, "values") ||
1395
0
      !atomsCache->name_id.init(cx, "name")) {
1396
0
    return false;
1397
0
  }
1398
0
  return true;
1399
0
}
1400
1401
bool
1402
InspectorVariationInstance::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
1403
0
{
1404
0
  // Passing a null JSContext is OK only if we're initing from null,
1405
0
  // Since in that case we will not have to do any property gets
1406
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
1407
0
  // checkers by static analysis tools
1408
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
1409
0
  InspectorVariationInstanceAtoms* atomsCache = nullptr;
1410
0
  if (cx) {
1411
0
    atomsCache = GetAtomCache<InspectorVariationInstanceAtoms>(cx);
1412
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
1413
0
      return false;
1414
0
    }
1415
0
  }
1416
0
1417
0
  if (!IsConvertibleToDictionary(val)) {
1418
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
1419
0
  }
1420
0
1421
0
  bool isNull = val.isNullOrUndefined();
1422
0
  // We only need these if !isNull, in which case we have |cx|.
1423
0
  Maybe<JS::Rooted<JSObject *> > object;
1424
0
  Maybe<JS::Rooted<JS::Value> > temp;
1425
0
  if (!isNull) {
1426
0
    MOZ_ASSERT(cx);
1427
0
    object.emplace(cx, &val.toObject());
1428
0
    temp.emplace(cx);
1429
0
  }
1430
0
  if (!isNull) {
1431
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->name_id, temp.ptr())) {
1432
0
      return false;
1433
0
    }
1434
0
  }
1435
0
  if (!isNull && !temp->isUndefined()) {
1436
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mName)) {
1437
0
      return false;
1438
0
    }
1439
0
    mIsAnyMemberPresent = true;
1440
0
  } else if (cx) {
1441
0
    // Don't error out if we have no cx.  In that
1442
0
    // situation the caller is default-constructing us and we'll
1443
0
    // just assume they know what they're doing.
1444
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
1445
0
                             "'name' member of InspectorVariationInstance");
1446
0
  }
1447
0
1448
0
  if (!isNull) {
1449
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->values_id, temp.ptr())) {
1450
0
      return false;
1451
0
    }
1452
0
  }
1453
0
  if (!isNull && !temp->isUndefined()) {
1454
0
    if (temp.ref().isObject()) {
1455
0
      JS::ForOfIterator iter(cx);
1456
0
      if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
1457
0
        return false;
1458
0
      }
1459
0
      if (!iter.valueIsIterable()) {
1460
0
        ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'values' member of InspectorVariationInstance");
1461
0
        return false;
1462
0
      }
1463
0
      Sequence<InspectorVariationValue> &arr = mValues;
1464
0
      JS::Rooted<JS::Value> temp(cx);
1465
0
      while (true) {
1466
0
        bool done;
1467
0
        if (!iter.next(&temp, &done)) {
1468
0
          return false;
1469
0
        }
1470
0
        if (done) {
1471
0
          break;
1472
0
        }
1473
0
        InspectorVariationValue* slotPtr = arr.AppendElement(mozilla::fallible);
1474
0
        if (!slotPtr) {
1475
0
          JS_ReportOutOfMemory(cx);
1476
0
          return false;
1477
0
        }
1478
0
        InspectorVariationValue& slot = *slotPtr;
1479
0
        if (!slot.Init(cx, temp,  "Element of 'values' member of InspectorVariationInstance", passedToJSImpl)) {
1480
0
          return false;
1481
0
        }
1482
0
      }
1483
0
    } else {
1484
0
      ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'values' member of InspectorVariationInstance");
1485
0
      return false;
1486
0
    }
1487
0
    mIsAnyMemberPresent = true;
1488
0
  } else if (cx) {
1489
0
    // Don't error out if we have no cx.  In that
1490
0
    // situation the caller is default-constructing us and we'll
1491
0
    // just assume they know what they're doing.
1492
0
    return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
1493
0
                             "'values' member of InspectorVariationInstance");
1494
0
  }
1495
0
  return true;
1496
0
}
1497
1498
bool
1499
InspectorVariationInstance::Init(const nsAString& aJSON)
1500
0
{
1501
0
  AutoJSAPI jsapi;
1502
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
1503
0
  if (!cleanGlobal) {
1504
0
    return false;
1505
0
  }
1506
0
  if (!jsapi.Init(cleanGlobal)) {
1507
0
    return false;
1508
0
  }
1509
0
  JSContext* cx = jsapi.cx();
1510
0
  JS::Rooted<JS::Value> json(cx);
1511
0
  bool ok = ParseJSON(cx, aJSON, &json);
1512
0
  NS_ENSURE_TRUE(ok, false);
1513
0
  return Init(cx, json);
1514
0
}
1515
1516
bool
1517
InspectorVariationInstance::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
1518
0
{
1519
0
  InspectorVariationInstanceAtoms* atomsCache = GetAtomCache<InspectorVariationInstanceAtoms>(cx);
1520
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
1521
0
    return false;
1522
0
  }
1523
0
1524
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
1525
0
  if (!obj) {
1526
0
    return false;
1527
0
  }
1528
0
  rval.set(JS::ObjectValue(*obj));
1529
0
1530
0
  do {
1531
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1532
0
    JS::Rooted<JS::Value> temp(cx);
1533
0
    nsString const & currentValue = mName;
1534
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
1535
0
      return false;
1536
0
    }
1537
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->name_id, temp, JSPROP_ENUMERATE)) {
1538
0
      return false;
1539
0
    }
1540
0
    break;
1541
0
  } while(false);
1542
0
1543
0
  do {
1544
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1545
0
    JS::Rooted<JS::Value> temp(cx);
1546
0
    Sequence<InspectorVariationValue> const & currentValue = mValues;
1547
0
1548
0
    uint32_t length = currentValue.Length();
1549
0
    JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
1550
0
    if (!returnArray) {
1551
0
      return false;
1552
0
    }
1553
0
    // Scope for 'tmp'
1554
0
    {
1555
0
      JS::Rooted<JS::Value> tmp(cx);
1556
0
      for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
1557
0
        // Control block to let us common up the JS_DefineElement calls when there
1558
0
        // are different ways to succeed at wrapping the object.
1559
0
        do {
1560
0
          if (!currentValue[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
1561
0
            return false;
1562
0
          }
1563
0
          break;
1564
0
        } while (false);
1565
0
        if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
1566
0
                              JSPROP_ENUMERATE)) {
1567
0
          return false;
1568
0
        }
1569
0
      }
1570
0
    }
1571
0
    temp.setObject(*returnArray);
1572
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->values_id, temp, JSPROP_ENUMERATE)) {
1573
0
      return false;
1574
0
    }
1575
0
    break;
1576
0
  } while(false);
1577
0
1578
0
  return true;
1579
0
}
1580
1581
bool
1582
InspectorVariationInstance::ToJSON(nsAString& aJSON) const
1583
0
{
1584
0
  AutoJSAPI jsapi;
1585
0
  jsapi.Init();
1586
0
  JSContext *cx = jsapi.cx();
1587
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
1588
0
  // because we'll only be creating objects, in ways that have no
1589
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
1590
0
  // which likewise guarantees no side-effects for the sorts of
1591
0
  // things we will pass it.
1592
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
1593
0
  JS::Rooted<JS::Value> val(cx);
1594
0
  if (!ToObjectInternal(cx, &val)) {
1595
0
    return false;
1596
0
  }
1597
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
1598
0
  return StringifyToJSON(cx, obj, aJSON);
1599
0
}
1600
1601
void
1602
InspectorVariationInstance::TraceDictionary(JSTracer* trc)
1603
0
{
1604
0
}
1605
1606
InspectorVariationInstance&
1607
InspectorVariationInstance::operator=(const InspectorVariationInstance& aOther)
1608
0
{
1609
0
  DictionaryBase::operator=(aOther);
1610
0
  mName = aOther.mName;
1611
0
  mValues = aOther.mValues;
1612
0
  return *this;
1613
0
}
1614
1615
namespace binding_detail {
1616
} // namespace binding_detail
1617
1618
1619
namespace InspectorFontFace_Binding {
1620
1621
MOZ_CAN_RUN_SCRIPT static bool
1622
get_fromFontGroup(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::InspectorFontFace* self, JSJitGetterCallArgs args)
1623
0
{
1624
0
  AUTO_PROFILER_LABEL_FAST("get InspectorFontFace.fromFontGroup", DOM, cx);
1625
0
1626
0
  bool result(self->FromFontGroup());
1627
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1628
0
  args.rval().setBoolean(result);
1629
0
  return true;
1630
0
}
1631
1632
static const JSJitInfo fromFontGroup_getterinfo = {
1633
  { (JSJitGetterOp)get_fromFontGroup },
1634
  { prototypes::id::InspectorFontFace },
1635
  { PrototypeTraits<prototypes::id::InspectorFontFace>::Depth },
1636
  JSJitInfo::Getter,
1637
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1638
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1639
  true,  /* isInfallible. False in setters. */
1640
  false,  /* isMovable.  Not relevant for setters. */
1641
  false, /* isEliminatable.  Not relevant for setters. */
1642
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1643
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1644
  false,  /* isTypedMethod.  Only relevant for methods. */
1645
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1646
};
1647
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1648
static_assert(0 < 2, "There is no slot for us");
1649
1650
MOZ_CAN_RUN_SCRIPT static bool
1651
get_fromLanguagePrefs(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::InspectorFontFace* self, JSJitGetterCallArgs args)
1652
0
{
1653
0
  AUTO_PROFILER_LABEL_FAST("get InspectorFontFace.fromLanguagePrefs", DOM, cx);
1654
0
1655
0
  bool result(self->FromLanguagePrefs());
1656
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1657
0
  args.rval().setBoolean(result);
1658
0
  return true;
1659
0
}
1660
1661
static const JSJitInfo fromLanguagePrefs_getterinfo = {
1662
  { (JSJitGetterOp)get_fromLanguagePrefs },
1663
  { prototypes::id::InspectorFontFace },
1664
  { PrototypeTraits<prototypes::id::InspectorFontFace>::Depth },
1665
  JSJitInfo::Getter,
1666
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1667
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1668
  true,  /* isInfallible. False in setters. */
1669
  false,  /* isMovable.  Not relevant for setters. */
1670
  false, /* isEliminatable.  Not relevant for setters. */
1671
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1672
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1673
  false,  /* isTypedMethod.  Only relevant for methods. */
1674
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1675
};
1676
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1677
static_assert(0 < 2, "There is no slot for us");
1678
1679
MOZ_CAN_RUN_SCRIPT static bool
1680
get_fromSystemFallback(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::InspectorFontFace* self, JSJitGetterCallArgs args)
1681
0
{
1682
0
  AUTO_PROFILER_LABEL_FAST("get InspectorFontFace.fromSystemFallback", DOM, cx);
1683
0
1684
0
  bool result(self->FromSystemFallback());
1685
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1686
0
  args.rval().setBoolean(result);
1687
0
  return true;
1688
0
}
1689
1690
static const JSJitInfo fromSystemFallback_getterinfo = {
1691
  { (JSJitGetterOp)get_fromSystemFallback },
1692
  { prototypes::id::InspectorFontFace },
1693
  { PrototypeTraits<prototypes::id::InspectorFontFace>::Depth },
1694
  JSJitInfo::Getter,
1695
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1696
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1697
  true,  /* isInfallible. False in setters. */
1698
  false,  /* isMovable.  Not relevant for setters. */
1699
  false, /* isEliminatable.  Not relevant for setters. */
1700
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1701
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1702
  false,  /* isTypedMethod.  Only relevant for methods. */
1703
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1704
};
1705
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1706
static_assert(0 < 2, "There is no slot for us");
1707
1708
MOZ_CAN_RUN_SCRIPT static bool
1709
get_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::InspectorFontFace* self, JSJitGetterCallArgs args)
1710
0
{
1711
0
  AUTO_PROFILER_LABEL_FAST("get InspectorFontFace.name", DOM, cx);
1712
0
1713
0
  DOMString result;
1714
0
  self->GetName(result);
1715
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1716
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1717
0
    return false;
1718
0
  }
1719
0
  return true;
1720
0
}
1721
1722
static const JSJitInfo name_getterinfo = {
1723
  { (JSJitGetterOp)get_name },
1724
  { prototypes::id::InspectorFontFace },
1725
  { PrototypeTraits<prototypes::id::InspectorFontFace>::Depth },
1726
  JSJitInfo::Getter,
1727
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1728
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
1729
  false,  /* isInfallible. False in setters. */
1730
  false,  /* isMovable.  Not relevant for setters. */
1731
  false, /* isEliminatable.  Not relevant for setters. */
1732
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1733
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1734
  false,  /* isTypedMethod.  Only relevant for methods. */
1735
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1736
};
1737
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1738
static_assert(0 < 2, "There is no slot for us");
1739
1740
MOZ_CAN_RUN_SCRIPT static bool
1741
get_CSSFamilyName(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::InspectorFontFace* self, JSJitGetterCallArgs args)
1742
0
{
1743
0
  AUTO_PROFILER_LABEL_FAST("get InspectorFontFace.CSSFamilyName", DOM, cx);
1744
0
1745
0
  DOMString result;
1746
0
  self->GetCSSFamilyName(result);
1747
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1748
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1749
0
    return false;
1750
0
  }
1751
0
  return true;
1752
0
}
1753
1754
static const JSJitInfo CSSFamilyName_getterinfo = {
1755
  { (JSJitGetterOp)get_CSSFamilyName },
1756
  { prototypes::id::InspectorFontFace },
1757
  { PrototypeTraits<prototypes::id::InspectorFontFace>::Depth },
1758
  JSJitInfo::Getter,
1759
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1760
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
1761
  false,  /* isInfallible. False in setters. */
1762
  false,  /* isMovable.  Not relevant for setters. */
1763
  false, /* isEliminatable.  Not relevant for setters. */
1764
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1765
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1766
  false,  /* isTypedMethod.  Only relevant for methods. */
1767
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1768
};
1769
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1770
static_assert(0 < 2, "There is no slot for us");
1771
1772
MOZ_CAN_RUN_SCRIPT static bool
1773
get_CSSGeneric(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::InspectorFontFace* self, JSJitGetterCallArgs args)
1774
0
{
1775
0
  AUTO_PROFILER_LABEL_FAST("get InspectorFontFace.CSSGeneric", DOM, cx);
1776
0
1777
0
  DOMString result;
1778
0
  self->GetCSSGeneric(result);
1779
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1780
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1781
0
    return false;
1782
0
  }
1783
0
  return true;
1784
0
}
1785
1786
static const JSJitInfo CSSGeneric_getterinfo = {
1787
  { (JSJitGetterOp)get_CSSGeneric },
1788
  { prototypes::id::InspectorFontFace },
1789
  { PrototypeTraits<prototypes::id::InspectorFontFace>::Depth },
1790
  JSJitInfo::Getter,
1791
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1792
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
1793
  false,  /* isInfallible. False in setters. */
1794
  false,  /* isMovable.  Not relevant for setters. */
1795
  false, /* isEliminatable.  Not relevant for setters. */
1796
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1797
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1798
  false,  /* isTypedMethod.  Only relevant for methods. */
1799
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1800
};
1801
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1802
static_assert(0 < 2, "There is no slot for us");
1803
1804
MOZ_CAN_RUN_SCRIPT static bool
1805
getVariationAxes(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::InspectorFontFace* self, const JSJitMethodCallArgs& args)
1806
0
{
1807
0
  AUTO_PROFILER_LABEL_FAST("InspectorFontFace.getVariationAxes", DOM, cx);
1808
0
1809
0
  FastErrorResult rv;
1810
0
  nsTArray<InspectorVariationAxis> result;
1811
0
  self->GetVariationAxes(result, rv);
1812
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1813
0
    return false;
1814
0
  }
1815
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1816
0
1817
0
  uint32_t length = result.Length();
1818
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
1819
0
  if (!returnArray) {
1820
0
    return false;
1821
0
  }
1822
0
  // Scope for 'tmp'
1823
0
  {
1824
0
    JS::Rooted<JS::Value> tmp(cx);
1825
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
1826
0
      // Control block to let us common up the JS_DefineElement calls when there
1827
0
      // are different ways to succeed at wrapping the object.
1828
0
      do {
1829
0
        if (!result[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
1830
0
          return false;
1831
0
        }
1832
0
        break;
1833
0
      } while (false);
1834
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
1835
0
                            JSPROP_ENUMERATE)) {
1836
0
        return false;
1837
0
      }
1838
0
    }
1839
0
  }
1840
0
  args.rval().setObject(*returnArray);
1841
0
  return true;
1842
0
}
1843
1844
static const JSJitInfo getVariationAxes_methodinfo = {
1845
  { (JSJitGetterOp)getVariationAxes },
1846
  { prototypes::id::InspectorFontFace },
1847
  { PrototypeTraits<prototypes::id::InspectorFontFace>::Depth },
1848
  JSJitInfo::Method,
1849
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1850
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1851
  false,  /* isInfallible. False in setters. */
1852
  false,  /* isMovable.  Not relevant for setters. */
1853
  false, /* isEliminatable.  Not relevant for setters. */
1854
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1855
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1856
  false,  /* isTypedMethod.  Only relevant for methods. */
1857
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1858
};
1859
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1860
static_assert(0 < 2, "There is no slot for us");
1861
1862
MOZ_CAN_RUN_SCRIPT static bool
1863
getVariationInstances(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::InspectorFontFace* self, const JSJitMethodCallArgs& args)
1864
0
{
1865
0
  AUTO_PROFILER_LABEL_FAST("InspectorFontFace.getVariationInstances", DOM, cx);
1866
0
1867
0
  FastErrorResult rv;
1868
0
  nsTArray<InspectorVariationInstance> result;
1869
0
  self->GetVariationInstances(result, rv);
1870
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1871
0
    return false;
1872
0
  }
1873
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1874
0
1875
0
  uint32_t length = result.Length();
1876
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
1877
0
  if (!returnArray) {
1878
0
    return false;
1879
0
  }
1880
0
  // Scope for 'tmp'
1881
0
  {
1882
0
    JS::Rooted<JS::Value> tmp(cx);
1883
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
1884
0
      // Control block to let us common up the JS_DefineElement calls when there
1885
0
      // are different ways to succeed at wrapping the object.
1886
0
      do {
1887
0
        if (!result[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
1888
0
          return false;
1889
0
        }
1890
0
        break;
1891
0
      } while (false);
1892
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
1893
0
                            JSPROP_ENUMERATE)) {
1894
0
        return false;
1895
0
      }
1896
0
    }
1897
0
  }
1898
0
  args.rval().setObject(*returnArray);
1899
0
  return true;
1900
0
}
1901
1902
static const JSJitInfo getVariationInstances_methodinfo = {
1903
  { (JSJitGetterOp)getVariationInstances },
1904
  { prototypes::id::InspectorFontFace },
1905
  { PrototypeTraits<prototypes::id::InspectorFontFace>::Depth },
1906
  JSJitInfo::Method,
1907
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1908
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1909
  false,  /* isInfallible. False in setters. */
1910
  false,  /* isMovable.  Not relevant for setters. */
1911
  false, /* isEliminatable.  Not relevant for setters. */
1912
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1913
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1914
  false,  /* isTypedMethod.  Only relevant for methods. */
1915
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1916
};
1917
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1918
static_assert(0 < 2, "There is no slot for us");
1919
1920
MOZ_CAN_RUN_SCRIPT static bool
1921
getFeatures(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::InspectorFontFace* self, const JSJitMethodCallArgs& args)
1922
0
{
1923
0
  AUTO_PROFILER_LABEL_FAST("InspectorFontFace.getFeatures", DOM, cx);
1924
0
1925
0
  FastErrorResult rv;
1926
0
  nsTArray<InspectorFontFeature> result;
1927
0
  self->GetFeatures(result, rv);
1928
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1929
0
    return false;
1930
0
  }
1931
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1932
0
1933
0
  uint32_t length = result.Length();
1934
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
1935
0
  if (!returnArray) {
1936
0
    return false;
1937
0
  }
1938
0
  // Scope for 'tmp'
1939
0
  {
1940
0
    JS::Rooted<JS::Value> tmp(cx);
1941
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
1942
0
      // Control block to let us common up the JS_DefineElement calls when there
1943
0
      // are different ways to succeed at wrapping the object.
1944
0
      do {
1945
0
        if (!result[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
1946
0
          return false;
1947
0
        }
1948
0
        break;
1949
0
      } while (false);
1950
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
1951
0
                            JSPROP_ENUMERATE)) {
1952
0
        return false;
1953
0
      }
1954
0
    }
1955
0
  }
1956
0
  args.rval().setObject(*returnArray);
1957
0
  return true;
1958
0
}
1959
1960
static const JSJitInfo getFeatures_methodinfo = {
1961
  { (JSJitGetterOp)getFeatures },
1962
  { prototypes::id::InspectorFontFace },
1963
  { PrototypeTraits<prototypes::id::InspectorFontFace>::Depth },
1964
  JSJitInfo::Method,
1965
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1966
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1967
  false,  /* isInfallible. False in setters. */
1968
  false,  /* isMovable.  Not relevant for setters. */
1969
  false, /* isEliminatable.  Not relevant for setters. */
1970
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1971
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1972
  false,  /* isTypedMethod.  Only relevant for methods. */
1973
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1974
};
1975
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1976
static_assert(0 < 2, "There is no slot for us");
1977
1978
MOZ_CAN_RUN_SCRIPT static bool
1979
get_ranges(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::InspectorFontFace* self, JSJitGetterCallArgs args)
1980
0
{
1981
0
  AUTO_PROFILER_LABEL_FAST("get InspectorFontFace.ranges", DOM, cx);
1982
0
1983
0
  // Have to either root across the getter call or reget after.
1984
0
  bool isXray;
1985
0
  JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
1986
0
  if (!slotStorage) {
1987
0
    return false;
1988
0
  }
1989
0
  const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 0) : (DOM_INSTANCE_RESERVED_SLOTS + 0);
1990
0
  MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
1991
0
  {
1992
0
    // Scope for cachedVal
1993
0
    JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
1994
0
    if (!cachedVal.isUndefined()) {
1995
0
      args.rval().set(cachedVal);
1996
0
      // The cached value is in the compartment of slotStorage,
1997
0
      // so wrap into the caller compartment as needed.
1998
0
      if (MaybeWrapNonDOMObjectValue(cx, args.rval())) {
1999
0
        return true;
2000
0
      }
2001
0
      return false;
2002
0
    }
2003
0
  }
2004
0
2005
0
  nsTArray<StrongPtrForMember<nsRange>::Type> result;
2006
0
  self->GetRanges(result);
2007
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2008
0
  {
2009
0
    JS::Rooted<JSObject*> conversionScope(cx, isXray ? JS::CurrentGlobalOrNull(cx) : slotStorage);
2010
0
    JSAutoRealm ar(cx, conversionScope);
2011
0
    do { // block we break out of when done wrapping
2012
0
2013
0
      uint32_t length = result.Length();
2014
0
      JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
2015
0
      if (!returnArray) {
2016
0
        return false;
2017
0
      }
2018
0
      // Scope for 'tmp'
2019
0
      {
2020
0
        JS::Rooted<JS::Value> tmp(cx);
2021
0
        for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
2022
0
          // Control block to let us common up the JS_DefineElement calls when there
2023
0
          // are different ways to succeed at wrapping the object.
2024
0
          do {
2025
0
            if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) {
2026
0
              MOZ_ASSERT(JS_IsExceptionPending(cx));
2027
0
              return false;
2028
0
            }
2029
0
            break;
2030
0
          } while (false);
2031
0
          if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
2032
0
                                JSPROP_ENUMERATE)) {
2033
0
            return false;
2034
0
          }
2035
0
        }
2036
0
      }
2037
0
      args.rval().setObject(*returnArray);
2038
0
      break;
2039
0
    } while (false);
2040
0
  }
2041
0
  { // And now store things in the realm of our slotStorage.
2042
0
    JSAutoRealm ar(cx, slotStorage);
2043
0
    // Make a copy so that we don't do unnecessary wrapping on args.rval().
2044
0
    JS::Rooted<JS::Value> storedVal(cx, args.rval());
2045
0
    if (!MaybeWrapNonDOMObjectValue(cx, &storedVal)) {
2046
0
      return false;
2047
0
    }
2048
0
    js::SetReservedSlot(slotStorage, slotIndex, storedVal);
2049
0
  }
2050
0
  // And now make sure args.rval() is in the caller realm.
2051
0
  if (MaybeWrapNonDOMObjectValue(cx, args.rval())) {
2052
0
    return true;
2053
0
  }
2054
0
  return false;
2055
0
}
2056
2057
static const JSJitInfo ranges_getterinfo = {
2058
  { (JSJitGetterOp)get_ranges },
2059
  { prototypes::id::InspectorFontFace },
2060
  { PrototypeTraits<prototypes::id::InspectorFontFace>::Depth },
2061
  JSJitInfo::Getter,
2062
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
2063
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
2064
  false,  /* isInfallible. False in setters. */
2065
  true,  /* isMovable.  Not relevant for setters. */
2066
  true, /* isEliminatable.  Not relevant for setters. */
2067
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2068
  true, /* isLazilyCachedInSlot.  Only relevant for getters. */
2069
  false,  /* isTypedMethod.  Only relevant for methods. */
2070
  (DOM_INSTANCE_RESERVED_SLOTS + 0)   /* Reserved slot index, if we're stored in a slot, else 0. */
2071
};
2072
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) <= JSJitInfo::maxSlotIndex, "We won't fit");
2073
static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) < 2, "There is no slot for us");
2074
2075
MOZ_CAN_RUN_SCRIPT static bool
2076
get_rule(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::InspectorFontFace* self, JSJitGetterCallArgs args)
2077
0
{
2078
0
  AUTO_PROFILER_LABEL_FAST("get InspectorFontFace.rule", DOM, cx);
2079
0
2080
0
  auto result(StrongOrRawPtr<mozilla::dom::CSSFontFaceRule>(self->GetRule()));
2081
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2082
0
  if (!result) {
2083
0
    args.rval().setNull();
2084
0
    return true;
2085
0
  }
2086
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
2087
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
2088
0
    return false;
2089
0
  }
2090
0
  return true;
2091
0
}
2092
2093
static const JSJitInfo rule_getterinfo = {
2094
  { (JSJitGetterOp)get_rule },
2095
  { prototypes::id::InspectorFontFace },
2096
  { PrototypeTraits<prototypes::id::InspectorFontFace>::Depth },
2097
  JSJitInfo::Getter,
2098
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2099
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
2100
  false,  /* isInfallible. False in setters. */
2101
  false,  /* isMovable.  Not relevant for setters. */
2102
  false, /* isEliminatable.  Not relevant for setters. */
2103
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2104
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2105
  false,  /* isTypedMethod.  Only relevant for methods. */
2106
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2107
};
2108
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2109
static_assert(0 < 2, "There is no slot for us");
2110
2111
MOZ_CAN_RUN_SCRIPT static bool
2112
get_srcIndex(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::InspectorFontFace* self, JSJitGetterCallArgs args)
2113
0
{
2114
0
  AUTO_PROFILER_LABEL_FAST("get InspectorFontFace.srcIndex", DOM, cx);
2115
0
2116
0
  int32_t result(self->SrcIndex());
2117
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2118
0
  args.rval().setInt32(int32_t(result));
2119
0
  return true;
2120
0
}
2121
2122
static const JSJitInfo srcIndex_getterinfo = {
2123
  { (JSJitGetterOp)get_srcIndex },
2124
  { prototypes::id::InspectorFontFace },
2125
  { PrototypeTraits<prototypes::id::InspectorFontFace>::Depth },
2126
  JSJitInfo::Getter,
2127
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2128
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
2129
  true,  /* isInfallible. False in setters. */
2130
  false,  /* isMovable.  Not relevant for setters. */
2131
  false, /* isEliminatable.  Not relevant for setters. */
2132
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2133
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2134
  false,  /* isTypedMethod.  Only relevant for methods. */
2135
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2136
};
2137
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2138
static_assert(0 < 2, "There is no slot for us");
2139
2140
MOZ_CAN_RUN_SCRIPT static bool
2141
get_URI(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::InspectorFontFace* self, JSJitGetterCallArgs args)
2142
0
{
2143
0
  AUTO_PROFILER_LABEL_FAST("get InspectorFontFace.URI", DOM, cx);
2144
0
2145
0
  DOMString result;
2146
0
  self->GetURI(result);
2147
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2148
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
2149
0
    return false;
2150
0
  }
2151
0
  return true;
2152
0
}
2153
2154
static const JSJitInfo URI_getterinfo = {
2155
  { (JSJitGetterOp)get_URI },
2156
  { prototypes::id::InspectorFontFace },
2157
  { PrototypeTraits<prototypes::id::InspectorFontFace>::Depth },
2158
  JSJitInfo::Getter,
2159
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2160
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2161
  false,  /* isInfallible. False in setters. */
2162
  false,  /* isMovable.  Not relevant for setters. */
2163
  false, /* isEliminatable.  Not relevant for setters. */
2164
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2165
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2166
  false,  /* isTypedMethod.  Only relevant for methods. */
2167
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2168
};
2169
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2170
static_assert(0 < 2, "There is no slot for us");
2171
2172
MOZ_CAN_RUN_SCRIPT static bool
2173
get_localName(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::InspectorFontFace* self, JSJitGetterCallArgs args)
2174
0
{
2175
0
  AUTO_PROFILER_LABEL_FAST("get InspectorFontFace.localName", DOM, cx);
2176
0
2177
0
  DOMString result;
2178
0
  self->GetLocalName(result);
2179
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2180
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
2181
0
    return false;
2182
0
  }
2183
0
  return true;
2184
0
}
2185
2186
static const JSJitInfo localName_getterinfo = {
2187
  { (JSJitGetterOp)get_localName },
2188
  { prototypes::id::InspectorFontFace },
2189
  { PrototypeTraits<prototypes::id::InspectorFontFace>::Depth },
2190
  JSJitInfo::Getter,
2191
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2192
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2193
  false,  /* isInfallible. False in setters. */
2194
  false,  /* isMovable.  Not relevant for setters. */
2195
  false, /* isEliminatable.  Not relevant for setters. */
2196
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2197
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2198
  false,  /* isTypedMethod.  Only relevant for methods. */
2199
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2200
};
2201
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2202
static_assert(0 < 2, "There is no slot for us");
2203
2204
MOZ_CAN_RUN_SCRIPT static bool
2205
get_format(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::InspectorFontFace* self, JSJitGetterCallArgs args)
2206
0
{
2207
0
  AUTO_PROFILER_LABEL_FAST("get InspectorFontFace.format", DOM, cx);
2208
0
2209
0
  DOMString result;
2210
0
  self->GetFormat(result);
2211
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2212
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
2213
0
    return false;
2214
0
  }
2215
0
  return true;
2216
0
}
2217
2218
static const JSJitInfo format_getterinfo = {
2219
  { (JSJitGetterOp)get_format },
2220
  { prototypes::id::InspectorFontFace },
2221
  { PrototypeTraits<prototypes::id::InspectorFontFace>::Depth },
2222
  JSJitInfo::Getter,
2223
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2224
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2225
  false,  /* isInfallible. False in setters. */
2226
  false,  /* isMovable.  Not relevant for setters. */
2227
  false, /* isEliminatable.  Not relevant for setters. */
2228
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2229
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2230
  false,  /* isTypedMethod.  Only relevant for methods. */
2231
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2232
};
2233
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2234
static_assert(0 < 2, "There is no slot for us");
2235
2236
MOZ_CAN_RUN_SCRIPT static bool
2237
get_metadata(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::InspectorFontFace* self, JSJitGetterCallArgs args)
2238
0
{
2239
0
  AUTO_PROFILER_LABEL_FAST("get InspectorFontFace.metadata", DOM, cx);
2240
0
2241
0
  DOMString result;
2242
0
  self->GetMetadata(result);
2243
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2244
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
2245
0
    return false;
2246
0
  }
2247
0
  return true;
2248
0
}
2249
2250
static const JSJitInfo metadata_getterinfo = {
2251
  { (JSJitGetterOp)get_metadata },
2252
  { prototypes::id::InspectorFontFace },
2253
  { PrototypeTraits<prototypes::id::InspectorFontFace>::Depth },
2254
  JSJitInfo::Getter,
2255
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2256
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2257
  false,  /* isInfallible. False in setters. */
2258
  false,  /* isMovable.  Not relevant for setters. */
2259
  false, /* isEliminatable.  Not relevant for setters. */
2260
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2261
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2262
  false,  /* isTypedMethod.  Only relevant for methods. */
2263
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2264
};
2265
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2266
static_assert(0 < 2, "There is no slot for us");
2267
2268
static void
2269
_finalize(js::FreeOp* fop, JSObject* obj)
2270
0
{
2271
0
  mozilla::dom::InspectorFontFace* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::InspectorFontFace>(obj);
2272
0
  if (self) {
2273
0
    AddForDeferredFinalization<mozilla::dom::InspectorFontFace>(self);
2274
0
  }
2275
0
}
2276
2277
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
2278
#if defined(__clang__)
2279
#pragma clang diagnostic push
2280
#pragma clang diagnostic ignored "-Wmissing-braces"
2281
#endif
2282
static const JSFunctionSpec sMethods_specs[] = {
2283
  JS_FNSPEC("getVariationAxes", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getVariationAxes_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
2284
  JS_FNSPEC("getVariationInstances", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getVariationInstances_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
2285
  JS_FNSPEC("getFeatures", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getFeatures_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
2286
  JS_FS_END
2287
};
2288
#if defined(__clang__)
2289
#pragma clang diagnostic pop
2290
#endif
2291
2292
2293
static const Prefable<const JSFunctionSpec> sMethods[] = {
2294
  { nullptr, &sMethods_specs[0] },
2295
  { nullptr, nullptr }
2296
};
2297
2298
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
2299
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
2300
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
2301
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
2302
2303
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
2304
#if defined(__clang__)
2305
#pragma clang diagnostic push
2306
#pragma clang diagnostic ignored "-Wmissing-braces"
2307
#endif
2308
static const JSPropertySpec sAttributes_specs[] = {
2309
  { "fromFontGroup", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &fromFontGroup_getterinfo, nullptr, nullptr },
2310
  { "fromLanguagePrefs", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &fromLanguagePrefs_getterinfo, nullptr, nullptr },
2311
  { "fromSystemFallback", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &fromSystemFallback_getterinfo, nullptr, nullptr },
2312
  { "name", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &name_getterinfo, nullptr, nullptr },
2313
  { "CSSFamilyName", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &CSSFamilyName_getterinfo, nullptr, nullptr },
2314
  { "CSSGeneric", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &CSSGeneric_getterinfo, nullptr, nullptr },
2315
  { "ranges", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &ranges_getterinfo, nullptr, nullptr },
2316
  { "rule", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &rule_getterinfo, nullptr, nullptr },
2317
  { "srcIndex", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &srcIndex_getterinfo, nullptr, nullptr },
2318
  { "URI", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &URI_getterinfo, nullptr, nullptr },
2319
  { "localName", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &localName_getterinfo, nullptr, nullptr },
2320
  { "format", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &format_getterinfo, nullptr, nullptr },
2321
  { "metadata", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &metadata_getterinfo, nullptr, nullptr },
2322
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
2323
};
2324
#if defined(__clang__)
2325
#pragma clang diagnostic pop
2326
#endif
2327
2328
2329
static const Prefable<const JSPropertySpec> sAttributes[] = {
2330
  { nullptr, &sAttributes_specs[0] },
2331
  { nullptr, nullptr }
2332
};
2333
2334
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
2335
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
2336
static_assert(13 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
2337
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
2338
2339
2340
static uint16_t sNativeProperties_sortedPropertyIndices[16];
2341
static PropertyInfo sNativeProperties_propertyInfos[16];
2342
2343
static const NativePropertiesN<2> sNativeProperties = {
2344
  false, 0,
2345
  false, 0,
2346
  true,  0 /* sMethods */,
2347
  true,  1 /* sAttributes */,
2348
  false, 0,
2349
  false, 0,
2350
  false, 0,
2351
  -1,
2352
  16,
2353
  sNativeProperties_sortedPropertyIndices,
2354
  {
2355
    { sMethods, &sNativeProperties_propertyInfos[0] },
2356
    { sAttributes, &sNativeProperties_propertyInfos[3] }
2357
  }
2358
};
2359
static_assert(16 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
2360
    "We have a property info count that is oversized");
2361
2362
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
2363
  {
2364
    "Function",
2365
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
2366
    &sBoringInterfaceObjectClassClassOps,
2367
    JS_NULL_CLASS_SPEC,
2368
    JS_NULL_CLASS_EXT,
2369
    &sInterfaceObjectClassObjectOps
2370
  },
2371
  eInterface,
2372
  true,
2373
  prototypes::id::InspectorFontFace,
2374
  PrototypeTraits<prototypes::id::InspectorFontFace>::Depth,
2375
  sNativePropertyHooks,
2376
  "function InspectorFontFace() {\n    [native code]\n}",
2377
  JS::GetRealmFunctionPrototype
2378
};
2379
2380
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
2381
  {
2382
    "InspectorFontFacePrototype",
2383
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
2384
    JS_NULL_CLASS_OPS,
2385
    JS_NULL_CLASS_SPEC,
2386
    JS_NULL_CLASS_EXT,
2387
    JS_NULL_OBJECT_OPS
2388
  },
2389
  eInterfacePrototype,
2390
  false,
2391
  prototypes::id::InspectorFontFace,
2392
  PrototypeTraits<prototypes::id::InspectorFontFace>::Depth,
2393
  sNativePropertyHooks,
2394
  "[object InspectorFontFacePrototype]",
2395
  JS::GetRealmObjectPrototype
2396
};
2397
2398
bool
2399
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
2400
0
{
2401
0
  return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
2402
0
}
2403
2404
static const js::ClassOps sClassOps = {
2405
  nullptr, /* addProperty */
2406
  nullptr,               /* delProperty */
2407
  nullptr,               /* enumerate */
2408
  nullptr, /* newEnumerate */
2409
  nullptr, /* resolve */
2410
  nullptr, /* mayResolve */
2411
  _finalize, /* finalize */
2412
  nullptr, /* call */
2413
  nullptr,               /* hasInstance */
2414
  nullptr,               /* construct */
2415
  nullptr, /* trace */
2416
};
2417
2418
static const js::ClassExtension sClassExtension = {
2419
  nullptr, /* weakmapKeyDelegateOp */
2420
  nullptr /* objectMovedOp */
2421
};
2422
2423
static const DOMJSClass sClass = {
2424
  { "InspectorFontFace",
2425
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(2),
2426
    &sClassOps,
2427
    JS_NULL_CLASS_SPEC,
2428
    &sClassExtension,
2429
    JS_NULL_OBJECT_OPS
2430
  },
2431
  { prototypes::id::InspectorFontFace, 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 },
2432
  IsBaseOf<nsISupports, mozilla::dom::InspectorFontFace >::value,
2433
  sNativePropertyHooks,
2434
  FindAssociatedGlobalForNative<mozilla::dom::InspectorFontFace>::Get,
2435
  GetProtoObjectHandle,
2436
  GetCCParticipant<mozilla::dom::InspectorFontFace>::Get()
2437
};
2438
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
2439
              "Must have the right minimal number of reserved slots.");
2440
static_assert(2 >= 2,
2441
              "Must have enough reserved slots.");
2442
2443
const JSClass*
2444
GetJSClass()
2445
0
{
2446
0
  return sClass.ToJSClass();
2447
0
}
2448
2449
bool
2450
Wrap(JSContext* aCx, mozilla::dom::InspectorFontFace* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
2451
0
{
2452
0
  MOZ_ASSERT(static_cast<mozilla::dom::InspectorFontFace*>(aObject) ==
2453
0
             reinterpret_cast<mozilla::dom::InspectorFontFace*>(aObject),
2454
0
             "Multiple inheritance for mozilla::dom::InspectorFontFace is broken.");
2455
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
2456
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
2457
0
2458
0
  JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
2459
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
2460
0
  if (!canonicalProto) {
2461
0
    return false;
2462
0
  }
2463
0
  JS::Rooted<JSObject*> proto(aCx);
2464
0
  if (aGivenProto) {
2465
0
    proto = aGivenProto;
2466
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
2467
0
    // coming in, we changed compartments to that of "parent" so may need
2468
0
    // to wrap the proto here.
2469
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
2470
0
      if (!JS_WrapObject(aCx, &proto)) {
2471
0
        return false;
2472
0
      }
2473
0
    }
2474
0
  } else {
2475
0
    proto = canonicalProto;
2476
0
  }
2477
0
2478
0
  BindingJSObjectCreator<mozilla::dom::InspectorFontFace> creator(aCx);
2479
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
2480
0
  if (!aReflector) {
2481
0
    return false;
2482
0
  }
2483
0
2484
0
2485
0
2486
0
  creator.InitializationSucceeded();
2487
0
  return true;
2488
0
}
2489
2490
// This may allocate too many slots, because we only really need
2491
// slots for our non-interface-typed members that we cache.  But
2492
// allocating slots only for those would make the slot index
2493
// computations much more complicated, so let's do this the simple
2494
// way for now.
2495
DEFINE_XRAY_EXPANDO_CLASS(static, sXrayExpandoObjectClass, 1);
2496
2497
const NativePropertyHooks sNativePropertyHooks[] = { {
2498
  nullptr,
2499
  nullptr,
2500
  nullptr,
2501
  { sNativeProperties.Upcast(), nullptr },
2502
  prototypes::id::InspectorFontFace,
2503
  constructors::id::InspectorFontFace,
2504
  nullptr,
2505
  &sXrayExpandoObjectClass
2506
} };
2507
2508
void
2509
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
2510
0
{
2511
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
2512
0
  if (!parentProto) {
2513
0
    return;
2514
0
  }
2515
0
2516
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
2517
0
  if (!constructorProto) {
2518
0
    return;
2519
0
  }
2520
0
2521
0
  static bool sIdsInited = false;
2522
0
  if (!sIdsInited && NS_IsMainThread()) {
2523
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
2524
0
      return;
2525
0
    }
2526
0
    sIdsInited = true;
2527
0
  }
2528
0
2529
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::InspectorFontFace);
2530
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::InspectorFontFace);
2531
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
2532
0
                              &sPrototypeClass.mBase, protoCache,
2533
0
                              nullptr,
2534
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
2535
0
                              interfaceCache,
2536
0
                              sNativeProperties.Upcast(),
2537
0
                              nullptr,
2538
0
                              "InspectorFontFace", aDefineOnGlobal,
2539
0
                              nullptr,
2540
0
                              false);
2541
0
}
2542
2543
JSObject*
2544
GetConstructorObject(JSContext* aCx)
2545
0
{
2546
0
  return GetConstructorObjectHandle(aCx);
2547
0
}
2548
2549
} // namespace InspectorFontFace_Binding
2550
2551
2552
2553
namespace InspectorUtils_Binding {
2554
2555
static bool
2556
getAllStyleSheets(JSContext* cx, unsigned argc, JS::Value* vp)
2557
0
{
2558
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.getAllStyleSheets", DOM, cx);
2559
0
2560
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
2561
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
2562
0
2563
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
2564
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.getAllStyleSheets");
2565
0
  }
2566
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
2567
0
  if (global.Failed()) {
2568
0
    return false;
2569
0
  }
2570
0
2571
0
  NonNull<nsIDocument> arg0;
2572
0
  if (args[0].isObject()) {
2573
0
    {
2574
0
      nsresult rv = UnwrapObject<prototypes::id::Document, nsIDocument>(args[0], arg0);
2575
0
      if (NS_FAILED(rv)) {
2576
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.getAllStyleSheets", "Document");
2577
0
        return false;
2578
0
      }
2579
0
    }
2580
0
  } else {
2581
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.getAllStyleSheets");
2582
0
    return false;
2583
0
  }
2584
0
  bool arg1;
2585
0
  if (args.hasDefined(1)) {
2586
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
2587
0
      return false;
2588
0
    }
2589
0
  } else {
2590
0
    arg1 = false;
2591
0
  }
2592
0
  nsTArray<StrongPtrForMember<mozilla::StyleSheet>::Type> result;
2593
0
  mozilla::dom::InspectorUtils::GetAllStyleSheets(global, MOZ_KnownLive(NonNullHelper(arg0)), arg1, result);
2594
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2595
0
2596
0
  uint32_t length = result.Length();
2597
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
2598
0
  if (!returnArray) {
2599
0
    return false;
2600
0
  }
2601
0
  // Scope for 'tmp'
2602
0
  {
2603
0
    JS::Rooted<JS::Value> tmp(cx);
2604
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
2605
0
      // Control block to let us common up the JS_DefineElement calls when there
2606
0
      // are different ways to succeed at wrapping the object.
2607
0
      do {
2608
0
        if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) {
2609
0
          MOZ_ASSERT(JS_IsExceptionPending(cx));
2610
0
          return false;
2611
0
        }
2612
0
        break;
2613
0
      } while (false);
2614
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
2615
0
                            JSPROP_ENUMERATE)) {
2616
0
        return false;
2617
0
      }
2618
0
    }
2619
0
  }
2620
0
  args.rval().setObject(*returnArray);
2621
0
  return true;
2622
0
}
2623
2624
static bool
2625
getCSSStyleRules(JSContext* cx, unsigned argc, JS::Value* vp)
2626
0
{
2627
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.getCSSStyleRules", DOM, cx);
2628
0
2629
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
2630
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
2631
0
2632
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
2633
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.getCSSStyleRules");
2634
0
  }
2635
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
2636
0
  if (global.Failed()) {
2637
0
    return false;
2638
0
  }
2639
0
2640
0
  NonNull<mozilla::dom::Element> arg0;
2641
0
  if (args[0].isObject()) {
2642
0
    {
2643
0
      nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
2644
0
      if (NS_FAILED(rv)) {
2645
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.getCSSStyleRules", "Element");
2646
0
        return false;
2647
0
      }
2648
0
    }
2649
0
  } else {
2650
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.getCSSStyleRules");
2651
0
    return false;
2652
0
  }
2653
0
  binding_detail::FakeString arg1;
2654
0
  if (args.hasDefined(1)) {
2655
0
    if (!ConvertJSValueToString(cx, args[1], eEmpty, eStringify, arg1)) {
2656
0
      return false;
2657
0
    }
2658
0
  } else {
2659
0
    static const char16_t data[] = { 0 };
2660
0
    arg1.Rebind(data, ArrayLength(data) - 1);
2661
0
  }
2662
0
  nsTArray<StrongPtrForMember<mozilla::css::Rule>::Type> result;
2663
0
  mozilla::dom::InspectorUtils::GetCSSStyleRules(global, MOZ_KnownLive(NonNullHelper(arg0)), NonNullHelper(Constify(arg1)), result);
2664
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2665
0
2666
0
  uint32_t length = result.Length();
2667
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
2668
0
  if (!returnArray) {
2669
0
    return false;
2670
0
  }
2671
0
  // Scope for 'tmp'
2672
0
  {
2673
0
    JS::Rooted<JS::Value> tmp(cx);
2674
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
2675
0
      // Control block to let us common up the JS_DefineElement calls when there
2676
0
      // are different ways to succeed at wrapping the object.
2677
0
      do {
2678
0
        if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) {
2679
0
          MOZ_ASSERT(JS_IsExceptionPending(cx));
2680
0
          return false;
2681
0
        }
2682
0
        break;
2683
0
      } while (false);
2684
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
2685
0
                            JSPROP_ENUMERATE)) {
2686
0
        return false;
2687
0
      }
2688
0
    }
2689
0
  }
2690
0
  args.rval().setObject(*returnArray);
2691
0
  return true;
2692
0
}
2693
2694
static bool
2695
getRuleLine(JSContext* cx, unsigned argc, JS::Value* vp)
2696
0
{
2697
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.getRuleLine", DOM, cx);
2698
0
2699
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
2700
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
2701
0
2702
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
2703
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.getRuleLine");
2704
0
  }
2705
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
2706
0
  if (global.Failed()) {
2707
0
    return false;
2708
0
  }
2709
0
2710
0
  NonNull<mozilla::css::Rule> arg0;
2711
0
  if (args[0].isObject()) {
2712
0
    {
2713
0
      nsresult rv = UnwrapObject<prototypes::id::CSSRule, mozilla::css::Rule>(args[0], arg0);
2714
0
      if (NS_FAILED(rv)) {
2715
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.getRuleLine", "CSSRule");
2716
0
        return false;
2717
0
      }
2718
0
    }
2719
0
  } else {
2720
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.getRuleLine");
2721
0
    return false;
2722
0
  }
2723
0
  uint32_t result(mozilla::dom::InspectorUtils::GetRuleLine(global, MOZ_KnownLive(NonNullHelper(arg0))));
2724
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2725
0
  args.rval().setNumber(result);
2726
0
  return true;
2727
0
}
2728
2729
static bool
2730
getRuleColumn(JSContext* cx, unsigned argc, JS::Value* vp)
2731
0
{
2732
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.getRuleColumn", DOM, cx);
2733
0
2734
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
2735
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
2736
0
2737
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
2738
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.getRuleColumn");
2739
0
  }
2740
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
2741
0
  if (global.Failed()) {
2742
0
    return false;
2743
0
  }
2744
0
2745
0
  NonNull<mozilla::css::Rule> arg0;
2746
0
  if (args[0].isObject()) {
2747
0
    {
2748
0
      nsresult rv = UnwrapObject<prototypes::id::CSSRule, mozilla::css::Rule>(args[0], arg0);
2749
0
      if (NS_FAILED(rv)) {
2750
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.getRuleColumn", "CSSRule");
2751
0
        return false;
2752
0
      }
2753
0
    }
2754
0
  } else {
2755
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.getRuleColumn");
2756
0
    return false;
2757
0
  }
2758
0
  uint32_t result(mozilla::dom::InspectorUtils::GetRuleColumn(global, MOZ_KnownLive(NonNullHelper(arg0))));
2759
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2760
0
  args.rval().setNumber(result);
2761
0
  return true;
2762
0
}
2763
2764
static bool
2765
getRelativeRuleLine(JSContext* cx, unsigned argc, JS::Value* vp)
2766
0
{
2767
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.getRelativeRuleLine", DOM, cx);
2768
0
2769
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
2770
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
2771
0
2772
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
2773
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.getRelativeRuleLine");
2774
0
  }
2775
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
2776
0
  if (global.Failed()) {
2777
0
    return false;
2778
0
  }
2779
0
2780
0
  NonNull<mozilla::css::Rule> arg0;
2781
0
  if (args[0].isObject()) {
2782
0
    {
2783
0
      nsresult rv = UnwrapObject<prototypes::id::CSSRule, mozilla::css::Rule>(args[0], arg0);
2784
0
      if (NS_FAILED(rv)) {
2785
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.getRelativeRuleLine", "CSSRule");
2786
0
        return false;
2787
0
      }
2788
0
    }
2789
0
  } else {
2790
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.getRelativeRuleLine");
2791
0
    return false;
2792
0
  }
2793
0
  uint32_t result(mozilla::dom::InspectorUtils::GetRelativeRuleLine(global, MOZ_KnownLive(NonNullHelper(arg0))));
2794
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2795
0
  args.rval().setNumber(result);
2796
0
  return true;
2797
0
}
2798
2799
static bool
2800
hasRulesModifiedByCSSOM(JSContext* cx, unsigned argc, JS::Value* vp)
2801
0
{
2802
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.hasRulesModifiedByCSSOM", DOM, cx);
2803
0
2804
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
2805
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
2806
0
2807
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
2808
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.hasRulesModifiedByCSSOM");
2809
0
  }
2810
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
2811
0
  if (global.Failed()) {
2812
0
    return false;
2813
0
  }
2814
0
2815
0
  NonNull<mozilla::StyleSheet> arg0;
2816
0
  if (args[0].isObject()) {
2817
0
    {
2818
0
      nsresult rv = UnwrapObject<prototypes::id::CSSStyleSheet, mozilla::StyleSheet>(args[0], arg0);
2819
0
      if (NS_FAILED(rv)) {
2820
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.hasRulesModifiedByCSSOM", "CSSStyleSheet");
2821
0
        return false;
2822
0
      }
2823
0
    }
2824
0
  } else {
2825
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.hasRulesModifiedByCSSOM");
2826
0
    return false;
2827
0
  }
2828
0
  bool result(mozilla::dom::InspectorUtils::HasRulesModifiedByCSSOM(global, MOZ_KnownLive(NonNullHelper(arg0))));
2829
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2830
0
  args.rval().setBoolean(result);
2831
0
  return true;
2832
0
}
2833
2834
static bool
2835
getSelectorCount(JSContext* cx, unsigned argc, JS::Value* vp)
2836
0
{
2837
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.getSelectorCount", DOM, cx);
2838
0
2839
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
2840
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
2841
0
2842
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
2843
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.getSelectorCount");
2844
0
  }
2845
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
2846
0
  if (global.Failed()) {
2847
0
    return false;
2848
0
  }
2849
0
2850
0
  NonNull<mozilla::BindingStyleRule> arg0;
2851
0
  if (args[0].isObject()) {
2852
0
    {
2853
0
      nsresult rv = UnwrapObject<prototypes::id::CSSStyleRule, mozilla::BindingStyleRule>(args[0], arg0);
2854
0
      if (NS_FAILED(rv)) {
2855
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.getSelectorCount", "CSSStyleRule");
2856
0
        return false;
2857
0
      }
2858
0
    }
2859
0
  } else {
2860
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.getSelectorCount");
2861
0
    return false;
2862
0
  }
2863
0
  uint32_t result(mozilla::dom::InspectorUtils::GetSelectorCount(global, MOZ_KnownLive(NonNullHelper(arg0))));
2864
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2865
0
  args.rval().setNumber(result);
2866
0
  return true;
2867
0
}
2868
2869
static bool
2870
getSelectorText(JSContext* cx, unsigned argc, JS::Value* vp)
2871
0
{
2872
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.getSelectorText", DOM, cx);
2873
0
2874
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
2875
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
2876
0
2877
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
2878
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.getSelectorText");
2879
0
  }
2880
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
2881
0
  if (global.Failed()) {
2882
0
    return false;
2883
0
  }
2884
0
2885
0
  NonNull<mozilla::BindingStyleRule> arg0;
2886
0
  if (args[0].isObject()) {
2887
0
    {
2888
0
      nsresult rv = UnwrapObject<prototypes::id::CSSStyleRule, mozilla::BindingStyleRule>(args[0], arg0);
2889
0
      if (NS_FAILED(rv)) {
2890
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.getSelectorText", "CSSStyleRule");
2891
0
        return false;
2892
0
      }
2893
0
    }
2894
0
  } else {
2895
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.getSelectorText");
2896
0
    return false;
2897
0
  }
2898
0
  uint32_t arg1;
2899
0
  if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
2900
0
    return false;
2901
0
  }
2902
0
  FastErrorResult rv;
2903
0
  DOMString result;
2904
0
  mozilla::dom::InspectorUtils::GetSelectorText(global, MOZ_KnownLive(NonNullHelper(arg0)), arg1, result, rv);
2905
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2906
0
    return false;
2907
0
  }
2908
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2909
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
2910
0
    return false;
2911
0
  }
2912
0
  return true;
2913
0
}
2914
2915
static bool
2916
getSpecificity(JSContext* cx, unsigned argc, JS::Value* vp)
2917
0
{
2918
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.getSpecificity", DOM, cx);
2919
0
2920
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
2921
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
2922
0
2923
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
2924
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.getSpecificity");
2925
0
  }
2926
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
2927
0
  if (global.Failed()) {
2928
0
    return false;
2929
0
  }
2930
0
2931
0
  NonNull<mozilla::BindingStyleRule> arg0;
2932
0
  if (args[0].isObject()) {
2933
0
    {
2934
0
      nsresult rv = UnwrapObject<prototypes::id::CSSStyleRule, mozilla::BindingStyleRule>(args[0], arg0);
2935
0
      if (NS_FAILED(rv)) {
2936
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.getSpecificity", "CSSStyleRule");
2937
0
        return false;
2938
0
      }
2939
0
    }
2940
0
  } else {
2941
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.getSpecificity");
2942
0
    return false;
2943
0
  }
2944
0
  uint32_t arg1;
2945
0
  if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
2946
0
    return false;
2947
0
  }
2948
0
  FastErrorResult rv;
2949
0
  uint64_t result(mozilla::dom::InspectorUtils::GetSpecificity(global, MOZ_KnownLive(NonNullHelper(arg0)), arg1, rv));
2950
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2951
0
    return false;
2952
0
  }
2953
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2954
0
  args.rval().set(JS_NumberValue(double(result)));
2955
0
  return true;
2956
0
}
2957
2958
static bool
2959
selectorMatchesElement(JSContext* cx, unsigned argc, JS::Value* vp)
2960
0
{
2961
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.selectorMatchesElement", DOM, cx);
2962
0
2963
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
2964
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
2965
0
2966
0
  if (MOZ_UNLIKELY(args.length() < 3)) {
2967
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.selectorMatchesElement");
2968
0
  }
2969
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
2970
0
  if (global.Failed()) {
2971
0
    return false;
2972
0
  }
2973
0
2974
0
  NonNull<mozilla::dom::Element> arg0;
2975
0
  if (args[0].isObject()) {
2976
0
    {
2977
0
      nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
2978
0
      if (NS_FAILED(rv)) {
2979
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.selectorMatchesElement", "Element");
2980
0
        return false;
2981
0
      }
2982
0
    }
2983
0
  } else {
2984
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.selectorMatchesElement");
2985
0
    return false;
2986
0
  }
2987
0
  NonNull<mozilla::BindingStyleRule> arg1;
2988
0
  if (args[1].isObject()) {
2989
0
    {
2990
0
      nsresult rv = UnwrapObject<prototypes::id::CSSStyleRule, mozilla::BindingStyleRule>(args[1], arg1);
2991
0
      if (NS_FAILED(rv)) {
2992
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of InspectorUtils.selectorMatchesElement", "CSSStyleRule");
2993
0
        return false;
2994
0
      }
2995
0
    }
2996
0
  } else {
2997
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of InspectorUtils.selectorMatchesElement");
2998
0
    return false;
2999
0
  }
3000
0
  uint32_t arg2;
3001
0
  if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) {
3002
0
    return false;
3003
0
  }
3004
0
  binding_detail::FakeString arg3;
3005
0
  if (args.hasDefined(3)) {
3006
0
    if (!ConvertJSValueToString(cx, args[3], eEmpty, eStringify, arg3)) {
3007
0
      return false;
3008
0
    }
3009
0
  } else {
3010
0
    static const char16_t data[] = { 0 };
3011
0
    arg3.Rebind(data, ArrayLength(data) - 1);
3012
0
  }
3013
0
  FastErrorResult rv;
3014
0
  bool result(mozilla::dom::InspectorUtils::SelectorMatchesElement(global, MOZ_KnownLive(NonNullHelper(arg0)), MOZ_KnownLive(NonNullHelper(arg1)), arg2, NonNullHelper(Constify(arg3)), rv));
3015
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3016
0
    return false;
3017
0
  }
3018
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3019
0
  args.rval().setBoolean(result);
3020
0
  return true;
3021
0
}
3022
3023
static bool
3024
isInheritedProperty(JSContext* cx, unsigned argc, JS::Value* vp)
3025
0
{
3026
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.isInheritedProperty", DOM, cx);
3027
0
3028
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3029
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3030
0
3031
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
3032
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.isInheritedProperty");
3033
0
  }
3034
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3035
0
  if (global.Failed()) {
3036
0
    return false;
3037
0
  }
3038
0
3039
0
  binding_detail::FakeString arg0;
3040
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
3041
0
    return false;
3042
0
  }
3043
0
  bool result(mozilla::dom::InspectorUtils::IsInheritedProperty(global, NonNullHelper(Constify(arg0))));
3044
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3045
0
  args.rval().setBoolean(result);
3046
0
  return true;
3047
0
}
3048
3049
static bool
3050
getCSSPropertyNames(JSContext* cx, unsigned argc, JS::Value* vp)
3051
0
{
3052
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.getCSSPropertyNames", DOM, cx);
3053
0
3054
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3055
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3056
0
3057
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3058
0
  if (global.Failed()) {
3059
0
    return false;
3060
0
  }
3061
0
3062
0
  binding_detail::FastPropertyNamesOptions arg0;
3063
0
  if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue,  "Argument 1 of InspectorUtils.getCSSPropertyNames", false)) {
3064
0
    return false;
3065
0
  }
3066
0
  nsTArray<nsString> result;
3067
0
  mozilla::dom::InspectorUtils::GetCSSPropertyNames(global, Constify(arg0), result);
3068
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3069
0
3070
0
  uint32_t length = result.Length();
3071
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
3072
0
  if (!returnArray) {
3073
0
    return false;
3074
0
  }
3075
0
  // Scope for 'tmp'
3076
0
  {
3077
0
    JS::Rooted<JS::Value> tmp(cx);
3078
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
3079
0
      // Control block to let us common up the JS_DefineElement calls when there
3080
0
      // are different ways to succeed at wrapping the object.
3081
0
      do {
3082
0
        if (!xpc::NonVoidStringToJsval(cx, result[sequenceIdx0], &tmp)) {
3083
0
          return false;
3084
0
        }
3085
0
        break;
3086
0
      } while (false);
3087
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
3088
0
                            JSPROP_ENUMERATE)) {
3089
0
        return false;
3090
0
      }
3091
0
    }
3092
0
  }
3093
0
  args.rval().setObject(*returnArray);
3094
0
  return true;
3095
0
}
3096
3097
static bool
3098
getCSSPropertyPrefs(JSContext* cx, unsigned argc, JS::Value* vp)
3099
0
{
3100
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.getCSSPropertyPrefs", DOM, cx);
3101
0
3102
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3103
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3104
0
3105
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3106
0
  if (global.Failed()) {
3107
0
    return false;
3108
0
  }
3109
0
3110
0
  nsTArray<PropertyPref> result;
3111
0
  mozilla::dom::InspectorUtils::GetCSSPropertyPrefs(global, result);
3112
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3113
0
3114
0
  uint32_t length = result.Length();
3115
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
3116
0
  if (!returnArray) {
3117
0
    return false;
3118
0
  }
3119
0
  // Scope for 'tmp'
3120
0
  {
3121
0
    JS::Rooted<JS::Value> tmp(cx);
3122
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
3123
0
      // Control block to let us common up the JS_DefineElement calls when there
3124
0
      // are different ways to succeed at wrapping the object.
3125
0
      do {
3126
0
        if (!result[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
3127
0
          return false;
3128
0
        }
3129
0
        break;
3130
0
      } while (false);
3131
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
3132
0
                            JSPROP_ENUMERATE)) {
3133
0
        return false;
3134
0
      }
3135
0
    }
3136
0
  }
3137
0
  args.rval().setObject(*returnArray);
3138
0
  return true;
3139
0
}
3140
3141
static bool
3142
getCSSValuesForProperty(JSContext* cx, unsigned argc, JS::Value* vp)
3143
0
{
3144
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.getCSSValuesForProperty", DOM, cx);
3145
0
3146
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3147
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3148
0
3149
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
3150
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.getCSSValuesForProperty");
3151
0
  }
3152
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3153
0
  if (global.Failed()) {
3154
0
    return false;
3155
0
  }
3156
0
3157
0
  binding_detail::FakeString arg0;
3158
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
3159
0
    return false;
3160
0
  }
3161
0
  FastErrorResult rv;
3162
0
  nsTArray<nsString> result;
3163
0
  mozilla::dom::InspectorUtils::GetCSSValuesForProperty(global, NonNullHelper(Constify(arg0)), result, rv);
3164
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3165
0
    return false;
3166
0
  }
3167
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3168
0
3169
0
  uint32_t length = result.Length();
3170
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
3171
0
  if (!returnArray) {
3172
0
    return false;
3173
0
  }
3174
0
  // Scope for 'tmp'
3175
0
  {
3176
0
    JS::Rooted<JS::Value> tmp(cx);
3177
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
3178
0
      // Control block to let us common up the JS_DefineElement calls when there
3179
0
      // are different ways to succeed at wrapping the object.
3180
0
      do {
3181
0
        if (!xpc::NonVoidStringToJsval(cx, result[sequenceIdx0], &tmp)) {
3182
0
          return false;
3183
0
        }
3184
0
        break;
3185
0
      } while (false);
3186
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
3187
0
                            JSPROP_ENUMERATE)) {
3188
0
        return false;
3189
0
      }
3190
0
    }
3191
0
  }
3192
0
  args.rval().setObject(*returnArray);
3193
0
  return true;
3194
0
}
3195
3196
static bool
3197
rgbToColorName(JSContext* cx, unsigned argc, JS::Value* vp)
3198
0
{
3199
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.rgbToColorName", DOM, cx);
3200
0
3201
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3202
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3203
0
3204
0
  if (MOZ_UNLIKELY(args.length() < 3)) {
3205
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.rgbToColorName");
3206
0
  }
3207
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3208
0
  if (global.Failed()) {
3209
0
    return false;
3210
0
  }
3211
0
3212
0
  uint8_t arg0;
3213
0
  if (!ValueToPrimitive<uint8_t, eDefault>(cx, args[0], &arg0)) {
3214
0
    return false;
3215
0
  }
3216
0
  uint8_t arg1;
3217
0
  if (!ValueToPrimitive<uint8_t, eDefault>(cx, args[1], &arg1)) {
3218
0
    return false;
3219
0
  }
3220
0
  uint8_t arg2;
3221
0
  if (!ValueToPrimitive<uint8_t, eDefault>(cx, args[2], &arg2)) {
3222
0
    return false;
3223
0
  }
3224
0
  FastErrorResult rv;
3225
0
  DOMString result;
3226
0
  mozilla::dom::InspectorUtils::RgbToColorName(global, arg0, arg1, arg2, result, rv);
3227
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3228
0
    return false;
3229
0
  }
3230
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3231
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
3232
0
    return false;
3233
0
  }
3234
0
  return true;
3235
0
}
3236
3237
static bool
3238
colorToRGBA(JSContext* cx, unsigned argc, JS::Value* vp)
3239
0
{
3240
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.colorToRGBA", DOM, cx);
3241
0
3242
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3243
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3244
0
3245
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
3246
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.colorToRGBA");
3247
0
  }
3248
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3249
0
  if (global.Failed()) {
3250
0
    return false;
3251
0
  }
3252
0
3253
0
  binding_detail::FakeString arg0;
3254
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
3255
0
    return false;
3256
0
  }
3257
0
  Nullable<InspectorRGBATuple> result;
3258
0
  mozilla::dom::InspectorUtils::ColorToRGBA(global, NonNullHelper(Constify(arg0)), result);
3259
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3260
0
  if (result.IsNull()) {
3261
0
    args.rval().setNull();
3262
0
    return true;
3263
0
  }
3264
0
  if (!result.Value().ToObjectInternal(cx, args.rval())) {
3265
0
    return false;
3266
0
  }
3267
0
  return true;
3268
0
}
3269
3270
static bool
3271
isValidCSSColor(JSContext* cx, unsigned argc, JS::Value* vp)
3272
0
{
3273
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.isValidCSSColor", DOM, cx);
3274
0
3275
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3276
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3277
0
3278
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
3279
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.isValidCSSColor");
3280
0
  }
3281
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3282
0
  if (global.Failed()) {
3283
0
    return false;
3284
0
  }
3285
0
3286
0
  binding_detail::FakeString arg0;
3287
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
3288
0
    return false;
3289
0
  }
3290
0
  bool result(mozilla::dom::InspectorUtils::IsValidCSSColor(global, NonNullHelper(Constify(arg0))));
3291
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3292
0
  args.rval().setBoolean(result);
3293
0
  return true;
3294
0
}
3295
3296
static bool
3297
getSubpropertiesForCSSProperty(JSContext* cx, unsigned argc, JS::Value* vp)
3298
0
{
3299
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.getSubpropertiesForCSSProperty", DOM, cx);
3300
0
3301
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3302
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3303
0
3304
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
3305
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.getSubpropertiesForCSSProperty");
3306
0
  }
3307
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3308
0
  if (global.Failed()) {
3309
0
    return false;
3310
0
  }
3311
0
3312
0
  binding_detail::FakeString arg0;
3313
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
3314
0
    return false;
3315
0
  }
3316
0
  FastErrorResult rv;
3317
0
  nsTArray<nsString> result;
3318
0
  mozilla::dom::InspectorUtils::GetSubpropertiesForCSSProperty(global, NonNullHelper(Constify(arg0)), result, rv);
3319
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3320
0
    return false;
3321
0
  }
3322
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3323
0
3324
0
  uint32_t length = result.Length();
3325
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
3326
0
  if (!returnArray) {
3327
0
    return false;
3328
0
  }
3329
0
  // Scope for 'tmp'
3330
0
  {
3331
0
    JS::Rooted<JS::Value> tmp(cx);
3332
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
3333
0
      // Control block to let us common up the JS_DefineElement calls when there
3334
0
      // are different ways to succeed at wrapping the object.
3335
0
      do {
3336
0
        if (!xpc::NonVoidStringToJsval(cx, result[sequenceIdx0], &tmp)) {
3337
0
          return false;
3338
0
        }
3339
0
        break;
3340
0
      } while (false);
3341
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
3342
0
                            JSPROP_ENUMERATE)) {
3343
0
        return false;
3344
0
      }
3345
0
    }
3346
0
  }
3347
0
  args.rval().setObject(*returnArray);
3348
0
  return true;
3349
0
}
3350
3351
static bool
3352
cssPropertyIsShorthand(JSContext* cx, unsigned argc, JS::Value* vp)
3353
0
{
3354
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.cssPropertyIsShorthand", DOM, cx);
3355
0
3356
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3357
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3358
0
3359
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
3360
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.cssPropertyIsShorthand");
3361
0
  }
3362
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3363
0
  if (global.Failed()) {
3364
0
    return false;
3365
0
  }
3366
0
3367
0
  binding_detail::FakeString arg0;
3368
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
3369
0
    return false;
3370
0
  }
3371
0
  FastErrorResult rv;
3372
0
  bool result(mozilla::dom::InspectorUtils::CssPropertyIsShorthand(global, NonNullHelper(Constify(arg0)), rv));
3373
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3374
0
    return false;
3375
0
  }
3376
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3377
0
  args.rval().setBoolean(result);
3378
0
  return true;
3379
0
}
3380
3381
static bool
3382
cssPropertySupportsType(JSContext* cx, unsigned argc, JS::Value* vp)
3383
0
{
3384
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.cssPropertySupportsType", DOM, cx);
3385
0
3386
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3387
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3388
0
3389
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
3390
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.cssPropertySupportsType");
3391
0
  }
3392
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3393
0
  if (global.Failed()) {
3394
0
    return false;
3395
0
  }
3396
0
3397
0
  binding_detail::FakeString arg0;
3398
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
3399
0
    return false;
3400
0
  }
3401
0
  uint32_t arg1;
3402
0
  if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
3403
0
    return false;
3404
0
  }
3405
0
  FastErrorResult rv;
3406
0
  bool result(mozilla::dom::InspectorUtils::CssPropertySupportsType(global, NonNullHelper(Constify(arg0)), arg1, rv));
3407
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3408
0
    return false;
3409
0
  }
3410
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3411
0
  args.rval().setBoolean(result);
3412
0
  return true;
3413
0
}
3414
3415
static bool
3416
isIgnorableWhitespace(JSContext* cx, unsigned argc, JS::Value* vp)
3417
0
{
3418
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.isIgnorableWhitespace", DOM, cx);
3419
0
3420
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3421
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3422
0
3423
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
3424
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.isIgnorableWhitespace");
3425
0
  }
3426
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3427
0
  if (global.Failed()) {
3428
0
    return false;
3429
0
  }
3430
0
3431
0
  NonNull<mozilla::dom::CharacterData> arg0;
3432
0
  if (args[0].isObject()) {
3433
0
    {
3434
0
      nsresult rv = UnwrapObject<prototypes::id::CharacterData, mozilla::dom::CharacterData>(args[0], arg0);
3435
0
      if (NS_FAILED(rv)) {
3436
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.isIgnorableWhitespace", "CharacterData");
3437
0
        return false;
3438
0
      }
3439
0
    }
3440
0
  } else {
3441
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.isIgnorableWhitespace");
3442
0
    return false;
3443
0
  }
3444
0
  bool result(mozilla::dom::InspectorUtils::IsIgnorableWhitespace(global, MOZ_KnownLive(NonNullHelper(arg0))));
3445
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3446
0
  args.rval().setBoolean(result);
3447
0
  return true;
3448
0
}
3449
3450
static bool
3451
getParentForNode(JSContext* cx, unsigned argc, JS::Value* vp)
3452
0
{
3453
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.getParentForNode", DOM, cx);
3454
0
3455
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3456
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3457
0
3458
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
3459
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.getParentForNode");
3460
0
  }
3461
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3462
0
  if (global.Failed()) {
3463
0
    return false;
3464
0
  }
3465
0
3466
0
  NonNull<nsINode> arg0;
3467
0
  if (args[0].isObject()) {
3468
0
    {
3469
0
      nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0);
3470
0
      if (NS_FAILED(rv)) {
3471
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.getParentForNode", "Node");
3472
0
        return false;
3473
0
      }
3474
0
    }
3475
0
  } else {
3476
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.getParentForNode");
3477
0
    return false;
3478
0
  }
3479
0
  bool arg1;
3480
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
3481
0
    return false;
3482
0
  }
3483
0
  auto result(StrongOrRawPtr<nsINode>(mozilla::dom::InspectorUtils::GetParentForNode(global, MOZ_KnownLive(NonNullHelper(arg0)), arg1)));
3484
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3485
0
  if (!result) {
3486
0
    args.rval().setNull();
3487
0
    return true;
3488
0
  }
3489
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
3490
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
3491
0
    return false;
3492
0
  }
3493
0
  return true;
3494
0
}
3495
3496
static bool
3497
getChildrenForNode(JSContext* cx, unsigned argc, JS::Value* vp)
3498
0
{
3499
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.getChildrenForNode", DOM, cx);
3500
0
3501
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3502
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3503
0
3504
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
3505
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.getChildrenForNode");
3506
0
  }
3507
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3508
0
  if (global.Failed()) {
3509
0
    return false;
3510
0
  }
3511
0
3512
0
  NonNull<nsINode> arg0;
3513
0
  if (args[0].isObject()) {
3514
0
    {
3515
0
      nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0);
3516
0
      if (NS_FAILED(rv)) {
3517
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.getChildrenForNode", "Node");
3518
0
        return false;
3519
0
      }
3520
0
    }
3521
0
  } else {
3522
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.getChildrenForNode");
3523
0
    return false;
3524
0
  }
3525
0
  bool arg1;
3526
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
3527
0
    return false;
3528
0
  }
3529
0
  auto result(StrongOrRawPtr<nsINodeList>(mozilla::dom::InspectorUtils::GetChildrenForNode(global, MOZ_KnownLive(NonNullHelper(arg0)), arg1)));
3530
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3531
0
  static_assert(!IsPointer<decltype(result)>::value,
3532
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
3533
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
3534
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
3535
0
    return false;
3536
0
  }
3537
0
  return true;
3538
0
}
3539
3540
static bool
3541
getBindingURLs(JSContext* cx, unsigned argc, JS::Value* vp)
3542
0
{
3543
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.getBindingURLs", DOM, cx);
3544
0
3545
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3546
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3547
0
3548
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
3549
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.getBindingURLs");
3550
0
  }
3551
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3552
0
  if (global.Failed()) {
3553
0
    return false;
3554
0
  }
3555
0
3556
0
  NonNull<mozilla::dom::Element> arg0;
3557
0
  if (args[0].isObject()) {
3558
0
    {
3559
0
      nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
3560
0
      if (NS_FAILED(rv)) {
3561
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.getBindingURLs", "Element");
3562
0
        return false;
3563
0
      }
3564
0
    }
3565
0
  } else {
3566
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.getBindingURLs");
3567
0
    return false;
3568
0
  }
3569
0
  nsTArray<nsString> result;
3570
0
  mozilla::dom::InspectorUtils::GetBindingURLs(global, MOZ_KnownLive(NonNullHelper(arg0)), result);
3571
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3572
0
3573
0
  uint32_t length = result.Length();
3574
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
3575
0
  if (!returnArray) {
3576
0
    return false;
3577
0
  }
3578
0
  // Scope for 'tmp'
3579
0
  {
3580
0
    JS::Rooted<JS::Value> tmp(cx);
3581
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
3582
0
      // Control block to let us common up the JS_DefineElement calls when there
3583
0
      // are different ways to succeed at wrapping the object.
3584
0
      do {
3585
0
        if (!xpc::NonVoidStringToJsval(cx, result[sequenceIdx0], &tmp)) {
3586
0
          return false;
3587
0
        }
3588
0
        break;
3589
0
      } while (false);
3590
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
3591
0
                            JSPROP_ENUMERATE)) {
3592
0
        return false;
3593
0
      }
3594
0
    }
3595
0
  }
3596
0
  args.rval().setObject(*returnArray);
3597
0
  return true;
3598
0
}
3599
3600
static bool
3601
setContentState(JSContext* cx, unsigned argc, JS::Value* vp)
3602
0
{
3603
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.setContentState", DOM, cx);
3604
0
3605
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3606
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3607
0
3608
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
3609
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.setContentState");
3610
0
  }
3611
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3612
0
  if (global.Failed()) {
3613
0
    return false;
3614
0
  }
3615
0
3616
0
  NonNull<mozilla::dom::Element> arg0;
3617
0
  if (args[0].isObject()) {
3618
0
    {
3619
0
      nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
3620
0
      if (NS_FAILED(rv)) {
3621
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.setContentState", "Element");
3622
0
        return false;
3623
0
      }
3624
0
    }
3625
0
  } else {
3626
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.setContentState");
3627
0
    return false;
3628
0
  }
3629
0
  uint64_t arg1;
3630
0
  if (!ValueToPrimitive<uint64_t, eDefault>(cx, args[1], &arg1)) {
3631
0
    return false;
3632
0
  }
3633
0
  FastErrorResult rv;
3634
0
  bool result(mozilla::dom::InspectorUtils::SetContentState(global, MOZ_KnownLive(NonNullHelper(arg0)), arg1, rv));
3635
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3636
0
    return false;
3637
0
  }
3638
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3639
0
  args.rval().setBoolean(result);
3640
0
  return true;
3641
0
}
3642
3643
static bool
3644
removeContentState(JSContext* cx, unsigned argc, JS::Value* vp)
3645
0
{
3646
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.removeContentState", DOM, cx);
3647
0
3648
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3649
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3650
0
3651
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
3652
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.removeContentState");
3653
0
  }
3654
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3655
0
  if (global.Failed()) {
3656
0
    return false;
3657
0
  }
3658
0
3659
0
  NonNull<mozilla::dom::Element> arg0;
3660
0
  if (args[0].isObject()) {
3661
0
    {
3662
0
      nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
3663
0
      if (NS_FAILED(rv)) {
3664
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.removeContentState", "Element");
3665
0
        return false;
3666
0
      }
3667
0
    }
3668
0
  } else {
3669
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.removeContentState");
3670
0
    return false;
3671
0
  }
3672
0
  uint64_t arg1;
3673
0
  if (!ValueToPrimitive<uint64_t, eDefault>(cx, args[1], &arg1)) {
3674
0
    return false;
3675
0
  }
3676
0
  bool arg2;
3677
0
  if (args.hasDefined(2)) {
3678
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) {
3679
0
      return false;
3680
0
    }
3681
0
  } else {
3682
0
    arg2 = false;
3683
0
  }
3684
0
  FastErrorResult rv;
3685
0
  bool result(mozilla::dom::InspectorUtils::RemoveContentState(global, MOZ_KnownLive(NonNullHelper(arg0)), arg1, arg2, rv));
3686
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3687
0
    return false;
3688
0
  }
3689
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3690
0
  args.rval().setBoolean(result);
3691
0
  return true;
3692
0
}
3693
3694
static bool
3695
getContentState(JSContext* cx, unsigned argc, JS::Value* vp)
3696
0
{
3697
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.getContentState", DOM, cx);
3698
0
3699
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3700
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3701
0
3702
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
3703
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.getContentState");
3704
0
  }
3705
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3706
0
  if (global.Failed()) {
3707
0
    return false;
3708
0
  }
3709
0
3710
0
  NonNull<mozilla::dom::Element> arg0;
3711
0
  if (args[0].isObject()) {
3712
0
    {
3713
0
      nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
3714
0
      if (NS_FAILED(rv)) {
3715
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.getContentState", "Element");
3716
0
        return false;
3717
0
      }
3718
0
    }
3719
0
  } else {
3720
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.getContentState");
3721
0
    return false;
3722
0
  }
3723
0
  uint64_t result(mozilla::dom::InspectorUtils::GetContentState(global, MOZ_KnownLive(NonNullHelper(arg0))));
3724
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3725
0
  args.rval().set(JS_NumberValue(double(result)));
3726
0
  return true;
3727
0
}
3728
3729
static bool
3730
getUsedFontFaces(JSContext* cx, unsigned argc, JS::Value* vp)
3731
0
{
3732
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.getUsedFontFaces", DOM, cx);
3733
0
3734
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3735
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3736
0
3737
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
3738
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.getUsedFontFaces");
3739
0
  }
3740
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3741
0
  if (global.Failed()) {
3742
0
    return false;
3743
0
  }
3744
0
3745
0
  NonNull<nsRange> arg0;
3746
0
  if (args[0].isObject()) {
3747
0
    {
3748
0
      nsresult rv = UnwrapObject<prototypes::id::Range, nsRange>(args[0], arg0);
3749
0
      if (NS_FAILED(rv)) {
3750
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.getUsedFontFaces", "Range");
3751
0
        return false;
3752
0
      }
3753
0
    }
3754
0
  } else {
3755
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.getUsedFontFaces");
3756
0
    return false;
3757
0
  }
3758
0
  uint32_t arg1;
3759
0
  if (args.hasDefined(1)) {
3760
0
    if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
3761
0
      return false;
3762
0
    }
3763
0
  } else {
3764
0
    arg1 = 0U;
3765
0
  }
3766
0
  bool arg2;
3767
0
  if (args.hasDefined(2)) {
3768
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) {
3769
0
      return false;
3770
0
    }
3771
0
  } else {
3772
0
    arg2 = true;
3773
0
  }
3774
0
  FastErrorResult rv;
3775
0
  nsTArray<StrongPtrForMember<mozilla::dom::InspectorFontFace>::Type> result;
3776
0
  mozilla::dom::InspectorUtils::GetUsedFontFaces(global, MOZ_KnownLive(NonNullHelper(arg0)), arg1, arg2, result, rv);
3777
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3778
0
    return false;
3779
0
  }
3780
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3781
0
3782
0
  uint32_t length = result.Length();
3783
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
3784
0
  if (!returnArray) {
3785
0
    return false;
3786
0
  }
3787
0
  // Scope for 'tmp'
3788
0
  {
3789
0
    JS::Rooted<JS::Value> tmp(cx);
3790
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
3791
0
      // Control block to let us common up the JS_DefineElement calls when there
3792
0
      // are different ways to succeed at wrapping the object.
3793
0
      do {
3794
0
        if (!WrapNewBindingNonWrapperCachedObject(cx, returnArray, result[sequenceIdx0], &tmp)) {
3795
0
          MOZ_ASSERT(JS_IsExceptionPending(cx));
3796
0
          return false;
3797
0
        }
3798
0
        break;
3799
0
      } while (false);
3800
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
3801
0
                            JSPROP_ENUMERATE)) {
3802
0
        return false;
3803
0
      }
3804
0
    }
3805
0
  }
3806
0
  args.rval().setObject(*returnArray);
3807
0
  return true;
3808
0
}
3809
3810
static bool
3811
getCSSPseudoElementNames(JSContext* cx, unsigned argc, JS::Value* vp)
3812
0
{
3813
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.getCSSPseudoElementNames", DOM, cx);
3814
0
3815
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3816
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3817
0
3818
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3819
0
  if (global.Failed()) {
3820
0
    return false;
3821
0
  }
3822
0
3823
0
  nsTArray<nsString> result;
3824
0
  mozilla::dom::InspectorUtils::GetCSSPseudoElementNames(global, result);
3825
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3826
0
3827
0
  uint32_t length = result.Length();
3828
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
3829
0
  if (!returnArray) {
3830
0
    return false;
3831
0
  }
3832
0
  // Scope for 'tmp'
3833
0
  {
3834
0
    JS::Rooted<JS::Value> tmp(cx);
3835
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
3836
0
      // Control block to let us common up the JS_DefineElement calls when there
3837
0
      // are different ways to succeed at wrapping the object.
3838
0
      do {
3839
0
        if (!xpc::NonVoidStringToJsval(cx, result[sequenceIdx0], &tmp)) {
3840
0
          return false;
3841
0
        }
3842
0
        break;
3843
0
      } while (false);
3844
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
3845
0
                            JSPROP_ENUMERATE)) {
3846
0
        return false;
3847
0
      }
3848
0
    }
3849
0
  }
3850
0
  args.rval().setObject(*returnArray);
3851
0
  return true;
3852
0
}
3853
3854
static bool
3855
addPseudoClassLock(JSContext* cx, unsigned argc, JS::Value* vp)
3856
0
{
3857
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.addPseudoClassLock", DOM, cx);
3858
0
3859
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3860
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3861
0
3862
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
3863
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.addPseudoClassLock");
3864
0
  }
3865
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3866
0
  if (global.Failed()) {
3867
0
    return false;
3868
0
  }
3869
0
3870
0
  NonNull<mozilla::dom::Element> arg0;
3871
0
  if (args[0].isObject()) {
3872
0
    {
3873
0
      nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
3874
0
      if (NS_FAILED(rv)) {
3875
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.addPseudoClassLock", "Element");
3876
0
        return false;
3877
0
      }
3878
0
    }
3879
0
  } else {
3880
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.addPseudoClassLock");
3881
0
    return false;
3882
0
  }
3883
0
  binding_detail::FakeString arg1;
3884
0
  if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
3885
0
    return false;
3886
0
  }
3887
0
  bool arg2;
3888
0
  if (args.hasDefined(2)) {
3889
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) {
3890
0
      return false;
3891
0
    }
3892
0
  } else {
3893
0
    arg2 = true;
3894
0
  }
3895
0
  mozilla::dom::InspectorUtils::AddPseudoClassLock(global, MOZ_KnownLive(NonNullHelper(arg0)), NonNullHelper(Constify(arg1)), arg2);
3896
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3897
0
  args.rval().setUndefined();
3898
0
  return true;
3899
0
}
3900
3901
static bool
3902
removePseudoClassLock(JSContext* cx, unsigned argc, JS::Value* vp)
3903
0
{
3904
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.removePseudoClassLock", DOM, cx);
3905
0
3906
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3907
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3908
0
3909
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
3910
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.removePseudoClassLock");
3911
0
  }
3912
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3913
0
  if (global.Failed()) {
3914
0
    return false;
3915
0
  }
3916
0
3917
0
  NonNull<mozilla::dom::Element> arg0;
3918
0
  if (args[0].isObject()) {
3919
0
    {
3920
0
      nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
3921
0
      if (NS_FAILED(rv)) {
3922
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.removePseudoClassLock", "Element");
3923
0
        return false;
3924
0
      }
3925
0
    }
3926
0
  } else {
3927
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.removePseudoClassLock");
3928
0
    return false;
3929
0
  }
3930
0
  binding_detail::FakeString arg1;
3931
0
  if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
3932
0
    return false;
3933
0
  }
3934
0
  mozilla::dom::InspectorUtils::RemovePseudoClassLock(global, MOZ_KnownLive(NonNullHelper(arg0)), NonNullHelper(Constify(arg1)));
3935
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3936
0
  args.rval().setUndefined();
3937
0
  return true;
3938
0
}
3939
3940
static bool
3941
hasPseudoClassLock(JSContext* cx, unsigned argc, JS::Value* vp)
3942
0
{
3943
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.hasPseudoClassLock", DOM, cx);
3944
0
3945
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3946
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3947
0
3948
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
3949
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.hasPseudoClassLock");
3950
0
  }
3951
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3952
0
  if (global.Failed()) {
3953
0
    return false;
3954
0
  }
3955
0
3956
0
  NonNull<mozilla::dom::Element> arg0;
3957
0
  if (args[0].isObject()) {
3958
0
    {
3959
0
      nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
3960
0
      if (NS_FAILED(rv)) {
3961
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.hasPseudoClassLock", "Element");
3962
0
        return false;
3963
0
      }
3964
0
    }
3965
0
  } else {
3966
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.hasPseudoClassLock");
3967
0
    return false;
3968
0
  }
3969
0
  binding_detail::FakeString arg1;
3970
0
  if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
3971
0
    return false;
3972
0
  }
3973
0
  bool result(mozilla::dom::InspectorUtils::HasPseudoClassLock(global, MOZ_KnownLive(NonNullHelper(arg0)), NonNullHelper(Constify(arg1))));
3974
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3975
0
  args.rval().setBoolean(result);
3976
0
  return true;
3977
0
}
3978
3979
static bool
3980
clearPseudoClassLocks(JSContext* cx, unsigned argc, JS::Value* vp)
3981
0
{
3982
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.clearPseudoClassLocks", DOM, cx);
3983
0
3984
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3985
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3986
0
3987
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
3988
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.clearPseudoClassLocks");
3989
0
  }
3990
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
3991
0
  if (global.Failed()) {
3992
0
    return false;
3993
0
  }
3994
0
3995
0
  NonNull<mozilla::dom::Element> arg0;
3996
0
  if (args[0].isObject()) {
3997
0
    {
3998
0
      nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
3999
0
      if (NS_FAILED(rv)) {
4000
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.clearPseudoClassLocks", "Element");
4001
0
        return false;
4002
0
      }
4003
0
    }
4004
0
  } else {
4005
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.clearPseudoClassLocks");
4006
0
    return false;
4007
0
  }
4008
0
  mozilla::dom::InspectorUtils::ClearPseudoClassLocks(global, MOZ_KnownLive(NonNullHelper(arg0)));
4009
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4010
0
  args.rval().setUndefined();
4011
0
  return true;
4012
0
}
4013
4014
static bool
4015
parseStyleSheet(JSContext* cx, unsigned argc, JS::Value* vp)
4016
0
{
4017
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.parseStyleSheet", DOM, cx);
4018
0
4019
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4020
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4021
0
4022
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
4023
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.parseStyleSheet");
4024
0
  }
4025
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4026
0
  if (global.Failed()) {
4027
0
    return false;
4028
0
  }
4029
0
4030
0
  NonNull<mozilla::StyleSheet> arg0;
4031
0
  if (args[0].isObject()) {
4032
0
    {
4033
0
      nsresult rv = UnwrapObject<prototypes::id::CSSStyleSheet, mozilla::StyleSheet>(args[0], arg0);
4034
0
      if (NS_FAILED(rv)) {
4035
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.parseStyleSheet", "CSSStyleSheet");
4036
0
        return false;
4037
0
      }
4038
0
    }
4039
0
  } else {
4040
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.parseStyleSheet");
4041
0
    return false;
4042
0
  }
4043
0
  binding_detail::FakeString arg1;
4044
0
  if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
4045
0
    return false;
4046
0
  }
4047
0
  FastErrorResult rv;
4048
0
  mozilla::dom::InspectorUtils::ParseStyleSheet(global, MOZ_KnownLive(NonNullHelper(arg0)), NonNullHelper(Constify(arg1)), rv);
4049
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
4050
0
    return false;
4051
0
  }
4052
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4053
0
  args.rval().setUndefined();
4054
0
  return true;
4055
0
}
4056
4057
static bool
4058
scrollElementIntoView(JSContext* cx, unsigned argc, JS::Value* vp)
4059
0
{
4060
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.scrollElementIntoView", DOM, cx);
4061
0
4062
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4063
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4064
0
4065
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
4066
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.scrollElementIntoView");
4067
0
  }
4068
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4069
0
  if (global.Failed()) {
4070
0
    return false;
4071
0
  }
4072
0
4073
0
  NonNull<mozilla::dom::Element> arg0;
4074
0
  if (args[0].isObject()) {
4075
0
    {
4076
0
      nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
4077
0
      if (NS_FAILED(rv)) {
4078
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of InspectorUtils.scrollElementIntoView", "Element");
4079
0
        return false;
4080
0
      }
4081
0
    }
4082
0
  } else {
4083
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of InspectorUtils.scrollElementIntoView");
4084
0
    return false;
4085
0
  }
4086
0
  mozilla::dom::InspectorUtils::ScrollElementIntoView(global, MOZ_KnownLive(NonNullHelper(arg0)));
4087
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4088
0
  args.rval().setUndefined();
4089
0
  return true;
4090
0
}
4091
4092
static bool
4093
isCustomElementName(JSContext* cx, unsigned argc, JS::Value* vp)
4094
0
{
4095
0
  AUTO_PROFILER_LABEL_FAST("InspectorUtils.isCustomElementName", DOM, cx);
4096
0
4097
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4098
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4099
0
4100
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
4101
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "InspectorUtils.isCustomElementName");
4102
0
  }
4103
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
4104
0
  if (global.Failed()) {
4105
0
    return false;
4106
0
  }
4107
0
4108
0
  binding_detail::FakeString arg0;
4109
0
  if (!ConvertJSValueToString(cx, args[0], eEmpty, eStringify, arg0)) {
4110
0
    return false;
4111
0
  }
4112
0
  binding_detail::FakeString arg1;
4113
0
  if (!ConvertJSValueToString(cx, args[1], eNull, eNull, arg1)) {
4114
0
    return false;
4115
0
  }
4116
0
  bool result(mozilla::dom::InspectorUtils::IsCustomElementName(global, NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1))));
4117
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4118
0
  args.rval().setBoolean(result);
4119
0
  return true;
4120
0
}
4121
4122
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
4123
#if defined(__clang__)
4124
#pragma clang diagnostic push
4125
#pragma clang diagnostic ignored "-Wmissing-braces"
4126
#endif
4127
static const JSFunctionSpec sStaticMethods_specs[] = {
4128
  JS_FNSPEC("getAllStyleSheets", getAllStyleSheets, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4129
  JS_FNSPEC("getCSSStyleRules", getCSSStyleRules, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4130
  JS_FNSPEC("getRuleLine", getRuleLine, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4131
  JS_FNSPEC("getRuleColumn", getRuleColumn, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4132
  JS_FNSPEC("getRelativeRuleLine", getRelativeRuleLine, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4133
  JS_FNSPEC("hasRulesModifiedByCSSOM", hasRulesModifiedByCSSOM, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4134
  JS_FNSPEC("getSelectorCount", getSelectorCount, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4135
  JS_FNSPEC("getSelectorText", getSelectorText, nullptr, 2, JSPROP_ENUMERATE, nullptr),
4136
  JS_FNSPEC("getSpecificity", getSpecificity, nullptr, 2, JSPROP_ENUMERATE, nullptr),
4137
  JS_FNSPEC("selectorMatchesElement", selectorMatchesElement, nullptr, 3, JSPROP_ENUMERATE, nullptr),
4138
  JS_FNSPEC("isInheritedProperty", isInheritedProperty, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4139
  JS_FNSPEC("getCSSPropertyNames", getCSSPropertyNames, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4140
  JS_FNSPEC("getCSSPropertyPrefs", getCSSPropertyPrefs, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4141
  JS_FNSPEC("getCSSValuesForProperty", getCSSValuesForProperty, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4142
  JS_FNSPEC("rgbToColorName", rgbToColorName, nullptr, 3, JSPROP_ENUMERATE, nullptr),
4143
  JS_FNSPEC("colorToRGBA", colorToRGBA, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4144
  JS_FNSPEC("isValidCSSColor", isValidCSSColor, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4145
  JS_FNSPEC("getSubpropertiesForCSSProperty", getSubpropertiesForCSSProperty, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4146
  JS_FNSPEC("cssPropertyIsShorthand", cssPropertyIsShorthand, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4147
  JS_FNSPEC("cssPropertySupportsType", cssPropertySupportsType, nullptr, 2, JSPROP_ENUMERATE, nullptr),
4148
  JS_FNSPEC("isIgnorableWhitespace", isIgnorableWhitespace, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4149
  JS_FNSPEC("getParentForNode", getParentForNode, nullptr, 2, JSPROP_ENUMERATE, nullptr),
4150
  JS_FNSPEC("getChildrenForNode", getChildrenForNode, nullptr, 2, JSPROP_ENUMERATE, nullptr),
4151
  JS_FNSPEC("getBindingURLs", getBindingURLs, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4152
  JS_FNSPEC("setContentState", setContentState, nullptr, 2, JSPROP_ENUMERATE, nullptr),
4153
  JS_FNSPEC("removeContentState", removeContentState, nullptr, 2, JSPROP_ENUMERATE, nullptr),
4154
  JS_FNSPEC("getContentState", getContentState, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4155
  JS_FNSPEC("getUsedFontFaces", getUsedFontFaces, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4156
  JS_FNSPEC("getCSSPseudoElementNames", getCSSPseudoElementNames, nullptr, 0, JSPROP_ENUMERATE, nullptr),
4157
  JS_FNSPEC("addPseudoClassLock", addPseudoClassLock, nullptr, 2, JSPROP_ENUMERATE, nullptr),
4158
  JS_FNSPEC("removePseudoClassLock", removePseudoClassLock, nullptr, 2, JSPROP_ENUMERATE, nullptr),
4159
  JS_FNSPEC("hasPseudoClassLock", hasPseudoClassLock, nullptr, 2, JSPROP_ENUMERATE, nullptr),
4160
  JS_FNSPEC("clearPseudoClassLocks", clearPseudoClassLocks, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4161
  JS_FNSPEC("parseStyleSheet", parseStyleSheet, nullptr, 2, JSPROP_ENUMERATE, nullptr),
4162
  JS_FNSPEC("scrollElementIntoView", scrollElementIntoView, nullptr, 1, JSPROP_ENUMERATE, nullptr),
4163
  JS_FNSPEC("isCustomElementName", isCustomElementName, nullptr, 2, JSPROP_ENUMERATE, nullptr),
4164
  JS_FS_END
4165
};
4166
#if defined(__clang__)
4167
#pragma clang diagnostic pop
4168
#endif
4169
4170
4171
static const Prefable<const JSFunctionSpec> sStaticMethods[] = {
4172
  { nullptr, &sStaticMethods_specs[0] },
4173
  { nullptr, nullptr }
4174
};
4175
4176
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
4177
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
4178
static_assert(36 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
4179
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
4180
4181
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
4182
#if defined(__clang__)
4183
#pragma clang diagnostic push
4184
#pragma clang diagnostic ignored "-Wmissing-braces"
4185
#endif
4186
static const ConstantSpec sConstants_specs[] = {
4187
  { "TYPE_COLOR", JS::NumberValue(1U) },
4188
  { "TYPE_GRADIENT", JS::NumberValue(2U) },
4189
  { "TYPE_TIMING_FUNCTION", JS::NumberValue(3U) },
4190
  { 0, JS::UndefinedValue() }
4191
};
4192
#if defined(__clang__)
4193
#pragma clang diagnostic pop
4194
#endif
4195
4196
4197
static const Prefable<const ConstantSpec> sConstants[] = {
4198
  { nullptr, &sConstants_specs[0] },
4199
  { nullptr, nullptr }
4200
};
4201
4202
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
4203
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
4204
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
4205
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
4206
4207
4208
static uint16_t sNativeProperties_sortedPropertyIndices[39];
4209
static PropertyInfo sNativeProperties_propertyInfos[39];
4210
4211
static const NativePropertiesN<2> sNativeProperties = {
4212
  true,  0 /* sStaticMethods */,
4213
  false, 0,
4214
  false, 0,
4215
  false, 0,
4216
  false, 0,
4217
  false, 0,
4218
  true,  1 /* sConstants */,
4219
  -1,
4220
  39,
4221
  sNativeProperties_sortedPropertyIndices,
4222
  {
4223
    { sStaticMethods, &sNativeProperties_propertyInfos[0] },
4224
    { sConstants, &sNativeProperties_propertyInfos[36] }
4225
  }
4226
};
4227
static_assert(39 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
4228
    "We have a property info count that is oversized");
4229
4230
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
4231
  {
4232
    "Object",
4233
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
4234
    JS_NULL_CLASS_OPS,
4235
    JS_NULL_CLASS_SPEC,
4236
    JS_NULL_CLASS_EXT,
4237
    JS_NULL_OBJECT_OPS
4238
  },
4239
  eInterface,
4240
  false,
4241
  prototypes::id::_ID_Count,
4242
  0,
4243
  sNativePropertyHooks,
4244
  "[object Object]",
4245
  JS::GetRealmObjectPrototype
4246
};
4247
4248
bool
4249
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
4250
0
{
4251
0
  return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
4252
0
}
4253
4254
const NativePropertyHooks sNativePropertyHooks[] = { {
4255
  nullptr,
4256
  nullptr,
4257
  nullptr,
4258
  { sNativeProperties.Upcast(), nullptr },
4259
  prototypes::id::_ID_Count,
4260
  constructors::id::InspectorUtils,
4261
  nullptr,
4262
  &DefaultXrayExpandoObjectClass
4263
} };
4264
4265
void
4266
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
4267
0
{
4268
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmObjectPrototype(aCx));
4269
0
  if (!constructorProto) {
4270
0
    return;
4271
0
  }
4272
0
4273
0
  static bool sIdsInited = false;
4274
0
  if (!sIdsInited && NS_IsMainThread()) {
4275
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
4276
0
      return;
4277
0
    }
4278
0
    sIdsInited = true;
4279
0
  }
4280
0
4281
0
  JS::Heap<JSObject*>* protoCache = nullptr;
4282
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::InspectorUtils);
4283
0
  dom::CreateInterfaceObjects(aCx, aGlobal, nullptr,
4284
0
                              nullptr, protoCache,
4285
0
                              nullptr,
4286
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
4287
0
                              interfaceCache,
4288
0
                              sNativeProperties.Upcast(),
4289
0
                              nullptr,
4290
0
                              "InspectorUtils", aDefineOnGlobal,
4291
0
                              nullptr,
4292
0
                              false);
4293
0
}
4294
4295
JSObject*
4296
GetConstructorObject(JSContext* aCx)
4297
0
{
4298
0
  return GetConstructorObjectHandle(aCx);
4299
0
}
4300
4301
} // namespace InspectorUtils_Binding
4302
4303
4304
4305
} // namespace dom
4306
} // namespace mozilla