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