Coverage Report

Created: 2018-09-25 14:53

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