Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM HTMLParamElement.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "HTMLElementBinding.h"
4 : #include "HTMLParamElementBinding.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/HTMLSharedElement.h"
11 : #include "mozilla/dom/NonRefcountedDOMObject.h"
12 : #include "mozilla/dom/XrayExpandoClass.h"
13 :
14 : namespace mozilla {
15 : namespace dom {
16 :
17 : namespace HTMLParamElementBinding {
18 :
19 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<HTMLElementBinding::NativeType>::value,
20 : "Can't inherit from an interface with a different ownership model.");
21 :
22 : static bool
23 0 : get_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedElement* self, JSJitGetterCallArgs args)
24 : {
25 0 : DOMString result;
26 0 : self->GetName(result);
27 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
28 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
29 0 : return false;
30 : }
31 0 : return true;
32 : }
33 :
34 : static bool
35 0 : set_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedElement* self, JSJitSetterCallArgs args)
36 : {
37 0 : binding_detail::FakeString arg0;
38 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
39 0 : return false;
40 : }
41 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
42 0 : Maybe<AutoCEReaction> ceReaction;
43 0 : if (reactionsStack) {
44 0 : ceReaction.emplace(reactionsStack);
45 : }
46 0 : binding_detail::FastErrorResult rv;
47 0 : self->SetName(NonNullHelper(Constify(arg0)), rv);
48 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
49 0 : return false;
50 : }
51 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
52 :
53 0 : return true;
54 : }
55 :
56 : static const JSJitInfo name_getterinfo = {
57 : { (JSJitGetterOp)get_name },
58 : { prototypes::id::HTMLParamElement },
59 : { PrototypeTraits<prototypes::id::HTMLParamElement>::Depth },
60 : JSJitInfo::Getter,
61 : JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */
62 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
63 : false, /* isInfallible. False in setters. */
64 : true, /* isMovable. Not relevant for setters. */
65 : true, /* isEliminatable. Not relevant for setters. */
66 : false, /* isAlwaysInSlot. Only relevant for getters. */
67 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
68 : false, /* isTypedMethod. Only relevant for methods. */
69 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
70 : };
71 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
72 : static_assert(0 < 1, "There is no slot for us");
73 : static const JSJitInfo name_setterinfo = {
74 : { (JSJitGetterOp)set_name },
75 : { prototypes::id::HTMLParamElement },
76 : { PrototypeTraits<prototypes::id::HTMLParamElement>::Depth },
77 : JSJitInfo::Setter,
78 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
79 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
80 : false, /* isInfallible. False in setters. */
81 : false, /* isMovable. Not relevant for setters. */
82 : false, /* isEliminatable. Not relevant for setters. */
83 : false, /* isAlwaysInSlot. Only relevant for getters. */
84 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
85 : false, /* isTypedMethod. Only relevant for methods. */
86 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
87 : };
88 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
89 : static_assert(0 < 1, "There is no slot for us");
90 :
91 : static bool
92 0 : get_value(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedElement* self, JSJitGetterCallArgs args)
93 : {
94 0 : DOMString result;
95 0 : self->GetValue(result);
96 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
97 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
98 0 : return false;
99 : }
100 0 : return true;
101 : }
102 :
103 : static bool
104 0 : set_value(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedElement* self, JSJitSetterCallArgs args)
105 : {
106 0 : binding_detail::FakeString arg0;
107 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
108 0 : return false;
109 : }
110 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
111 0 : Maybe<AutoCEReaction> ceReaction;
112 0 : if (reactionsStack) {
113 0 : ceReaction.emplace(reactionsStack);
114 : }
115 0 : binding_detail::FastErrorResult rv;
116 0 : self->SetValue(NonNullHelper(Constify(arg0)), rv);
117 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
118 0 : return false;
119 : }
120 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
121 :
122 0 : return true;
123 : }
124 :
125 : static const JSJitInfo value_getterinfo = {
126 : { (JSJitGetterOp)get_value },
127 : { prototypes::id::HTMLParamElement },
128 : { PrototypeTraits<prototypes::id::HTMLParamElement>::Depth },
129 : JSJitInfo::Getter,
130 : JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */
131 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
132 : false, /* isInfallible. False in setters. */
133 : true, /* isMovable. Not relevant for setters. */
134 : true, /* isEliminatable. Not relevant for setters. */
135 : false, /* isAlwaysInSlot. Only relevant for getters. */
136 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
137 : false, /* isTypedMethod. Only relevant for methods. */
138 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
139 : };
140 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
141 : static_assert(0 < 1, "There is no slot for us");
142 : static const JSJitInfo value_setterinfo = {
143 : { (JSJitGetterOp)set_value },
144 : { prototypes::id::HTMLParamElement },
145 : { PrototypeTraits<prototypes::id::HTMLParamElement>::Depth },
146 : JSJitInfo::Setter,
147 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
148 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
149 : false, /* isInfallible. False in setters. */
150 : false, /* isMovable. Not relevant for setters. */
151 : false, /* isEliminatable. Not relevant for setters. */
152 : false, /* isAlwaysInSlot. Only relevant for getters. */
153 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
154 : false, /* isTypedMethod. Only relevant for methods. */
155 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
156 : };
157 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
158 : static_assert(0 < 1, "There is no slot for us");
159 :
160 : static bool
161 0 : get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedElement* self, JSJitGetterCallArgs args)
162 : {
163 0 : DOMString result;
164 0 : self->GetType(result);
165 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
166 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
167 0 : return false;
168 : }
169 0 : return true;
170 : }
171 :
172 : static bool
173 0 : set_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedElement* self, JSJitSetterCallArgs args)
174 : {
175 0 : binding_detail::FakeString arg0;
176 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
177 0 : return false;
178 : }
179 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
180 0 : Maybe<AutoCEReaction> ceReaction;
181 0 : if (reactionsStack) {
182 0 : ceReaction.emplace(reactionsStack);
183 : }
184 0 : binding_detail::FastErrorResult rv;
185 0 : self->SetType(NonNullHelper(Constify(arg0)), rv);
186 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
187 0 : return false;
188 : }
189 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
190 :
191 0 : return true;
192 : }
193 :
194 : static const JSJitInfo type_getterinfo = {
195 : { (JSJitGetterOp)get_type },
196 : { prototypes::id::HTMLParamElement },
197 : { PrototypeTraits<prototypes::id::HTMLParamElement>::Depth },
198 : JSJitInfo::Getter,
199 : JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */
200 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
201 : false, /* isInfallible. False in setters. */
202 : true, /* isMovable. Not relevant for setters. */
203 : true, /* isEliminatable. Not relevant for setters. */
204 : false, /* isAlwaysInSlot. Only relevant for getters. */
205 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
206 : false, /* isTypedMethod. Only relevant for methods. */
207 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
208 : };
209 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
210 : static_assert(0 < 1, "There is no slot for us");
211 : static const JSJitInfo type_setterinfo = {
212 : { (JSJitGetterOp)set_type },
213 : { prototypes::id::HTMLParamElement },
214 : { PrototypeTraits<prototypes::id::HTMLParamElement>::Depth },
215 : JSJitInfo::Setter,
216 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
217 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
218 : false, /* isInfallible. False in setters. */
219 : false, /* isMovable. Not relevant for setters. */
220 : false, /* isEliminatable. Not relevant for setters. */
221 : false, /* isAlwaysInSlot. Only relevant for getters. */
222 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
223 : false, /* isTypedMethod. Only relevant for methods. */
224 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
225 : };
226 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
227 : static_assert(0 < 1, "There is no slot for us");
228 :
229 : static bool
230 0 : get_valueType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedElement* self, JSJitGetterCallArgs args)
231 : {
232 0 : DOMString result;
233 0 : self->GetValueType(result);
234 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
235 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
236 0 : return false;
237 : }
238 0 : return true;
239 : }
240 :
241 : static bool
242 0 : set_valueType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedElement* self, JSJitSetterCallArgs args)
243 : {
244 0 : binding_detail::FakeString arg0;
245 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
246 0 : return false;
247 : }
248 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
249 0 : Maybe<AutoCEReaction> ceReaction;
250 0 : if (reactionsStack) {
251 0 : ceReaction.emplace(reactionsStack);
252 : }
253 0 : binding_detail::FastErrorResult rv;
254 0 : self->SetValueType(NonNullHelper(Constify(arg0)), rv);
255 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
256 0 : return false;
257 : }
258 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
259 :
260 0 : return true;
261 : }
262 :
263 : static const JSJitInfo valueType_getterinfo = {
264 : { (JSJitGetterOp)get_valueType },
265 : { prototypes::id::HTMLParamElement },
266 : { PrototypeTraits<prototypes::id::HTMLParamElement>::Depth },
267 : JSJitInfo::Getter,
268 : JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */
269 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
270 : false, /* isInfallible. False in setters. */
271 : true, /* isMovable. Not relevant for setters. */
272 : true, /* isEliminatable. Not relevant for setters. */
273 : false, /* isAlwaysInSlot. Only relevant for getters. */
274 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
275 : false, /* isTypedMethod. Only relevant for methods. */
276 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
277 : };
278 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
279 : static_assert(0 < 1, "There is no slot for us");
280 : static const JSJitInfo valueType_setterinfo = {
281 : { (JSJitGetterOp)set_valueType },
282 : { prototypes::id::HTMLParamElement },
283 : { PrototypeTraits<prototypes::id::HTMLParamElement>::Depth },
284 : JSJitInfo::Setter,
285 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
286 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
287 : false, /* isInfallible. False in setters. */
288 : false, /* isMovable. Not relevant for setters. */
289 : false, /* isEliminatable. Not relevant for setters. */
290 : false, /* isAlwaysInSlot. Only relevant for getters. */
291 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
292 : false, /* isTypedMethod. Only relevant for methods. */
293 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
294 : };
295 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
296 : static_assert(0 < 1, "There is no slot for us");
297 :
298 : static bool
299 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
300 : {
301 0 : mozilla::dom::HTMLSharedElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLSharedElement>(obj);
302 : // We don't want to preserve if we don't have a wrapper, and we
303 : // obviously can't preserve if we're not initialized.
304 0 : if (self && self->GetWrapperPreserveColor()) {
305 0 : PreserveWrapper(self);
306 : }
307 0 : return true;
308 : }
309 :
310 : static void
311 0 : _finalize(js::FreeOp* fop, JSObject* obj)
312 : {
313 0 : mozilla::dom::HTMLSharedElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLSharedElement>(obj);
314 0 : if (self) {
315 0 : ClearWrapper(self, self, obj);
316 0 : AddForDeferredFinalization<mozilla::dom::HTMLSharedElement>(self);
317 : }
318 0 : }
319 :
320 : static void
321 0 : _objectMoved(JSObject* obj, const JSObject* old)
322 : {
323 0 : mozilla::dom::HTMLSharedElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLSharedElement>(obj);
324 0 : if (self) {
325 0 : UpdateWrapper(self, self, obj, old);
326 : }
327 0 : }
328 :
329 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
330 : #if defined(__clang__)
331 : #pragma clang diagnostic push
332 : #pragma clang diagnostic ignored "-Wmissing-braces"
333 : #endif
334 : static const JSPropertySpec sAttributes_specs[] = {
335 : { "name", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &name_getterinfo, GenericBindingSetter, &name_setterinfo },
336 : { "value", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &value_getterinfo, GenericBindingSetter, &value_setterinfo },
337 : { "type", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &type_getterinfo, GenericBindingSetter, &type_setterinfo },
338 : { "valueType", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &valueType_getterinfo, GenericBindingSetter, &valueType_setterinfo },
339 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
340 : };
341 : #if defined(__clang__)
342 : #pragma clang diagnostic pop
343 : #endif
344 :
345 :
346 : // Can't be const because the pref-enabled boolean needs to be writable
347 : static Prefable<const JSPropertySpec> sAttributes[] = {
348 : { nullptr, &sAttributes_specs[0] },
349 : { nullptr, nullptr }
350 : };
351 :
352 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
353 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
354 : static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
355 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
356 :
357 :
358 : static uint16_t sNativeProperties_sortedPropertyIndices[4];
359 : static PropertyInfo sNativeProperties_propertyInfos[4];
360 :
361 : static const NativePropertiesN<1> sNativeProperties = {
362 : false, 0,
363 : false, 0,
364 : false, 0,
365 : true, 0 /* sAttributes */,
366 : false, 0,
367 : false, 0,
368 : false, 0,
369 : -1,
370 : 4,
371 : sNativeProperties_sortedPropertyIndices,
372 : {
373 : { sAttributes, &sNativeProperties_propertyInfos[0] }
374 : }
375 : };
376 : static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
377 : "We have a property info count that is oversized");
378 :
379 : static bool
380 0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
381 : {
382 0 : JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
383 0 : JS::Rooted<JSObject*> obj(cx, &args.callee());
384 0 : if (!args.isConstructing()) {
385 : // XXXbz wish I could get the name from the callee instead of
386 : // Adding more relocations
387 0 : return ThrowConstructorWithoutNew(cx, "HTMLParamElement");
388 : }
389 :
390 0 : GlobalObject global(cx, obj);
391 0 : if (global.Failed()) {
392 0 : return false;
393 : }
394 :
395 : // The newTarget might be a cross-compartment wrapper. Get the underlying object
396 : // so we can do the spec's object-identity checks.
397 0 : JS::Rooted<JSObject*> newTarget(cx, js::CheckedUnwrap(&args.newTarget().toObject()));
398 0 : if (!newTarget) {
399 0 : return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
400 : }
401 :
402 : // Step 2 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor.
403 : // Enter the compartment of our underlying newTarget object, so we end
404 : // up comparing to the constructor object for our interface from that global.
405 : {
406 0 : JSAutoCompartment ac(cx, newTarget);
407 0 : JS::Handle<JSObject*> constructor(GetConstructorObjectHandle(cx));
408 0 : if (!constructor) {
409 0 : return false;
410 : }
411 0 : if (newTarget == constructor) {
412 0 : return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
413 : }
414 : }
415 :
416 0 : JS::Rooted<JSObject*> desiredProto(cx);
417 0 : if (!GetDesiredProto(cx, args, &desiredProto)) {
418 0 : return false;
419 : }
420 0 : if (!desiredProto) {
421 : // Step 7 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor.
422 : // This fallback behavior is designed to match analogous behavior for the
423 : // JavaScript built-ins. So we enter the compartment of our underlying
424 : // newTarget object and fall back to the prototype object from that global.
425 : // XXX The spec says to use GetFunctionRealm(), which is not actually
426 : // the same thing as what we have here (e.g. in the case of scripted callable proxies
427 : // whose target is not same-compartment with the proxy, or bound functions, etc).
428 : // https://bugzilla.mozilla.org/show_bug.cgi?id=1317658
429 : {
430 0 : JSAutoCompartment ac(cx, newTarget);
431 0 : desiredProto = GetProtoObjectHandle(cx);
432 0 : if (!desiredProto) {
433 0 : return false;
434 : }
435 : }
436 :
437 : // desiredProto is in the compartment of the underlying newTarget object.
438 : // Wrap it into the context compartment.
439 0 : if (!JS_WrapObject(cx, &desiredProto)) {
440 0 : return false;
441 : }
442 : }
443 :
444 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
445 0 : Maybe<JSAutoCompartment> ac;
446 0 : if (objIsXray) {
447 0 : obj = js::CheckedUnwrap(obj);
448 0 : if (!obj) {
449 0 : return false;
450 : }
451 0 : ac.emplace(cx, obj);
452 0 : if (!JS_WrapObject(cx, &desiredProto)) {
453 0 : return false;
454 : }
455 : }
456 0 : binding_detail::FastErrorResult rv;
457 0 : auto result(StrongOrRawPtr<mozilla::dom::HTMLSharedElement>(CreateHTMLElement(global, args, rv)));
458 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
459 0 : return false;
460 : }
461 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
462 : static_assert(!IsPointer<decltype(result)>::value,
463 : "NewObject implies that we need to keep the object alive with a strong reference.");
464 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
465 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
466 0 : return false;
467 : }
468 0 : return true;
469 : }
470 :
471 : static const js::ClassOps sInterfaceObjectClassOps = {
472 : nullptr, /* addProperty */
473 : nullptr, /* delProperty */
474 : nullptr, /* getProperty */
475 : nullptr, /* setProperty */
476 : nullptr, /* enumerate */
477 : nullptr, /* newEnumerate */
478 : nullptr, /* resolve */
479 : nullptr, /* mayResolve */
480 : nullptr, /* finalize */
481 : _constructor, /* call */
482 : nullptr, /* hasInstance */
483 : _constructor, /* construct */
484 : nullptr, /* trace */
485 : };
486 :
487 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
488 : {
489 : "Function",
490 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
491 : &sInterfaceObjectClassOps,
492 : JS_NULL_CLASS_SPEC,
493 : JS_NULL_CLASS_EXT,
494 : &sInterfaceObjectClassObjectOps
495 : },
496 : eInterface,
497 : true,
498 : prototypes::id::HTMLParamElement,
499 : PrototypeTraits<prototypes::id::HTMLParamElement>::Depth,
500 : sNativePropertyHooks,
501 : "function HTMLParamElement() {\n [native code]\n}",
502 : HTMLElementBinding::GetConstructorObject
503 : };
504 :
505 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
506 : {
507 : "HTMLParamElementPrototype",
508 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
509 : JS_NULL_CLASS_OPS,
510 : JS_NULL_CLASS_SPEC,
511 : JS_NULL_CLASS_EXT,
512 : JS_NULL_OBJECT_OPS
513 : },
514 : eInterfacePrototype,
515 : false,
516 : prototypes::id::HTMLParamElement,
517 : PrototypeTraits<prototypes::id::HTMLParamElement>::Depth,
518 : sNativePropertyHooks,
519 : "[object HTMLParamElementPrototype]",
520 : HTMLElementBinding::GetProtoObject
521 : };
522 :
523 : JSObject*
524 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
525 : {
526 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
527 : }
528 :
529 : static const js::ClassOps sClassOps = {
530 : _addProperty, /* addProperty */
531 : nullptr, /* delProperty */
532 : nullptr, /* getProperty */
533 : nullptr, /* setProperty */
534 : nullptr, /* enumerate */
535 : nullptr, /* newEnumerate */
536 : nullptr, /* resolve */
537 : nullptr, /* mayResolve */
538 : _finalize, /* finalize */
539 : nullptr, /* call */
540 : nullptr, /* hasInstance */
541 : nullptr, /* construct */
542 : nullptr, /* trace */
543 : };
544 :
545 : static const js::ClassExtension sClassExtension = {
546 : nullptr, /* weakmapKeyDelegateOp */
547 : _objectMoved /* objectMovedOp */
548 : };
549 :
550 : static const DOMJSClass sClass = {
551 : { "HTMLParamElement",
552 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
553 : &sClassOps,
554 : JS_NULL_CLASS_SPEC,
555 : &sClassExtension,
556 : JS_NULL_OBJECT_OPS
557 : },
558 : { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLParamElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
559 : IsBaseOf<nsISupports, mozilla::dom::HTMLSharedElement >::value,
560 : sNativePropertyHooks,
561 : FindAssociatedGlobalForNative<mozilla::dom::HTMLSharedElement>::Get,
562 : GetProtoObjectHandle,
563 : GetCCParticipant<mozilla::dom::HTMLSharedElement>::Get()
564 : };
565 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
566 : "Must have the right minimal number of reserved slots.");
567 : static_assert(1 >= 1,
568 : "Must have enough reserved slots.");
569 :
570 : const JSClass*
571 0 : GetJSClass()
572 : {
573 0 : return sClass.ToJSClass();
574 : }
575 :
576 : bool
577 0 : Wrap(JSContext* aCx, mozilla::dom::HTMLSharedElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
578 : {
579 : MOZ_ASSERT(static_cast<mozilla::dom::HTMLSharedElement*>(aObject) ==
580 : reinterpret_cast<mozilla::dom::HTMLSharedElement*>(aObject),
581 : "Multiple inheritance for mozilla::dom::HTMLSharedElement is broken.");
582 : MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) ==
583 : reinterpret_cast<nsGenericHTMLElement*>(aObject),
584 : "Multiple inheritance for nsGenericHTMLElement is broken.");
585 : MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
586 : reinterpret_cast<mozilla::dom::Element*>(aObject),
587 : "Multiple inheritance for mozilla::dom::Element is broken.");
588 : MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
589 : reinterpret_cast<nsINode*>(aObject),
590 : "Multiple inheritance for nsINode is broken.");
591 : MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
592 : reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
593 : "Multiple inheritance for mozilla::dom::EventTarget is broken.");
594 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
595 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
596 0 : MOZ_ASSERT(!aCache->GetWrapper(),
597 : "You should probably not be using Wrap() directly; use "
598 : "GetOrCreateDOMReflector instead");
599 :
600 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
601 : "nsISupports must be on our primary inheritance chain");
602 :
603 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
604 0 : if (!global) {
605 0 : return false;
606 : }
607 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
608 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
609 :
610 : // That might have ended up wrapping us already, due to the wonders
611 : // of XBL. Check for that, and bail out as needed.
612 0 : aReflector.set(aCache->GetWrapper());
613 0 : if (aReflector) {
614 : #ifdef DEBUG
615 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
616 : #endif // DEBUG
617 0 : return true;
618 : }
619 :
620 0 : JSAutoCompartment ac(aCx, global);
621 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
622 0 : if (!canonicalProto) {
623 0 : return false;
624 : }
625 0 : JS::Rooted<JSObject*> proto(aCx);
626 0 : if (aGivenProto) {
627 0 : proto = aGivenProto;
628 : // Unfortunately, while aGivenProto was in the compartment of aCx
629 : // coming in, we changed compartments to that of "parent" so may need
630 : // to wrap the proto here.
631 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
632 0 : if (!JS_WrapObject(aCx, &proto)) {
633 0 : return false;
634 : }
635 : }
636 : } else {
637 0 : proto = canonicalProto;
638 : }
639 :
640 0 : BindingJSObjectCreator<mozilla::dom::HTMLSharedElement> creator(aCx);
641 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
642 0 : if (!aReflector) {
643 0 : return false;
644 : }
645 :
646 0 : aCache->SetWrapper(aReflector);
647 0 : creator.InitializationSucceeded();
648 :
649 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
650 : aCache->GetWrapperPreserveColor() == aReflector);
651 : // If proto != canonicalProto, we have to preserve our wrapper;
652 : // otherwise we won't be able to properly recreate it later, since
653 : // we won't know what proto to use. Note that we don't check
654 : // aGivenProto here, since it's entirely possible (and even
655 : // somewhat common) to have a non-null aGivenProto which is the
656 : // same as canonicalProto.
657 0 : if (proto != canonicalProto) {
658 0 : PreserveWrapper(aObject);
659 : }
660 :
661 0 : return true;
662 : }
663 :
664 : const NativePropertyHooks sNativePropertyHooks[] = { {
665 : nullptr,
666 : nullptr,
667 : nullptr,
668 : { sNativeProperties.Upcast(), nullptr },
669 : prototypes::id::HTMLParamElement,
670 : constructors::id::HTMLParamElement,
671 : HTMLElementBinding::sNativePropertyHooks,
672 : &DefaultXrayExpandoObjectClass
673 : } };
674 :
675 : void
676 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
677 : {
678 0 : JS::Handle<JSObject*> parentProto(HTMLElementBinding::GetProtoObjectHandle(aCx));
679 0 : if (!parentProto) {
680 0 : return;
681 : }
682 :
683 0 : JS::Handle<JSObject*> constructorProto(HTMLElementBinding::GetConstructorObjectHandle(aCx));
684 0 : if (!constructorProto) {
685 0 : return;
686 : }
687 :
688 : static bool sIdsInited = false;
689 0 : if (!sIdsInited && NS_IsMainThread()) {
690 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
691 0 : return;
692 : }
693 0 : sIdsInited = true;
694 : }
695 :
696 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLParamElement);
697 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLParamElement);
698 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
699 : &sPrototypeClass.mBase, protoCache,
700 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
701 : interfaceCache,
702 : sNativeProperties.Upcast(),
703 : nullptr,
704 : "HTMLParamElement", aDefineOnGlobal,
705 : nullptr,
706 0 : false);
707 : }
708 :
709 : JS::Handle<JSObject*>
710 0 : GetProtoObjectHandle(JSContext* aCx)
711 : {
712 : /* Get the interface prototype object for this class. This will create the
713 : object as needed. */
714 0 : bool aDefineOnGlobal = true;
715 :
716 : /* Make sure our global is sane. Hopefully we can remove this sometime */
717 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
718 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
719 0 : return nullptr;
720 : }
721 :
722 : /* Check to see whether the interface objects are already installed */
723 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
724 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::HTMLParamElement)) {
725 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
726 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
727 : }
728 :
729 : /*
730 : * The object might _still_ be null, but that's OK.
731 : *
732 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
733 : * traced by TraceProtoAndIfaceCache() and its contents are never
734 : * changed after they have been set.
735 : *
736 : * Calling address() avoids the read read barrier that does gray
737 : * unmarking, but it's not possible for the object to be gray here.
738 : */
739 :
740 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::HTMLParamElement);
741 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
742 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
743 : }
744 :
745 : JS::Handle<JSObject*>
746 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
747 : {
748 : /* Get the interface object for this class. This will create the object as
749 : needed. */
750 :
751 : /* Make sure our global is sane. Hopefully we can remove this sometime */
752 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
753 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
754 0 : return nullptr;
755 : }
756 :
757 : /* Check to see whether the interface objects are already installed */
758 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
759 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::HTMLParamElement)) {
760 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
761 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
762 : }
763 :
764 : /*
765 : * The object might _still_ be null, but that's OK.
766 : *
767 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
768 : * traced by TraceProtoAndIfaceCache() and its contents are never
769 : * changed after they have been set.
770 : *
771 : * Calling address() avoids the read read barrier that does gray
772 : * unmarking, but it's not possible for the object to be gray here.
773 : */
774 :
775 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::HTMLParamElement);
776 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
777 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
778 : }
779 :
780 : JSObject*
781 0 : GetConstructorObject(JSContext* aCx)
782 : {
783 0 : return GetConstructorObjectHandle(aCx);
784 : }
785 :
786 : } // namespace HTMLParamElementBinding
787 :
788 :
789 :
790 : } // namespace dom
791 : } // namespace mozilla
|