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