Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/CSSMozDocumentRuleBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM CSSMozDocumentRule.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "CSSConditionRuleBinding.h"
4
#include "CSSMozDocumentRuleBinding.h"
5
#include "WrapperFactory.h"
6
#include "mozilla/OwningNonNull.h"
7
#include "mozilla/dom/BindingUtils.h"
8
#include "mozilla/dom/CSSMozDocumentRule.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 CSSMozDocumentRule_Binding {
21
22
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<CSSConditionRule_Binding::NativeType>::value,
23
              "Can't inherit from an interface with a different ownership model.");
24
25
static bool
26
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
27
0
{
28
0
  mozilla::dom::CSSMozDocumentRule* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CSSMozDocumentRule>(obj);
29
0
  // We don't want to preserve if we don't have a wrapper, and we
30
0
  // obviously can't preserve if we're not initialized.
31
0
  if (self && self->GetWrapperPreserveColor()) {
32
0
    PreserveWrapper(self);
33
0
  }
34
0
  return true;
35
0
}
36
37
static void
38
_finalize(js::FreeOp* fop, JSObject* obj)
39
0
{
40
0
  mozilla::dom::CSSMozDocumentRule* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CSSMozDocumentRule>(obj);
41
0
  if (self) {
42
0
    ClearWrapper(self, self, obj);
43
0
    AddForDeferredFinalization<mozilla::dom::CSSMozDocumentRule>(self);
44
0
  }
45
0
}
46
47
static size_t
48
_objectMoved(JSObject* obj, JSObject* old)
49
0
{
50
0
  mozilla::dom::CSSMozDocumentRule* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CSSMozDocumentRule>(obj);
51
0
  if (self) {
52
0
    UpdateWrapper(self, self, obj, old);
53
0
  }
54
0
55
0
  return 0;
56
0
}
57
58
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
59
  {
60
    "Function",
61
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
62
    &sBoringInterfaceObjectClassClassOps,
63
    JS_NULL_CLASS_SPEC,
64
    JS_NULL_CLASS_EXT,
65
    &sInterfaceObjectClassObjectOps
66
  },
67
  eInterface,
68
  true,
69
  prototypes::id::CSSMozDocumentRule,
70
  PrototypeTraits<prototypes::id::CSSMozDocumentRule>::Depth,
71
  sNativePropertyHooks,
72
  "function CSSMozDocumentRule() {\n    [native code]\n}",
73
  CSSConditionRule_Binding::GetConstructorObject
74
};
75
76
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
77
  {
78
    "CSSMozDocumentRulePrototype",
79
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
80
    JS_NULL_CLASS_OPS,
81
    JS_NULL_CLASS_SPEC,
82
    JS_NULL_CLASS_EXT,
83
    JS_NULL_OBJECT_OPS
84
  },
85
  eInterfacePrototype,
86
  false,
87
  prototypes::id::CSSMozDocumentRule,
88
  PrototypeTraits<prototypes::id::CSSMozDocumentRule>::Depth,
89
  sNativePropertyHooks,
90
  "[object CSSMozDocumentRulePrototype]",
91
  CSSConditionRule_Binding::GetProtoObject
92
};
93
94
static const js::ClassOps sClassOps = {
95
  _addProperty, /* addProperty */
96
  nullptr,               /* delProperty */
97
  nullptr,               /* enumerate */
98
  nullptr, /* newEnumerate */
99
  nullptr, /* resolve */
100
  nullptr, /* mayResolve */
101
  _finalize, /* finalize */
102
  nullptr, /* call */
103
  nullptr,               /* hasInstance */
104
  nullptr,               /* construct */
105
  nullptr, /* trace */
106
};
107
108
static const js::ClassExtension sClassExtension = {
109
  nullptr, /* weakmapKeyDelegateOp */
110
  _objectMoved /* objectMovedOp */
111
};
112
113
static const DOMJSClass sClass = {
114
  { "CSSMozDocumentRule",
115
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
116
    &sClassOps,
117
    JS_NULL_CLASS_SPEC,
118
    &sClassExtension,
119
    JS_NULL_OBJECT_OPS
120
  },
121
  { prototypes::id::CSSRule, prototypes::id::CSSGroupingRule, prototypes::id::CSSConditionRule, prototypes::id::CSSMozDocumentRule, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
122
  IsBaseOf<nsISupports, mozilla::dom::CSSMozDocumentRule >::value,
123
  sNativePropertyHooks,
124
  FindAssociatedGlobalForNative<mozilla::dom::CSSMozDocumentRule>::Get,
125
  GetProtoObjectHandle,
126
  GetCCParticipant<mozilla::dom::CSSMozDocumentRule>::Get()
127
};
128
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
129
              "Must have the right minimal number of reserved slots.");
130
static_assert(1 >= 1,
131
              "Must have enough reserved slots.");
