Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/CSSRuleBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM CSSRule.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "CSSRuleBinding.h"
4
#include "WrapperFactory.h"
5
#include "mozilla/OwningNonNull.h"
6
#include "mozilla/StyleSheet.h"
7
#include "mozilla/css/Rule.h"
8
#include "mozilla/dom/BindingUtils.h"
9
#include "mozilla/dom/DOMJSClass.h"
10
#include "mozilla/dom/NonRefcountedDOMObject.h"
11
#include "mozilla/dom/Nullable.h"
12
#include "mozilla/dom/PrimitiveConversions.h"
13
#include "mozilla/dom/XrayExpandoClass.h"
14
#include "nsContentUtils.h"
15
16
namespace mozilla {
17
namespace dom {
18
19
namespace binding_detail {}; // Just to make sure it's known as a namespace
20
using namespace mozilla::dom::binding_detail;
21
22
23
namespace CSSRule_Binding {
24
25
MOZ_CAN_RUN_SCRIPT static bool
26
get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::css::Rule* self, JSJitGetterCallArgs args)
27
0
{
28
0
  AUTO_PROFILER_LABEL_FAST("get CSSRule.type", DOM, cx);
29
0
30
0
  uint16_t result(self->Type());
31
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
32
0
  args.rval().setInt32(int32_t(result));
33
0
  return true;
34
0
}
35
36
static const JSJitInfo type_getterinfo = {
37
  { (JSJitGetterOp)get_type },
38
  { prototypes::id::CSSRule },
39
  { PrototypeTraits<prototypes::id::CSSRule>::Depth },
40
  JSJitInfo::Getter,
41
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
42
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
43
  true,  /* isInfallible. False in setters. */
44
  false,  /* isMovable.  Not relevant for setters. */
45
  false, /* isEliminatable.  Not relevant for setters. */
46
  false, /* isAlwaysInSlot.  Only relevant for getters. */
47
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
48
  false,  /* isTypedMethod.  Only relevant for methods. */
49
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
50
};
51
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
52
static_assert(0 < 1, "There is no slot for us");
53
54
MOZ_CAN_RUN_SCRIPT static bool
55
get_cssText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::css::Rule* self, JSJitGetterCallArgs args)
56
0
{
57
0
  AUTO_PROFILER_LABEL_FAST("get CSSRule.cssText", DOM, cx);
58
0
59
0
  DOMString result;
60
0
  self->GetCssText(result);
61
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
62
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
63
0
    return false;
64
0
  }
65
0
  return true;
66
0
}
67
68
MOZ_CAN_RUN_SCRIPT static bool
69
set_cssText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::css::Rule* self, JSJitSetterCallArgs args)
70
0
{
71
0
  AUTO_PROFILER_LABEL_FAST("set CSSRule.cssText", DOM, cx);
72
0
73
0
  binding_detail::FakeString arg0;
74
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
75
0
    return false;
76
0
  }
77
0
  self->SetCssText(NonNullHelper(Constify(arg0)));
78
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
79
0
80
0
  return true;
81
0
}
82
83
static const JSJitInfo cssText_getterinfo = {
84
  { (JSJitGetterOp)get_cssText },
85
  { prototypes::id::CSSRule },
86
  { PrototypeTraits<prototypes::id::CSSRule>::Depth },
87
  JSJitInfo::Getter,
88
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
89
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
90
  false,  /* isInfallible. False in setters. */
91
  false,  /* isMovable.  Not relevant for setters. */
92
  false, /* isEliminatable.  Not relevant for setters. */
93
  false, /* isAlwaysInSlot.  Only relevant for getters. */
94
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
95
  false,  /* isTypedMethod.  Only relevant for methods. */
96
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
97
};
98
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
99
static_assert(0 < 1, "There is no slot for us");
100
static const JSJitInfo cssText_setterinfo = {
101
  { (JSJitGetterOp)set_cssText },
102
  { prototypes::id::CSSRule },
103
  { PrototypeTraits<prototypes::id::CSSRule>::Depth },
104
  JSJitInfo::Setter,
105
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
106
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
107
  false,  /* isInfallible. False in setters. */
108
  false,  /* isMovable.  Not relevant for setters. */
109
  false, /* isEliminatable.  Not relevant for setters. */
110
  false, /* isAlwaysInSlot.  Only relevant for getters. */
111
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
112
  false,  /* isTypedMethod.  Only relevant for methods. */
113
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
114
};
115
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
116
static_assert(0 < 1, "There is no slot for us");
117
118
MOZ_CAN_RUN_SCRIPT static bool
119
get_parentRule(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::css::Rule* self, JSJitGetterCallArgs args)
120
0
{
121
0
  AUTO_PROFILER_LABEL_FAST("get CSSRule.parentRule", DOM, cx);
122
0
123
0
  auto result(StrongOrRawPtr<mozilla::css::Rule>(self->GetParentRule()));
124
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
125
0
  if (!result) {
126
0
    args.rval().setNull();
127
0
    return true;
128
0
  }
129
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
130
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
131
0
    return false;
132
0
  }
