Coverage Report

Created: 2018-09-25 14:53

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