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