132
133
const JSClass*
134
GetJSClass()
135
0
{
136
0
  return sClass.ToJSClass();
137
0
}
138
139
bool
140
Wrap(JSContext* aCx, mozilla::dom::CSSMozDocumentRule* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
141
0
{
142
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::CSSMozDocumentRule>::value,
143
0
                "Shouldn't have wrappercached things that are not refcounted.");
144
0
  MOZ_ASSERT(static_cast<mozilla::dom::CSSMozDocumentRule*>(aObject) ==
145
0
             reinterpret_cast<mozilla::dom::CSSMozDocumentRule*>(aObject),
146
0
             "Multiple inheritance for mozilla::dom::CSSMozDocumentRule is broken.");
147
0
  MOZ_ASSERT(static_cast<mozilla::css::ConditionRule*>(aObject) ==
148
0
             reinterpret_cast<mozilla::css::ConditionRule*>(aObject),
149
0
             "Multiple inheritance for mozilla::css::ConditionRule is broken.");
150
0
  MOZ_ASSERT(static_cast<mozilla::css::GroupRule*>(aObject) ==
151
0
             reinterpret_cast<mozilla::css::GroupRule*>(aObject),
152
0
             "Multiple inheritance for mozilla::css::GroupRule is broken.");
153
0
  MOZ_ASSERT(static_cast<mozilla::css::Rule*>(aObject) ==
154
0
             reinterpret_cast<mozilla::css::Rule*>(aObject),
155
0
             "Multiple inheritance for mozilla::css::Rule is broken.");
156
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
157
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
158
0
  MOZ_ASSERT(!aCache->GetWrapper(),
159
0
             "You should probably not be using Wrap() directly; use "
160
0
             "GetOrCreateDOMReflector instead");
161
0
162
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
163
0
             "nsISupports must be on our primary inheritance chain");
164
0
165
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
166
0
  if (!global) {
167
0
    return false;
168
0
  }
169
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
170
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
171
0
172
0
  // That might have ended up wrapping us already, due to the wonders
173
0
  // of XBL.  Check for that, and bail out as needed.
174
0
  aReflector.set(aCache->GetWrapper());
175
0
  if (aReflector) {
176
#ifdef DEBUG
177
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
178
#endif // DEBUG
179
    return true;
180
0
  }
181
0
182
0
  JSAutoRealm ar(aCx, global);
183
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
184
0
  if (!canonicalProto) {
185
0
    return false;
186
0
  }
187
0
  JS::Rooted<JSObject*> proto(aCx);
188
0
  if (aGivenProto) {
189
0
    proto = aGivenProto;
190
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
191
0
    // coming in, we changed compartments to that of "parent" so may need
192
0
    // to wrap the proto here.
193
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
194
0
      if (!JS_WrapObject(aCx, &proto)) {
195
0
        return false;
196
0
      }
197
0
    }
198
0
  } else {
199
0
    proto = canonicalProto;
200
0
  }
201
0
202
0
  BindingJSObjectCreator<mozilla::dom::CSSMozDocumentRule> creator(aCx);
203
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
204
0
  if (!aReflector) {
205
0
    return false;
206
0
  }
207
0
208
0
  aCache->SetWrapper(aReflector);
209
0
  creator.InitializationSucceeded();
210
0
211
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
212
0
             aCache->GetWrapperPreserveColor() == aReflector);
213
0
  // If proto != canonicalProto, we have to preserve our wrapper;
214
0
  // otherwise we won't be able to properly recreate it later, since
215
0
  // we won't know what proto to use.  Note that we don't check
216
0
  // aGivenProto here, since it's entirely possible (and even
217
0
  // somewhat common) to have a non-null aGivenProto which is the
218
0
  // same as canonicalProto.
219
0
  if (proto != canonicalProto) {
220
0
    PreserveWrapper(aObject);
221
0
  }
222
0
223
0
  return true;
224
0
}
225
226
const NativePropertyHooks sNativePropertyHooks[] = { {
227
  nullptr,
228
  nullptr,
229
  nullptr,
230
  { nullptr, nullptr },
231
  prototypes::id::CSSMozDocumentRule,
232
  constructors::id::CSSMozDocumentRule,
233
  CSSConditionRule_Binding::sNativePropertyHooks,
234
  &DefaultXrayExpandoObjectClass
235
} };
236
237
void
238
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
239
0
{
240
0
  JS::Handle<JSObject*> parentProto(CSSConditionRule_Binding::GetProtoObjectHandle(aCx));
241
0
  if (!parentProto) {
242
0
    return;
243
0
  }
244
0
245
0
  JS::Handle<JSObject*> constructorProto(CSSConditionRule_Binding::GetConstructorObjectHandle(aCx));
246
0
  if (!constructorProto) {
247
0
    return;
248
0
  }
249
0
250
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::CSSMozDocumentRule);
251
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::CSSMozDocumentRule);
252
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
253
0
                              &sPrototypeClass.mBase, protoCache,
254
0
                              nullptr,
255
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
256
0
                              interfaceCache,
257
0
                              nullptr,
258
0
                              nullptr,
259
0
                              "CSSMozDocumentRule", aDefineOnGlobal,
260
0
                              nullptr,
261
0
                              false);
262
0
}
263
264
JSObject*
265
GetConstructorObject(JSContext* aCx)
266
0
{
267
0
  return GetConstructorObjectHandle(aCx);
268
0
}
269
270
} // namespace CSSMozDocumentRule_Binding
271
272
273
274
} // namespace dom
275
} // namespace mozilla