133
0
  return true;
134
0
}
135
136
static const JSJitInfo parentRule_getterinfo = {
137
  { (JSJitGetterOp)get_parentRule },
138
  { prototypes::id::CSSRule },
139
  { PrototypeTraits<prototypes::id::CSSRule>::Depth },
140
  JSJitInfo::Getter,
141
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
142
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
143
  false,  /* isInfallible. False in setters. */
144
  false,  /* isMovable.  Not relevant for setters. */
145
  false, /* isEliminatable.  Not relevant for setters. */
146
  false, /* isAlwaysInSlot.  Only relevant for getters. */
147
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
148
  false,  /* isTypedMethod.  Only relevant for methods. */
149
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
150
};
151
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
152
static_assert(0 < 1, "There is no slot for us");
153
154
MOZ_CAN_RUN_SCRIPT static bool
155
get_parentStyleSheet(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::css::Rule* self, JSJitGetterCallArgs args)
156
0
{
157
0
  AUTO_PROFILER_LABEL_FAST("get CSSRule.parentStyleSheet", DOM, cx);
158
0
159
0
  auto result(StrongOrRawPtr<mozilla::StyleSheet>(self->GetParentStyleSheet()));
160
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
161
0
  if (!result) {
162
0
    args.rval().setNull();
163
0
    return true;
164
0
  }
165
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
166
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
167
0
    return false;
168
0
  }
169
0
  return true;
170
0
}
171
172
static const JSJitInfo parentStyleSheet_getterinfo = {
173
  { (JSJitGetterOp)get_parentStyleSheet },
174
  { prototypes::id::CSSRule },
175
  { PrototypeTraits<prototypes::id::CSSRule>::Depth },
176
  JSJitInfo::Getter,
177
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
178
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
179
  false,  /* isInfallible. False in setters. */
180
  false,  /* isMovable.  Not relevant for setters. */
181
  false, /* isEliminatable.  Not relevant for setters. */
182
  false, /* isAlwaysInSlot.  Only relevant for getters. */
183
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
184
  false,  /* isTypedMethod.  Only relevant for methods. */
185
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
186
};
187
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
188
static_assert(0 < 1, "There is no slot for us");
189
190
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
191
#if defined(__clang__)
192
#pragma clang diagnostic push
193
#pragma clang diagnostic ignored "-Wmissing-braces"
194
#endif
195
static const JSPropertySpec sAttributes_specs[] = {
196
  { "type", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &type_getterinfo, nullptr, nullptr },
197
  { "cssText", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &cssText_getterinfo, GenericSetter<NormalThisPolicy>, &cssText_setterinfo },
198
  { "parentRule", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &parentRule_getterinfo, nullptr, nullptr },
199
  { "parentStyleSheet", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &parentStyleSheet_getterinfo, nullptr, nullptr },
200
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
201
};
202
#if defined(__clang__)
203
#pragma clang diagnostic pop
204
#endif
205
206
207
static const Prefable<const JSPropertySpec> sAttributes[] = {
208
  { nullptr, &sAttributes_specs[0] },
209
  { nullptr, nullptr }
210
};
211
212
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
213
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
214
static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
215
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
216
217
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
218
#if defined(__clang__)
219
#pragma clang diagnostic push
220
#pragma clang diagnostic ignored "-Wmissing-braces"
221
#endif
222
static const ConstantSpec sConstants_specs[] = {
223
  { "STYLE_RULE", JS::Int32Value(1) },
224
  { "CHARSET_RULE", JS::Int32Value(2) },
225
  { "IMPORT_RULE", JS::Int32Value(3) },
226
  { "MEDIA_RULE", JS::Int32Value(4) },
227
  { "FONT_FACE_RULE", JS::Int32Value(5) },
228
  { "PAGE_RULE", JS::Int32Value(6) },
229
  { "NAMESPACE_RULE", JS::Int32Value(10) },
230
  { "KEYFRAMES_RULE", JS::Int32Value(7) },
231
  { "KEYFRAME_RULE", JS::Int32Value(8) },
232
  { "COUNTER_STYLE_RULE", JS::Int32Value(11) },
233
  { "SUPPORTS_RULE", JS::Int32Value(12) },
234
  { "FONT_FEATURE_VALUES_RULE", JS::Int32Value(14) },
235
  { 0, JS::UndefinedValue() }
236
};
237
#if defined(__clang__)
238
#pragma clang diagnostic pop
239
#endif
240
241
242
static const Prefable<const ConstantSpec> sConstants[] = {
243
  { nullptr, &sConstants_specs[0] },
244
  { nullptr, nullptr }
245
};
246
247
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
248
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
249
static_assert(12 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
250
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
251
252
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
253
#if defined(__clang__)
254
#pragma clang diagnostic push
255
#pragma clang diagnostic ignored "-Wmissing-braces"
256
#endif
257
static const ConstantSpec sChromeConstants_specs[] = {
258
  { "DOCUMENT_RULE", JS::Int32Value(13) },
259
  { 0, JS::UndefinedValue() }
260
};
261
#if defined(__clang__)
262
#pragma clang diagnostic pop
263
#endif
264
265
266
static const Prefable<const ConstantSpec> sChromeConstants[] = {
267
  { nullptr, &sChromeConstants_specs[0] },
268
  { nullptr, nullptr }
269
};
270
271
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
272
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
273
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
274
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
275
276
277
static uint16_t sNativeProperties_sortedPropertyIndices[16];
278
static PropertyInfo sNativeProperties_propertyInfos[16];
279
280
static const NativePropertiesN<2> sNativeProperties = {
281
  false, 0,
282
  false, 0,
283
  false, 0,
284
  true,  0 /* sAttributes */,
285
  false, 0,
286
  false, 0,
287
  true,  1 /* sConstants */,
288
  -1,
289
  16,
290
  sNativeProperties_sortedPropertyIndices,
291
  {
292
    { sAttributes, &sNativeProperties_propertyInfos[0] },
293
    { sConstants, &sNativeProperties_propertyInfos[4] }
294
  }
295
};
296
static_assert(16 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
297
    "We have a property info count that is oversized");
298
299
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
300
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
301
302
static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
303
  false, 0,
304
  false, 0,
305
  false, 0,
306
  false, 0,
307
  false, 0,
308
  false, 0,
309
  true,  0 /* sChromeConstants */,
310
  -1,
311
  1,
312
  sChromeOnlyNativeProperties_sortedPropertyIndices,
313
  {
314
    { sChromeConstants, &sChromeOnlyNativeProperties_propertyInfos[0] }
315
  }
316
};
317
static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
318
    "We have a property info count that is oversized");
