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