Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/CSSFontFeatureValuesRuleBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM CSSFontFeatureValuesRule.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "CSSFontFeatureValuesRuleBinding.h"
4
#include "CSSRuleBinding.h"
5
#include "WrapperFactory.h"
6
#include "mozilla/OwningNonNull.h"
7
#include "mozilla/dom/BindingUtils.h"
8
#include "mozilla/dom/CSSFontFeatureValuesRule.h"
9
#include "mozilla/dom/DOMJSClass.h"
10
#include "mozilla/dom/NonRefcountedDOMObject.h"
11
#include "mozilla/dom/XrayExpandoClass.h"
12
13
namespace mozilla {
14
namespace dom {
15
16
namespace binding_detail {}; // Just to make sure it's known as a namespace
17
using namespace mozilla::dom::binding_detail;
18
19
20
namespace CSSFontFeatureValuesRule_Binding {
21
22
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<CSSRule_Binding::NativeType>::value,
23
              "Can't inherit from an interface with a different ownership model.");
24
25
MOZ_CAN_RUN_SCRIPT static bool
26
get_fontFamily(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CSSFontFeatureValuesRule* self, JSJitGetterCallArgs args)
27
0
{
28
0
  AUTO_PROFILER_LABEL_FAST("get CSSFontFeatureValuesRule.fontFamily", DOM, cx);
29
0
30
0
  DOMString result;
31
0
  self->GetFontFamily(result);
32
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
33
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
34
0
    return false;
35
0
  }
36
0
  return true;
37
0
}
38
39
MOZ_CAN_RUN_SCRIPT static bool
40
set_fontFamily(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CSSFontFeatureValuesRule* self, JSJitSetterCallArgs args)
41
0
{
42
0
  AUTO_PROFILER_LABEL_FAST("set CSSFontFeatureValuesRule.fontFamily", DOM, cx);
43
0
44
0
  binding_detail::FakeString arg0;
45
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
46
0
    return false;
47
0
  }
48
0
  FastErrorResult rv;
49
0
  self->SetFontFamily(NonNullHelper(Constify(arg0)), rv);
50
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
51
0
    return false;
52
0
  }
53
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
54
0
55
0
  return true;
56
0
}
57
58
static const JSJitInfo fontFamily_getterinfo = {
59
  { (JSJitGetterOp)get_fontFamily },
60
  { prototypes::id::CSSFontFeatureValuesRule },
61
  { PrototypeTraits<prototypes::id::CSSFontFeatureValuesRule>::Depth },
62
  JSJitInfo::Getter,
63
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
64
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
65
  false,  /* isInfallible. False in setters. */
66
  false,  /* isMovable.  Not relevant for setters. */
67
  false, /* isEliminatable.  Not relevant for setters. */
68
  false, /* isAlwaysInSlot.  Only relevant for getters. */
69
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
70
  false,  /* isTypedMethod.  Only relevant for methods. */
71
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
72
};
73
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
74
static_assert(0 < 1, "There is no slot for us");
75
static const JSJitInfo fontFamily_setterinfo = {
76
  { (JSJitGetterOp)set_fontFamily },
77
  { prototypes::id::CSSFontFeatureValuesRule },
78
  { PrototypeTraits<prototypes::id::CSSFontFeatureValuesRule>::Depth },
79
  JSJitInfo::Setter,
80
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
81
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
82
  false,  /* isInfallible. False in setters. */
83
  false,  /* isMovable.  Not relevant for setters. */
84
  false, /* isEliminatable.  Not relevant for setters. */
85
  false, /* isAlwaysInSlot.  Only relevant for getters. */
86
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
87
  false,  /* isTypedMethod.  Only relevant for methods. */
88
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
89
};
90
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
91
static_assert(0 < 1, "There is no slot for us");
92
93
MOZ_CAN_RUN_SCRIPT static bool
94
get_valueText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CSSFontFeatureValuesRule* self, JSJitGetterCallArgs args)
95
0
{
96
0
  AUTO_PROFILER_LABEL_FAST("get CSSFontFeatureValuesRule.valueText", DOM, cx);
97
0
98
0
  DOMString result;
99
0
  self->GetValueText(result);
100
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
101
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
102
0
    return false;
103
0
  }
104
0
  return true;
