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