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