105
0
}
106
107
MOZ_CAN_RUN_SCRIPT static bool
108
set_valueText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CSSFontFeatureValuesRule* self, JSJitSetterCallArgs args)
109
0
{
110
0
  AUTO_PROFILER_LABEL_FAST("set CSSFontFeatureValuesRule.valueText", DOM, cx);
111
0
112
0
  binding_detail::FakeString arg0;
113
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
114
0
    return false;
115
0
  }
116
0
  FastErrorResult rv;
117
0
  self->SetValueText(NonNullHelper(Constify(arg0)), rv);
118
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
119
0
    return false;
120
0
  }
121
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
122
0
123
0
  return true;
124
0
}
125
126
static const JSJitInfo valueText_getterinfo = {
127
  { (JSJitGetterOp)get_valueText },
128
  { prototypes::id::CSSFontFeatureValuesRule },
129
  { PrototypeTraits<prototypes::id::CSSFontFeatureValuesRule>::Depth },
130
  JSJitInfo::Getter,
131
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
132
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
133
  false,  /* isInfallible. False in setters. */
134
  false,  /* isMovable.  Not relevant for setters. */
135
  false, /* isEliminatable.  Not relevant for setters. */
136
  false, /* isAlwaysInSlot.  Only relevant for getters. */
137
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
138
  false,  /* isTypedMethod.  Only relevant for methods. */
139
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
140
};
141
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
142
static_assert(0 < 1, "There is no slot for us");
143
static const JSJitInfo valueText_setterinfo = {
144
  { (JSJitGetterOp)set_valueText },
145
  { prototypes::id::CSSFontFeatureValuesRule },
146
  { PrototypeTraits<prototypes::id::CSSFontFeatureValuesRule>::Depth },
147
  JSJitInfo::Setter,
148
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
149
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
150
  false,  /* isInfallible. False in setters. */
151
  false,  /* isMovable.  Not relevant for setters. */
152
  false, /* isEliminatable.  Not relevant for setters. */
153
  false, /* isAlwaysInSlot.  Only relevant for getters. */
154
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
155
  false,  /* isTypedMethod.  Only relevant for methods. */
156
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
157
};
158
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
159
static_assert(0 < 1, "There is no slot for us");
160
161
static bool
162
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
163
0
{
164
0
  mozilla::dom::CSSFontFeatureValuesRule* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CSSFontFeatureValuesRule>(obj);
165
0
  // We don't want to preserve if we don't have a wrapper, and we
166
0
  // obviously can't preserve if we're not initialized.
167
0
  if (self && self->GetWrapperPreserveColor()) {
168
0
    PreserveWrapper(self);
169
0
  }
170
0
  return true;
171
0
}
172
173
static void
174
_finalize(js::FreeOp* fop, JSObject* obj)
175
0
{
176
0
  mozilla::dom::CSSFontFeatureValuesRule* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CSSFontFeatureValuesRule>(obj);
177
0
  if (self) {
178
0
    ClearWrapper(self, self, obj);
179
0
    AddForDeferredFinalization<mozilla::dom::CSSFontFeatureValuesRule>(self);
180
0
  }
181
0
}
182
183
static size_t
184
_objectMoved(JSObject* obj, JSObject* old)
185
0
{
186
0
  mozilla::dom::CSSFontFeatureValuesRule* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CSSFontFeatureValuesRule>(obj);
187
0
  if (self) {
188
0
    UpdateWrapper(self, self, obj, old);
189
0
  }
190
0
191
0
  return 0;
192
0
}
193
194
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
195
#if defined(__clang__)
196
#pragma clang diagnostic push
197
#pragma clang diagnostic ignored "-Wmissing-braces"
198
#endif
199
static const JSPropertySpec sAttributes_specs[] = {
200
  { "fontFamily", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &fontFamily_getterinfo, GenericSetter<NormalThisPolicy>, &fontFamily_setterinfo },
201
  { "valueText", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &valueText_getterinfo, GenericSetter<NormalThisPolicy>, &valueText_setterinfo },
202
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
203
};
204
#if defined(__clang__)
205
#pragma clang diagnostic pop
206
#endif
207
208
209
static const Prefable<const JSPropertySpec> sAttributes[] = {
210
  { nullptr, &sAttributes_specs[0] },
211
  { nullptr, nullptr }
212
};
213
214
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
215
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
216
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
217
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
218
219
220
static uint16_t sNativeProperties_sortedPropertyIndices[2];
221
static PropertyInfo sNativeProperties_propertyInfos[2];
222
223
static const NativePropertiesN<1> sNativeProperties = {
224
  false, 0,
225
  false, 0,
226
  false, 0,
227
  true,  0 /* sAttributes */,
228
  false, 0,
229
  false, 0,
230
  false, 0,
231
  -1,
232
  2,
233
  sNativeProperties_sortedPropertyIndices,
234
  {
235
    { sAttributes, &sNativeProperties_propertyInfos[0] }
236
  }
237
};
238
static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
239
    "We have a property info count that is oversized");
