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