/work/obj-fuzz/dom/bindings/HTMLParamElementBinding.cpp
Line | Count | Source (jump to first uncovered line) |
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/DocGroup.h" |
11 | | #include "mozilla/dom/HTMLSharedElement.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 HTMLParamElement_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_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedElement* self, JSJitGetterCallArgs args) |
29 | 0 | { |
30 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLParamElement.name", DOM, cx); |
31 | 0 |
|
32 | 0 | DOMString result; |
33 | 0 | self->GetName(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_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedElement* self, JSJitSetterCallArgs args) |
43 | 0 | { |
44 | 0 | AUTO_PROFILER_LABEL_FAST("set HTMLParamElement.name", 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->SetName(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 name_getterinfo = { |
68 | | { (JSJitGetterOp)get_name }, |
69 | | { prototypes::id::HTMLParamElement }, |
70 | | { PrototypeTraits<prototypes::id::HTMLParamElement>::Depth }, |
71 | | JSJitInfo::Getter, |
72 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
73 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
74 | | false, /* isInfallible. False in setters. */ |
75 | | true, /* isMovable. Not relevant for setters. */ |
76 | | true, /* 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 name_setterinfo = { |
85 | | { (JSJitGetterOp)set_name }, |
86 | | { prototypes::id::HTMLParamElement }, |
87 | | { PrototypeTraits<prototypes::id::HTMLParamElement>::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 | | MOZ_CAN_RUN_SCRIPT static bool |
103 | | get_value(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedElement* self, JSJitGetterCallArgs args) |
104 | 0 | { |
105 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLParamElement.value", DOM, cx); |
106 | 0 |
|
107 | 0 | DOMString result; |
108 | 0 | self->GetValue(result); |
109 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
110 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
111 | 0 | return false; |
112 | 0 | } |
113 | 0 | return true; |
114 | 0 | } |
115 | | |
116 | | MOZ_CAN_RUN_SCRIPT static bool |
117 | | set_value(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedElement* self, JSJitSetterCallArgs args) |
118 | 0 | { |
119 | 0 | AUTO_PROFILER_LABEL_FAST("set HTMLParamElement.value", DOM, cx); |
120 | 0 |
|
121 | 0 | binding_detail::FakeString arg0; |
122 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
123 | 0 | return false; |
124 | 0 | } |
125 | 0 | Maybe<AutoCEReaction> ceReaction; |
126 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
127 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
128 | 0 | if (docGroup) { |
129 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
130 | 0 | } |
131 | 0 | } |
132 | 0 | FastErrorResult rv; |
133 | 0 | self->SetValue(NonNullHelper(Constify(arg0)), rv); |
134 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
135 | 0 | return false; |
136 | 0 | } |
137 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
138 | 0 |
|
139 | 0 | return true; |
140 | 0 | } |
141 | | |
142 | | static const JSJitInfo value_getterinfo = { |
143 | | { (JSJitGetterOp)get_value }, |
144 | | { prototypes::id::HTMLParamElement }, |
145 | | { PrototypeTraits<prototypes::id::HTMLParamElement>::Depth }, |
146 | | JSJitInfo::Getter, |
147 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
148 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
149 | | false, /* isInfallible. False in setters. */ |
150 | | true, /* isMovable. Not relevant for setters. */ |
151 | | true, /* 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 | | static const JSJitInfo value_setterinfo = { |
160 | | { (JSJitGetterOp)set_value }, |
161 | | { prototypes::id::HTMLParamElement }, |
162 | | { PrototypeTraits<prototypes::id::HTMLParamElement>::Depth }, |
163 | | JSJitInfo::Setter, |
164 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
165 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
166 | | false, /* isInfallible. False in setters. */ |
167 | | false, /* isMovable. Not relevant for setters. */ |
168 | | false, /* isEliminatable. Not relevant for setters. */ |
169 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
170 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
171 | | false, /* isTypedMethod. Only relevant for methods. */ |
172 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
173 | | }; |
174 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
175 | | static_assert(0 < 1, "There is no slot for us"); |
176 | | |
177 | | MOZ_CAN_RUN_SCRIPT static bool |
178 | | get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedElement* self, JSJitGetterCallArgs args) |
179 | 0 | { |
180 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLParamElement.type", DOM, cx); |
181 | 0 |
|
182 | 0 | DOMString result; |
183 | 0 | self->GetType(result); |
184 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
185 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
186 | 0 | return false; |
187 | 0 | } |
188 | 0 | return true; |
189 | 0 | } |
190 | | |
191 | | MOZ_CAN_RUN_SCRIPT static bool |
192 | | set_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedElement* self, JSJitSetterCallArgs args) |
193 | 0 | { |
194 | 0 | AUTO_PROFILER_LABEL_FAST("set HTMLParamElement.type", DOM, cx); |
195 | 0 |
|
196 | 0 | binding_detail::FakeString arg0; |
197 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
198 | 0 | return false; |
199 | 0 | } |
200 | 0 | Maybe<AutoCEReaction> ceReaction; |
201 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
202 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
203 | 0 | if (docGroup) { |
204 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
205 | 0 | } |
206 | 0 | } |
207 | 0 | FastErrorResult rv; |
208 | 0 | self->SetType(NonNullHelper(Constify(arg0)), rv); |
209 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
210 | 0 | return false; |
211 | 0 | } |
212 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
213 | 0 |
|
214 | 0 | return true; |
215 | 0 | } |
216 | | |
217 | | static const JSJitInfo type_getterinfo = { |
218 | | { (JSJitGetterOp)get_type }, |
219 | | { prototypes::id::HTMLParamElement }, |
220 | | { PrototypeTraits<prototypes::id::HTMLParamElement>::Depth }, |
221 | | JSJitInfo::Getter, |
222 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
223 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
224 | | false, /* isInfallible. False in setters. */ |
225 | | true, /* isMovable. Not relevant for setters. */ |
226 | | true, /* isEliminatable. Not relevant for setters. */ |
227 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
228 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
229 | | false, /* isTypedMethod. Only relevant for methods. */ |
230 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
231 | | }; |
232 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
233 | | static_assert(0 < 1, "There is no slot for us"); |
234 | | static const JSJitInfo type_setterinfo = { |
235 | | { (JSJitGetterOp)set_type }, |
236 | | { prototypes::id::HTMLParamElement }, |
237 | | { PrototypeTraits<prototypes::id::HTMLParamElement>::Depth }, |
238 | | JSJitInfo::Setter, |
239 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
240 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
241 | | false, /* isInfallible. False in setters. */ |
242 | | false, /* isMovable. Not relevant for setters. */ |
243 | | false, /* isEliminatable. Not relevant for setters. */ |
244 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
245 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
246 | | false, /* isTypedMethod. Only relevant for methods. */ |
247 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
248 | | }; |
249 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
250 | | static_assert(0 < 1, "There is no slot for us"); |
251 | | |
252 | | MOZ_CAN_RUN_SCRIPT static bool |
253 | | get_valueType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedElement* self, JSJitGetterCallArgs args) |
254 | 0 | { |
255 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLParamElement.valueType", DOM, cx); |
256 | 0 |
|
257 | 0 | DOMString result; |
258 | 0 | self->GetValueType(result); |
259 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
260 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
261 | 0 | return false; |
262 | 0 | } |
263 | 0 | return true; |
264 | 0 | } |
265 | | |
266 | | MOZ_CAN_RUN_SCRIPT static bool |
267 | | set_valueType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedElement* self, JSJitSetterCallArgs args) |
268 | 0 | { |
269 | 0 | AUTO_PROFILER_LABEL_FAST("set HTMLParamElement.valueType", DOM, cx); |
270 | 0 |
|
271 | 0 | binding_detail::FakeString arg0; |
272 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
273 | 0 | return false; |
274 | 0 | } |
275 | 0 | Maybe<AutoCEReaction> ceReaction; |
276 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
277 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
278 | 0 | if (docGroup) { |
279 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
280 | 0 | } |
281 | 0 | } |
282 | 0 | FastErrorResult rv; |
283 | 0 | self->SetValueType(NonNullHelper(Constify(arg0)), rv); |
284 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
285 | 0 | return false; |
286 | 0 | } |
287 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
288 | 0 |
|
289 | 0 | return true; |
290 | 0 | } |
291 | | |
292 | | static const JSJitInfo valueType_getterinfo = { |
293 | | { (JSJitGetterOp)get_valueType }, |
294 | | { prototypes::id::HTMLParamElement }, |
295 | | { PrototypeTraits<prototypes::id::HTMLParamElement>::Depth }, |
296 | | JSJitInfo::Getter, |
297 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
298 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
299 | | false, /* isInfallible. False in setters. */ |
300 | | true, /* isMovable. Not relevant for setters. */ |
301 | | true, /* isEliminatable. Not relevant for setters. */ |
302 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
303 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
304 | | false, /* isTypedMethod. Only relevant for methods. */ |
305 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
306 | | }; |
307 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
308 | | static_assert(0 < 1, "There is no slot for us"); |
309 | | static const JSJitInfo valueType_setterinfo = { |
310 | | { (JSJitGetterOp)set_valueType }, |
311 | | { prototypes::id::HTMLParamElement }, |
312 | | { PrototypeTraits<prototypes::id::HTMLParamElement>::Depth }, |
313 | | JSJitInfo::Setter, |
314 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
315 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
316 | | false, /* isInfallible. False in setters. */ |
317 | | false, /* isMovable. Not relevant for setters. */ |
318 | | false, /* isEliminatable. Not relevant for setters. */ |
319 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
320 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
321 | | false, /* isTypedMethod. Only relevant for methods. */ |
322 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
323 | | }; |
324 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
325 | | static_assert(0 < 1, "There is no slot for us"); |
326 | | |
327 | | static bool |
328 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
329 | 0 | { |
330 | 0 | mozilla::dom::HTMLSharedElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLSharedElement>(obj); |
331 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
332 | 0 | // obviously can't preserve if we're not initialized. |
333 | 0 | if (self && self->GetWrapperPreserveColor()) { |
334 | 0 | PreserveWrapper(self); |
335 | 0 | } |
336 | 0 | return true; |
337 | 0 | } |
338 | | |
339 | | static void |
340 | | _finalize(js::FreeOp* fop, JSObject* obj) |
341 | 0 | { |
342 | 0 | mozilla::dom::HTMLSharedElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLSharedElement>(obj); |
343 | 0 | if (self) { |
344 | 0 | ClearWrapper(self, self, obj); |
345 | 0 | AddForDeferredFinalization<mozilla::dom::HTMLSharedElement>(self); |
346 | 0 | } |
347 | 0 | } |
348 | | |
349 | | static size_t |
350 | | _objectMoved(JSObject* obj, JSObject* old) |
351 | 0 | { |
352 | 0 | mozilla::dom::HTMLSharedElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLSharedElement>(obj); |
353 | 0 | if (self) { |
354 | 0 | UpdateWrapper(self, self, obj, old); |
355 | 0 | } |
356 | 0 |
|
357 | 0 | return 0; |
358 | 0 | } |
359 | | |
360 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
361 | | #if defined(__clang__) |
362 | | #pragma clang diagnostic push |
363 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
364 | | #endif |
365 | | static const JSPropertySpec sAttributes_specs[] = { |
366 | | { "name", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &name_getterinfo, GenericSetter<NormalThisPolicy>, &name_setterinfo }, |
367 | | { "value", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &value_getterinfo, GenericSetter<NormalThisPolicy>, &value_setterinfo }, |
368 | | { "type", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &type_getterinfo, GenericSetter<NormalThisPolicy>, &type_setterinfo }, |
369 | | { "valueType", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &valueType_getterinfo, GenericSetter<NormalThisPolicy>, &valueType_setterinfo }, |
370 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
371 | | }; |
372 | | #if defined(__clang__) |
373 | | #pragma clang diagnostic pop |
374 | | #endif |
375 | | |
376 | | |
377 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
378 | | { nullptr, &sAttributes_specs[0] }, |
379 | | { nullptr, nullptr } |
380 | | }; |
381 | | |
382 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
383 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
384 | | static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
385 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
386 | | |
387 | | |
388 | | static uint16_t sNativeProperties_sortedPropertyIndices[4]; |
389 | | static PropertyInfo sNativeProperties_propertyInfos[4]; |
390 | | |
391 | | static const NativePropertiesN<1> sNativeProperties = { |
392 | | false, 0, |
393 | | false, 0, |
394 | | false, 0, |
395 | | true, 0 /* sAttributes */, |
396 | | false, 0, |
397 | | false, 0, |
398 | | false, 0, |
399 | | -1, |
400 | | 4, |
401 | | sNativeProperties_sortedPropertyIndices, |
402 | | { |
403 | | { sAttributes, &sNativeProperties_propertyInfos[0] } |
404 | | } |
405 | | }; |
406 | | static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
407 | | "We have a property info count that is oversized"); |
408 | | |
409 | | static bool |
410 | | _constructor(JSContext* cx, unsigned argc, JS::Value* vp) |
411 | 0 | { |
412 | 0 | AUTO_PROFILER_LABEL_FAST("HTMLParamElement constructor", DOM, cx); |
413 | 0 |
|
414 | 0 | return HTMLConstructor(cx, argc, vp, |
415 | 0 | constructors::id::HTMLParamElement, |
416 | 0 | prototypes::id::HTMLParamElement, |
417 | 0 | CreateInterfaceObjects); |
418 | 0 | } |
419 | | |
420 | | static const js::ClassOps sInterfaceObjectClassOps = { |
421 | | nullptr, /* addProperty */ |
422 | | nullptr, /* delProperty */ |
423 | | nullptr, /* enumerate */ |
424 | | nullptr, /* newEnumerate */ |
425 | | nullptr, /* resolve */ |
426 | | nullptr, /* mayResolve */ |
427 | | nullptr, /* finalize */ |
428 | | _constructor, /* call */ |
429 | | nullptr, /* hasInstance */ |
430 | | _constructor, /* construct */ |
431 | | nullptr, /* trace */ |
432 | | }; |
433 | | |
434 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
435 | | { |
436 | | "Function", |
437 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
438 | | &sInterfaceObjectClassOps, |
439 | | JS_NULL_CLASS_SPEC, |
440 | | JS_NULL_CLASS_EXT, |
441 | | &sInterfaceObjectClassObjectOps |
442 | | }, |
443 | | eInterface, |
444 | | true, |
445 | | prototypes::id::HTMLParamElement, |
446 | | PrototypeTraits<prototypes::id::HTMLParamElement>::Depth, |
447 | | sNativePropertyHooks, |
448 | | "function HTMLParamElement() {\n [native code]\n}", |
449 | | HTMLElement_Binding::GetConstructorObject |
450 | | }; |
451 | | |
452 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
453 | | { |
454 | | "HTMLParamElementPrototype", |
455 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
456 | | JS_NULL_CLASS_OPS, |
457 | | JS_NULL_CLASS_SPEC, |
458 | | JS_NULL_CLASS_EXT, |
459 | | JS_NULL_OBJECT_OPS |
460 | | }, |
461 | | eInterfacePrototype, |
462 | | false, |
463 | | prototypes::id::HTMLParamElement, |
464 | | PrototypeTraits<prototypes::id::HTMLParamElement>::Depth, |
465 | | sNativePropertyHooks, |
466 | | "[object HTMLParamElementPrototype]", |
467 | | HTMLElement_Binding::GetProtoObject |
468 | | }; |
469 | | |
470 | | static const js::ClassOps sClassOps = { |
471 | | _addProperty, /* addProperty */ |
472 | | nullptr, /* delProperty */ |
473 | | nullptr, /* enumerate */ |
474 | | nullptr, /* newEnumerate */ |
475 | | nullptr, /* resolve */ |
476 | | nullptr, /* mayResolve */ |
477 | | _finalize, /* finalize */ |
478 | | nullptr, /* call */ |
479 | | nullptr, /* hasInstance */ |
480 | | nullptr, /* construct */ |
481 | | nullptr, /* trace */ |
482 | | }; |
483 | | |
484 | | static const js::ClassExtension sClassExtension = { |
485 | | nullptr, /* weakmapKeyDelegateOp */ |
486 | | _objectMoved /* objectMovedOp */ |
487 | | }; |
488 | | |
489 | | static const DOMJSClass sClass = { |
490 | | { "HTMLParamElement", |
491 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
492 | | &sClassOps, |
493 | | JS_NULL_CLASS_SPEC, |
494 | | &sClassExtension, |
495 | | JS_NULL_OBJECT_OPS |
496 | | }, |
497 | | { 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 }, |
498 | | IsBaseOf<nsISupports, mozilla::dom::HTMLSharedElement >::value, |
499 | | sNativePropertyHooks, |
500 | | FindAssociatedGlobalForNative<mozilla::dom::HTMLSharedElement>::Get, |
501 | | GetProtoObjectHandle, |
502 | | GetCCParticipant<mozilla::dom::HTMLSharedElement>::Get() |
503 | | }; |
504 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
505 | | "Must have the right minimal number of reserved slots."); |
506 | | static_assert(1 >= 1, |
507 | | "Must have enough reserved slots."); |
508 | | |
509 | | const JSClass* |
510 | | GetJSClass() |
511 | 0 | { |
512 | 0 | return sClass.ToJSClass(); |
513 | 0 | } |
514 | | |
515 | | bool |
516 | | Wrap(JSContext* aCx, mozilla::dom::HTMLSharedElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
517 | 0 | { |
518 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::HTMLSharedElement>::value, |
519 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
520 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::HTMLSharedElement*>(aObject) == |
521 | 0 | reinterpret_cast<mozilla::dom::HTMLSharedElement*>(aObject), |
522 | 0 | "Multiple inheritance for mozilla::dom::HTMLSharedElement is broken."); |
523 | 0 | MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) == |
524 | 0 | reinterpret_cast<nsGenericHTMLElement*>(aObject), |
525 | 0 | "Multiple inheritance for nsGenericHTMLElement is broken."); |
526 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) == |
527 | 0 | reinterpret_cast<mozilla::dom::Element*>(aObject), |
528 | 0 | "Multiple inheritance for mozilla::dom::Element is broken."); |
529 | 0 | MOZ_ASSERT(static_cast<nsINode*>(aObject) == |
530 | 0 | reinterpret_cast<nsINode*>(aObject), |
531 | 0 | "Multiple inheritance for nsINode is broken."); |
532 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
533 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
534 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
535 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
536 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
537 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
538 | 0 | "You should probably not be using Wrap() directly; use " |
539 | 0 | "GetOrCreateDOMReflector instead"); |
540 | 0 |
|
541 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
542 | 0 | "nsISupports must be on our primary inheritance chain"); |
543 | 0 |
|
544 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
545 | 0 | if (!global) { |
546 | 0 | return false; |
547 | 0 | } |
548 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
549 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
550 | 0 |
|
551 | 0 | // That might have ended up wrapping us already, due to the wonders |
552 | 0 | // of XBL. Check for that, and bail out as needed. |
553 | 0 | aReflector.set(aCache->GetWrapper()); |
554 | 0 | if (aReflector) { |
555 | | #ifdef DEBUG |
556 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
557 | | #endif // DEBUG |
558 | | return true; |
559 | 0 | } |
560 | 0 |
|
561 | 0 | JSAutoRealm ar(aCx, global); |
562 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
563 | 0 | if (!canonicalProto) { |
564 | 0 | return false; |
565 | 0 | } |
566 | 0 | JS::Rooted<JSObject*> proto(aCx); |
567 | 0 | if (aGivenProto) { |
568 | 0 | proto = aGivenProto; |
569 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
570 | 0 | // coming in, we changed compartments to that of "parent" so may need |
571 | 0 | // to wrap the proto here. |
572 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
573 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
574 | 0 | return false; |
575 | 0 | } |
576 | 0 | } |
577 | 0 | } else { |
578 | 0 | proto = canonicalProto; |
579 | 0 | } |
580 | 0 |
|
581 | 0 | BindingJSObjectCreator<mozilla::dom::HTMLSharedElement> creator(aCx); |
582 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
583 | 0 | if (!aReflector) { |
584 | 0 | return false; |
585 | 0 | } |
586 | 0 | |
587 | 0 | aCache->SetWrapper(aReflector); |
588 | 0 | creator.InitializationSucceeded(); |
589 | 0 |
|
590 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
591 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
592 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
593 | 0 | // otherwise we won't be able to properly recreate it later, since |
594 | 0 | // we won't know what proto to use. Note that we don't check |
595 | 0 | // aGivenProto here, since it's entirely possible (and even |
596 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
597 | 0 | // same as canonicalProto. |
598 | 0 | if (proto != canonicalProto) { |
599 | 0 | PreserveWrapper(aObject); |
600 | 0 | } |
601 | 0 |
|
602 | 0 | return true; |
603 | 0 | } |
604 | | |
605 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
606 | | nullptr, |
607 | | nullptr, |
608 | | nullptr, |
609 | | { sNativeProperties.Upcast(), nullptr }, |
610 | | prototypes::id::HTMLParamElement, |
611 | | constructors::id::HTMLParamElement, |
612 | | HTMLElement_Binding::sNativePropertyHooks, |
613 | | &DefaultXrayExpandoObjectClass |
614 | | } }; |
615 | | |
616 | | void |
617 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
618 | 0 | { |
619 | 0 | JS::Handle<JSObject*> parentProto(HTMLElement_Binding::GetProtoObjectHandle(aCx)); |
620 | 0 | if (!parentProto) { |
621 | 0 | return; |
622 | 0 | } |
623 | 0 | |
624 | 0 | JS::Handle<JSObject*> constructorProto(HTMLElement_Binding::GetConstructorObjectHandle(aCx)); |
625 | 0 | if (!constructorProto) { |
626 | 0 | return; |
627 | 0 | } |
628 | 0 | |
629 | 0 | static bool sIdsInited = false; |
630 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
631 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
632 | 0 | return; |
633 | 0 | } |
634 | 0 | sIdsInited = true; |
635 | 0 | } |
636 | 0 |
|
637 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLParamElement); |
638 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLParamElement); |
639 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
640 | 0 | &sPrototypeClass.mBase, protoCache, |
641 | 0 | nullptr, |
642 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
643 | 0 | interfaceCache, |
644 | 0 | sNativeProperties.Upcast(), |
645 | 0 | nullptr, |
646 | 0 | "HTMLParamElement", aDefineOnGlobal, |
647 | 0 | nullptr, |
648 | 0 | false); |
649 | 0 | } |
650 | | |
651 | | JSObject* |
652 | | GetConstructorObject(JSContext* aCx) |
653 | 0 | { |
654 | 0 | return GetConstructorObjectHandle(aCx); |
655 | 0 | } |
656 | | |
657 | | } // namespace HTMLParamElement_Binding |
658 | | |
659 | | |
660 | | |
661 | | } // namespace dom |
662 | | } // namespace mozilla |