240
241
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
242
  {
243
    "Function",
244
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
245
    &sBoringInterfaceObjectClassClassOps,
246
    JS_NULL_CLASS_SPEC,
247
    JS_NULL_CLASS_EXT,
248
    &sInterfaceObjectClassObjectOps
249
  },
250
  eInterface,
251
  true,
252
  prototypes::id::CSSFontFeatureValuesRule,
253
  PrototypeTraits<prototypes::id::CSSFontFeatureValuesRule>::Depth,
254
  sNativePropertyHooks,
255
  "function CSSFontFeatureValuesRule() {\n    [native code]\n}",
256
  CSSRule_Binding::GetConstructorObject
257
};
258
259
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
260
  {
261
    "CSSFontFeatureValuesRulePrototype",
262
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
263
    JS_NULL_CLASS_OPS,
264
    JS_NULL_CLASS_SPEC,
265
    JS_NULL_CLASS_EXT,
266
    JS_NULL_OBJECT_OPS
267
  },
268
  eInterfacePrototype,
269
  false,
270
  prototypes::id::CSSFontFeatureValuesRule,
271
  PrototypeTraits<prototypes::id::CSSFontFeatureValuesRule>::Depth,
272
  sNativePropertyHooks,
273
  "[object CSSFontFeatureValuesRulePrototype]",
274
  CSSRule_Binding::GetProtoObject
275
};
276
277
static const js::ClassOps sClassOps = {
278
  _addProperty, /* addProperty */
279
  nullptr,               /* delProperty */
280
  nullptr,               /* enumerate */
281
  nullptr, /* newEnumerate */
282
  nullptr, /* resolve */
283
  nullptr, /* mayResolve */
284
  _finalize, /* finalize */
285
  nullptr, /* call */
286
  nullptr,               /* hasInstance */
287
  nullptr,               /* construct */
288
  nullptr, /* trace */
289
};
290
291
static const js::ClassExtension sClassExtension = {
292
  nullptr, /* weakmapKeyDelegateOp */
293
  _objectMoved /* objectMovedOp */
294
};
295
296
static const DOMJSClass sClass = {
297
  { "CSSFontFeatureValuesRule",
298
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
299
    &sClassOps,
300
    JS_NULL_CLASS_SPEC,
301
    &sClassExtension,
302
    JS_NULL_OBJECT_OPS
303
  },
304
  { prototypes::id::CSSRule, prototypes::id::CSSFontFeatureValuesRule, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
305
  IsBaseOf<nsISupports, mozilla::dom::CSSFontFeatureValuesRule >::value,
306
  sNativePropertyHooks,
307
  FindAssociatedGlobalForNative<mozilla::dom::CSSFontFeatureValuesRule>::Get,
308
  GetProtoObjectHandle,
309
  GetCCParticipant<mozilla::dom::CSSFontFeatureValuesRule>::Get()
310
};
311
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
312
              "Must have the right minimal number of reserved slots.");
313
static_assert(1 >= 1,
314
              "Must have enough reserved slots.");
315
316
const JSClass*
317
GetJSClass()
318
0
{
319
0
  return sClass.ToJSClass();
320
0
}
321
322
bool
323
Wrap(JSContext* aCx, mozilla::dom::CSSFontFeatureValuesRule* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
324
0
{
325
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::CSSFontFeatureValuesRule>::value,
326
0
                "Shouldn't have wrappercached things that are not refcounted.");
327
0
  MOZ_ASSERT(static_cast<mozilla::dom::CSSFontFeatureValuesRule*>(aObject) ==
328
0
             reinterpret_cast<mozilla::dom::CSSFontFeatureValuesRule*>(aObject),
329
0
             "Multiple inheritance for mozilla::dom::CSSFontFeatureValuesRule is broken.");
330
0
  MOZ_ASSERT(static_cast<mozilla::css::Rule*>(aObject) ==
331
0
             reinterpret_cast<mozilla::css::Rule*>(aObject),
332
0
             "Multiple inheritance for mozilla::css::Rule is broken.");
333
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
334
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
335
0
  MOZ_ASSERT(!aCache->GetWrapper(),
336
0
             "You should probably not be using Wrap() directly; use "
337
0
             "GetOrCreateDOMReflector instead");
338
0
339
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
340
0
             "nsISupports must be on our primary inheritance chain");
