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