319
320
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
321
  {
322
    "Function",
323
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
324
    &sBoringInterfaceObjectClassClassOps,
325
    JS_NULL_CLASS_SPEC,
326
    JS_NULL_CLASS_EXT,
327
    &sInterfaceObjectClassObjectOps
328
  },
329
  eInterface,
330
  true,
331
  prototypes::id::CSSRule,
332
  PrototypeTraits<prototypes::id::CSSRule>::Depth,
333
  sNativePropertyHooks,
334
  "function CSSRule() {\n    [native code]\n}",
335
  JS::GetRealmFunctionPrototype
336
};
337
338
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
339
  {
340
    "CSSRulePrototype",
341
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
342
    JS_NULL_CLASS_OPS,
343
    JS_NULL_CLASS_SPEC,
344
    JS_NULL_CLASS_EXT,
345
    JS_NULL_OBJECT_OPS
346
  },
347
  eInterfacePrototype,
348
  false,
349
  prototypes::id::CSSRule,
350
  PrototypeTraits<prototypes::id::CSSRule>::Depth,
351
  sNativePropertyHooks,
352
  "[object CSSRulePrototype]",
353
  JS::GetRealmObjectPrototype
354
};
355
356
const NativePropertyHooks sNativePropertyHooks[] = { {
357
  nullptr,
358
  nullptr,
359
  nullptr,
360
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
361
  prototypes::id::CSSRule,
362
  constructors::id::CSSRule,
363
  nullptr,
364
  &DefaultXrayExpandoObjectClass
365
} };
366
367
void
368
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
369
0
{
370
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
371
0
  if (!parentProto) {
372
0
    return;
373
0
  }
374
0
375
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
376
0
  if (!constructorProto) {
377
0
    return;
378
0
  }
379
0
380
0
  static bool sIdsInited = false;
381
0
  if (!sIdsInited && NS_IsMainThread()) {
382
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
383
0
      return;
384
0
    }
385
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
386
0
      return;
387
0
    }
388
0
    sIdsInited = true;
389
0
  }
390
0
391
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::CSSRule);
392
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::CSSRule);
393
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
394
0
                              &sPrototypeClass.mBase, protoCache,
395
0
                              nullptr,
396
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
397
0
                              interfaceCache,
398
0
                              sNativeProperties.Upcast(),
399
0
                              sChromeOnlyNativeProperties.Upcast(),
400
0
                              "CSSRule", aDefineOnGlobal,
401
0
                              nullptr,
402
0
                              false);
403
0
}
404
405
JSObject*
406
GetProtoObject(JSContext* aCx)
407
0
{
408
0
  return GetProtoObjectHandle(aCx);
409
0
}
410
411
JSObject*
412
GetConstructorObject(JSContext* aCx)
413
0
{
414
0
  return GetConstructorObjectHandle(aCx);
415
0
}
416
417
} // namespace CSSRule_Binding
418
419
420
421
} // namespace dom
422
} // namespace mozilla