341
0
342
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
343
0
  if (!global) {
344
0
    return false;
345
0
  }
346
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
347
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
348
0
349
0
  // That might have ended up wrapping us already, due to the wonders
350
0
  // of XBL.  Check for that, and bail out as needed.
351
0
  aReflector.set(aCache->GetWrapper());
352
0
  if (aReflector) {
353
#ifdef DEBUG
354
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
355
#endif // DEBUG
356
    return true;
357
0
  }
358
0
359
0
  JSAutoRealm ar(aCx, global);
360
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
361
0
  if (!canonicalProto) {
362
0
    return false;
363
0
  }
364
0
  JS::Rooted<JSObject*> proto(aCx);
365
0
  if (aGivenProto) {
366
0
    proto = aGivenProto;
367
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
368
0
    // coming in, we changed compartments to that of "parent" so may need
369
0
    // to wrap the proto here.
370
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
371
0
      if (!JS_WrapObject(aCx, &proto)) {
372
0
        return false;
373
0
      }
374
0
    }
375
0
  } else {
376
0
    proto = canonicalProto;
377
0
  }
378
0
379
0
  BindingJSObjectCreator<mozilla::dom::CSSFontFeatureValuesRule> creator(aCx);
380
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
381
0
  if (!aReflector) {
382
0
    return false;
383
0
  }
384
0
385
0
  aCache->SetWrapper(aReflector);
386
0
  creator.InitializationSucceeded();
387
0
388
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
389
0
             aCache->GetWrapperPreserveColor() == aReflector);
390
0
  // If proto != canonicalProto, we have to preserve our wrapper;
391
0
  // otherwise we won't be able to properly recreate it later, since
392
0
  // we won't know what proto to use.  Note that we don't check
393
0
  // aGivenProto here, since it's entirely possible (and even
394
0
  // somewhat common) to have a non-null aGivenProto which is the
395
0
  // same as canonicalProto.
396
0
  if (proto != canonicalProto) {
397
0
    PreserveWrapper(aObject);
398
0
  }
399
0
400
0
  return true;
401
0
}
402
403
const NativePropertyHooks sNativePropertyHooks[] = { {
404
  nullptr,
405
  nullptr,
406
  nullptr,
407
  { sNativeProperties.Upcast(), nullptr },
408
  prototypes::id::CSSFontFeatureValuesRule,
409
  constructors::id::CSSFontFeatureValuesRule,
410
  CSSRule_Binding::sNativePropertyHooks,
411
  &DefaultXrayExpandoObjectClass
412
} };
413
414
void
415
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
416
0
{
417
0
  JS::Handle<JSObject*> parentProto(CSSRule_Binding::GetProtoObjectHandle(aCx));
418
0
  if (!parentProto) {
419
0
    return;
420
0
  }
421
0
422
0
  JS::Handle<JSObject*> constructorProto(CSSRule_Binding::GetConstructorObjectHandle(aCx));
423
0
  if (!constructorProto) {
424
0
    return;
425
0
  }
426
0
427
0
  static bool sIdsInited = false;
428
0
  if (!sIdsInited && NS_IsMainThread()) {
429
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
430
0
      return;
431
0
    }
432
0
    sIdsInited = true;
433
0
  }
434
0
435
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::CSSFontFeatureValuesRule);
436
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::CSSFontFeatureValuesRule);
437
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
438
0
                              &sPrototypeClass.mBase, protoCache,
439
0
                              nullptr,
440
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
441
0
                              interfaceCache,
442
0
                              sNativeProperties.Upcast(),
443
0
                              nullptr,
444
0
                              "CSSFontFeatureValuesRule", aDefineOnGlobal,
445
0
                              nullptr,
446
0
                              false);
447
0
}
448
449
JSObject*
450
GetConstructorObject(JSContext* aCx)
451
0
{
452
0
  return GetConstructorObjectHandle(aCx);
453
0
}
454
455
} // namespace CSSFontFeatureValuesRule_Binding
456
457
458
459
} // namespace dom
460
} // namespace mozilla