/work/obj-fuzz/dom/bindings/XULScrollElementBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM XULScrollElement.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "WrapperFactory.h" |
4 | | #include "XULElementBinding.h" |
5 | | #include "XULScrollElementBinding.h" |
6 | | #include "mozilla/OwningNonNull.h" |
7 | | #include "mozilla/dom/BindingUtils.h" |
8 | | #include "mozilla/dom/DOMJSClass.h" |
9 | | #include "mozilla/dom/Element.h" |
10 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
11 | | #include "mozilla/dom/PrimitiveConversions.h" |
12 | | #include "mozilla/dom/XULScrollElement.h" |
13 | | #include "mozilla/dom/XrayExpandoClass.h" |
14 | | |
15 | | namespace mozilla { |
16 | | namespace dom { |
17 | | |
18 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
19 | | using namespace mozilla::dom::binding_detail; |
20 | | |
21 | | |
22 | | namespace XULScrollElement_Binding { |
23 | | |
24 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<XULElement_Binding::NativeType>::value, |
25 | | "Can't inherit from an interface with a different ownership model."); |
26 | | |
27 | | MOZ_CAN_RUN_SCRIPT static bool |
28 | | scrollToElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULScrollElement* self, const JSJitMethodCallArgs& args) |
29 | 0 | { |
30 | 0 | AUTO_PROFILER_LABEL_FAST("XULScrollElement.scrollToElement", DOM, cx); |
31 | 0 |
|
32 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
33 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XULScrollElement.scrollToElement"); |
34 | 0 | } |
35 | 0 | NonNull<mozilla::dom::Element> arg0; |
36 | 0 | if (args[0].isObject()) { |
37 | 0 | { |
38 | 0 | nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0); |
39 | 0 | if (NS_FAILED(rv)) { |
40 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of XULScrollElement.scrollToElement", "Element"); |
41 | 0 | return false; |
42 | 0 | } |
43 | 0 | } |
44 | 0 | } else { |
45 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of XULScrollElement.scrollToElement"); |
46 | 0 | return false; |
47 | 0 | } |
48 | 0 | FastErrorResult rv; |
49 | 0 | self->ScrollToElement(MOZ_KnownLive(NonNullHelper(arg0)), rv); |
50 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
51 | 0 | return false; |
52 | 0 | } |
53 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
54 | 0 | args.rval().setUndefined(); |
55 | 0 | return true; |
56 | 0 | } |
57 | | |
58 | | static const JSJitInfo scrollToElement_methodinfo = { |
59 | | { (JSJitGetterOp)scrollToElement }, |
60 | | { prototypes::id::XULScrollElement }, |
61 | | { PrototypeTraits<prototypes::id::XULScrollElement>::Depth }, |
62 | | JSJitInfo::Method, |
63 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
64 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
65 | | false, /* isInfallible. False in setters. */ |
66 | | false, /* isMovable. Not relevant for setters. */ |
67 | | false, /* isEliminatable. Not relevant for setters. */ |
68 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
69 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
70 | | false, /* isTypedMethod. Only relevant for methods. */ |
71 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
72 | | }; |
73 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
74 | | static_assert(0 < 1, "There is no slot for us"); |
75 | | |
76 | | MOZ_CAN_RUN_SCRIPT static bool |
77 | | scrollByIndex(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULScrollElement* self, const JSJitMethodCallArgs& args) |
78 | 0 | { |
79 | 0 | AUTO_PROFILER_LABEL_FAST("XULScrollElement.scrollByIndex", DOM, cx); |
80 | 0 |
|
81 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
82 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XULScrollElement.scrollByIndex"); |
83 | 0 | } |
84 | 0 | int32_t arg0; |
85 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) { |
86 | 0 | return false; |
87 | 0 | } |
88 | 0 | FastErrorResult rv; |
89 | 0 | self->ScrollByIndex(arg0, rv); |
90 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
91 | 0 | return false; |
92 | 0 | } |
93 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
94 | 0 | args.rval().setUndefined(); |
95 | 0 | return true; |
96 | 0 | } |
97 | | |
98 | | static const JSJitInfo scrollByIndex_methodinfo = { |
99 | | { (JSJitGetterOp)scrollByIndex }, |
100 | | { prototypes::id::XULScrollElement }, |
101 | | { PrototypeTraits<prototypes::id::XULScrollElement>::Depth }, |
102 | | JSJitInfo::Method, |
103 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
104 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
105 | | false, /* isInfallible. False in setters. */ |
106 | | false, /* isMovable. Not relevant for setters. */ |
107 | | false, /* isEliminatable. Not relevant for setters. */ |
108 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
109 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
110 | | false, /* isTypedMethod. Only relevant for methods. */ |
111 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
112 | | }; |
113 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
114 | | static_assert(0 < 1, "There is no slot for us"); |
115 | | |
116 | | MOZ_CAN_RUN_SCRIPT static bool |
117 | | ensureElementIsVisible(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULScrollElement* self, const JSJitMethodCallArgs& args) |
118 | 0 | { |
119 | 0 | AUTO_PROFILER_LABEL_FAST("XULScrollElement.ensureElementIsVisible", DOM, cx); |
120 | 0 |
|
121 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
122 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XULScrollElement.ensureElementIsVisible"); |
123 | 0 | } |
124 | 0 | NonNull<mozilla::dom::Element> arg0; |
125 | 0 | if (args[0].isObject()) { |
126 | 0 | { |
127 | 0 | nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0); |
128 | 0 | if (NS_FAILED(rv)) { |
129 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of XULScrollElement.ensureElementIsVisible", "Element"); |
130 | 0 | return false; |
131 | 0 | } |
132 | 0 | } |
133 | 0 | } else { |
134 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of XULScrollElement.ensureElementIsVisible"); |
135 | 0 | return false; |
136 | 0 | } |
137 | 0 | FastErrorResult rv; |
138 | 0 | self->EnsureElementIsVisible(MOZ_KnownLive(NonNullHelper(arg0)), rv); |
139 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
140 | 0 | return false; |
141 | 0 | } |
142 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
143 | 0 | args.rval().setUndefined(); |
144 | 0 | return true; |
145 | 0 | } |
146 | | |
147 | | static const JSJitInfo ensureElementIsVisible_methodinfo = { |
148 | | { (JSJitGetterOp)ensureElementIsVisible }, |
149 | | { prototypes::id::XULScrollElement }, |
150 | | { PrototypeTraits<prototypes::id::XULScrollElement>::Depth }, |
151 | | JSJitInfo::Method, |
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 | | static bool |
166 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
167 | 0 | { |
168 | 0 | mozilla::dom::XULScrollElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XULScrollElement>(obj); |
169 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
170 | 0 | // obviously can't preserve if we're not initialized. |
171 | 0 | if (self && self->GetWrapperPreserveColor()) { |
172 | 0 | PreserveWrapper(self); |
173 | 0 | } |
174 | 0 | return true; |
175 | 0 | } |
176 | | |
177 | | static void |
178 | | _finalize(js::FreeOp* fop, JSObject* obj) |
179 | 0 | { |
180 | 0 | mozilla::dom::XULScrollElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XULScrollElement>(obj); |
181 | 0 | if (self) { |
182 | 0 | ClearWrapper(self, self, obj); |
183 | 0 | AddForDeferredFinalization<mozilla::dom::XULScrollElement>(self); |
184 | 0 | } |
185 | 0 | } |
186 | | |
187 | | static size_t |
188 | | _objectMoved(JSObject* obj, JSObject* old) |
189 | 0 | { |
190 | 0 | mozilla::dom::XULScrollElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XULScrollElement>(obj); |
191 | 0 | if (self) { |
192 | 0 | UpdateWrapper(self, self, obj, old); |
193 | 0 | } |
194 | 0 |
|
195 | 0 | return 0; |
196 | 0 | } |
197 | | |
198 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
199 | | #if defined(__clang__) |
200 | | #pragma clang diagnostic push |
201 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
202 | | #endif |
203 | | static const JSFunctionSpec sMethods_specs[] = { |
204 | | JS_FNSPEC("scrollToElement", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&scrollToElement_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
205 | | JS_FNSPEC("scrollByIndex", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&scrollByIndex_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
206 | | JS_FNSPEC("ensureElementIsVisible", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&ensureElementIsVisible_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
207 | | JS_FS_END |
208 | | }; |
209 | | #if defined(__clang__) |
210 | | #pragma clang diagnostic pop |
211 | | #endif |
212 | | |
213 | | |
214 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
215 | | { nullptr, &sMethods_specs[0] }, |
216 | | { nullptr, nullptr } |
217 | | }; |
218 | | |
219 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
220 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
221 | | static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
222 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
223 | | |
224 | | |
225 | | static uint16_t sNativeProperties_sortedPropertyIndices[3]; |
226 | | static PropertyInfo sNativeProperties_propertyInfos[3]; |
227 | | |
228 | | static const NativePropertiesN<1> sNativeProperties = { |
229 | | false, 0, |
230 | | false, 0, |
231 | | true, 0 /* sMethods */, |
232 | | false, 0, |
233 | | false, 0, |
234 | | false, 0, |
235 | | false, 0, |
236 | | -1, |
237 | | 3, |
238 | | sNativeProperties_sortedPropertyIndices, |
239 | | { |
240 | | { sMethods, &sNativeProperties_propertyInfos[0] } |
241 | | } |
242 | | }; |
243 | | static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
244 | | "We have a property info count that is oversized"); |
245 | | |
246 | | static bool |
247 | | _constructor(JSContext* cx, unsigned argc, JS::Value* vp) |
248 | 0 | { |
249 | 0 | AUTO_PROFILER_LABEL_FAST("XULScrollElement constructor", DOM, cx); |
250 | 0 |
|
251 | 0 | return HTMLConstructor(cx, argc, vp, |
252 | 0 | constructors::id::XULScrollElement, |
253 | 0 | prototypes::id::XULScrollElement, |
254 | 0 | CreateInterfaceObjects); |
255 | 0 | } |
256 | | |
257 | | static const js::ClassOps sInterfaceObjectClassOps = { |
258 | | nullptr, /* addProperty */ |
259 | | nullptr, /* delProperty */ |
260 | | nullptr, /* enumerate */ |
261 | | nullptr, /* newEnumerate */ |
262 | | nullptr, /* resolve */ |
263 | | nullptr, /* mayResolve */ |
264 | | nullptr, /* finalize */ |
265 | | _constructor, /* call */ |
266 | | nullptr, /* hasInstance */ |
267 | | _constructor, /* construct */ |
268 | | nullptr, /* trace */ |
269 | | }; |
270 | | |
271 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
272 | | { |
273 | | "Function", |
274 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
275 | | &sInterfaceObjectClassOps, |
276 | | JS_NULL_CLASS_SPEC, |
277 | | JS_NULL_CLASS_EXT, |
278 | | &sInterfaceObjectClassObjectOps |
279 | | }, |
280 | | eInterface, |
281 | | true, |
282 | | prototypes::id::XULScrollElement, |
283 | | PrototypeTraits<prototypes::id::XULScrollElement>::Depth, |
284 | | sNativePropertyHooks, |
285 | | "function XULScrollElement() {\n [native code]\n}", |
286 | | XULElement_Binding::GetConstructorObject |
287 | | }; |
288 | | |
289 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
290 | | { |
291 | | "XULScrollElementPrototype", |
292 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
293 | | JS_NULL_CLASS_OPS, |
294 | | JS_NULL_CLASS_SPEC, |
295 | | JS_NULL_CLASS_EXT, |
296 | | JS_NULL_OBJECT_OPS |
297 | | }, |
298 | | eInterfacePrototype, |
299 | | false, |
300 | | prototypes::id::XULScrollElement, |
301 | | PrototypeTraits<prototypes::id::XULScrollElement>::Depth, |
302 | | sNativePropertyHooks, |
303 | | "[object XULScrollElementPrototype]", |
304 | | XULElement_Binding::GetProtoObject |
305 | | }; |
306 | | |
307 | | bool |
308 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
309 | 0 | { |
310 | 0 | return IsChromeOrXBL(aCx, aObj); |
311 | 0 | } |
312 | | |
313 | | static const js::ClassOps sClassOps = { |
314 | | _addProperty, /* addProperty */ |
315 | | nullptr, /* delProperty */ |
316 | | nullptr, /* enumerate */ |
317 | | nullptr, /* newEnumerate */ |
318 | | nullptr, /* resolve */ |
319 | | nullptr, /* mayResolve */ |
320 | | _finalize, /* finalize */ |
321 | | nullptr, /* call */ |
322 | | nullptr, /* hasInstance */ |
323 | | nullptr, /* construct */ |
324 | | nullptr, /* trace */ |
325 | | }; |
326 | | |
327 | | static const js::ClassExtension sClassExtension = { |
328 | | nullptr, /* weakmapKeyDelegateOp */ |
329 | | _objectMoved /* objectMovedOp */ |
330 | | }; |
331 | | |
332 | | static const DOMJSClass sClass = { |
333 | | { "XULScrollElement", |
334 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
335 | | &sClassOps, |
336 | | JS_NULL_CLASS_SPEC, |
337 | | &sClassExtension, |
338 | | JS_NULL_OBJECT_OPS |
339 | | }, |
340 | | { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::XULElement, prototypes::id::XULScrollElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
341 | | IsBaseOf<nsISupports, mozilla::dom::XULScrollElement >::value, |
342 | | sNativePropertyHooks, |
343 | | FindAssociatedGlobalForNative<mozilla::dom::XULScrollElement>::Get, |
344 | | GetProtoObjectHandle, |
345 | | GetCCParticipant<mozilla::dom::XULScrollElement>::Get() |
346 | | }; |
347 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
348 | | "Must have the right minimal number of reserved slots."); |
349 | | static_assert(1 >= 1, |
350 | | "Must have enough reserved slots."); |
351 | | |
352 | | const JSClass* |
353 | | GetJSClass() |
354 | 0 | { |
355 | 0 | return sClass.ToJSClass(); |
356 | 0 | } |
357 | | |
358 | | bool |
359 | | Wrap(JSContext* aCx, mozilla::dom::XULScrollElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
360 | 0 | { |
361 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::XULScrollElement>::value, |
362 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
363 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::XULScrollElement*>(aObject) == |
364 | 0 | reinterpret_cast<mozilla::dom::XULScrollElement*>(aObject), |
365 | 0 | "Multiple inheritance for mozilla::dom::XULScrollElement is broken."); |
366 | 0 | MOZ_ASSERT(static_cast<nsXULElement*>(aObject) == |
367 | 0 | reinterpret_cast<nsXULElement*>(aObject), |
368 | 0 | "Multiple inheritance for nsXULElement is broken."); |
369 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) == |
370 | 0 | reinterpret_cast<mozilla::dom::Element*>(aObject), |
371 | 0 | "Multiple inheritance for mozilla::dom::Element is broken."); |
372 | 0 | MOZ_ASSERT(static_cast<nsINode*>(aObject) == |
373 | 0 | reinterpret_cast<nsINode*>(aObject), |
374 | 0 | "Multiple inheritance for nsINode is broken."); |
375 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
376 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
377 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
378 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
379 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
380 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
381 | 0 | "You should probably not be using Wrap() directly; use " |
382 | 0 | "GetOrCreateDOMReflector instead"); |
383 | 0 |
|
384 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
385 | 0 | "nsISupports must be on our primary inheritance chain"); |
386 | 0 |
|
387 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
388 | 0 | if (!global) { |
389 | 0 | return false; |
390 | 0 | } |
391 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
392 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
393 | 0 |
|
394 | 0 | // That might have ended up wrapping us already, due to the wonders |
395 | 0 | // of XBL. Check for that, and bail out as needed. |
396 | 0 | aReflector.set(aCache->GetWrapper()); |
397 | 0 | if (aReflector) { |
398 | | #ifdef DEBUG |
399 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
400 | | #endif // DEBUG |
401 | | return true; |
402 | 0 | } |
403 | 0 |
|
404 | 0 | JSAutoRealm ar(aCx, global); |
405 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
406 | 0 | if (!canonicalProto) { |
407 | 0 | return false; |
408 | 0 | } |
409 | 0 | JS::Rooted<JSObject*> proto(aCx); |
410 | 0 | if (aGivenProto) { |
411 | 0 | proto = aGivenProto; |
412 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
413 | 0 | // coming in, we changed compartments to that of "parent" so may need |
414 | 0 | // to wrap the proto here. |
415 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
416 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
417 | 0 | return false; |
418 | 0 | } |
419 | 0 | } |
420 | 0 | } else { |
421 | 0 | proto = canonicalProto; |
422 | 0 | } |
423 | 0 |
|
424 | 0 | BindingJSObjectCreator<mozilla::dom::XULScrollElement> creator(aCx); |
425 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
426 | 0 | if (!aReflector) { |
427 | 0 | return false; |
428 | 0 | } |
429 | 0 | |
430 | 0 | aCache->SetWrapper(aReflector); |
431 | 0 | creator.InitializationSucceeded(); |
432 | 0 |
|
433 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
434 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
435 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
436 | 0 | // otherwise we won't be able to properly recreate it later, since |
437 | 0 | // we won't know what proto to use. Note that we don't check |
438 | 0 | // aGivenProto here, since it's entirely possible (and even |
439 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
440 | 0 | // same as canonicalProto. |
441 | 0 | if (proto != canonicalProto) { |
442 | 0 | PreserveWrapper(aObject); |
443 | 0 | } |
444 | 0 |
|
445 | 0 | return true; |
446 | 0 | } |
447 | | |
448 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
449 | | nullptr, |
450 | | nullptr, |
451 | | nullptr, |
452 | | { sNativeProperties.Upcast(), nullptr }, |
453 | | prototypes::id::XULScrollElement, |
454 | | constructors::id::XULScrollElement, |
455 | | XULElement_Binding::sNativePropertyHooks, |
456 | | &DefaultXrayExpandoObjectClass |
457 | | } }; |
458 | | |
459 | | void |
460 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
461 | 0 | { |
462 | 0 | JS::Handle<JSObject*> parentProto(XULElement_Binding::GetProtoObjectHandle(aCx)); |
463 | 0 | if (!parentProto) { |
464 | 0 | return; |
465 | 0 | } |
466 | 0 | |
467 | 0 | JS::Handle<JSObject*> constructorProto(XULElement_Binding::GetConstructorObjectHandle(aCx)); |
468 | 0 | if (!constructorProto) { |
469 | 0 | return; |
470 | 0 | } |
471 | 0 | |
472 | 0 | static bool sIdsInited = false; |
473 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
474 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
475 | 0 | return; |
476 | 0 | } |
477 | 0 | sIdsInited = true; |
478 | 0 | } |
479 | 0 |
|
480 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::XULScrollElement); |
481 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::XULScrollElement); |
482 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
483 | 0 | &sPrototypeClass.mBase, protoCache, |
484 | 0 | nullptr, |
485 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
486 | 0 | interfaceCache, |
487 | 0 | sNativeProperties.Upcast(), |
488 | 0 | nullptr, |
489 | 0 | "XULScrollElement", aDefineOnGlobal, |
490 | 0 | nullptr, |
491 | 0 | false); |
492 | 0 | } |
493 | | |
494 | | JSObject* |
495 | | GetConstructorObject(JSContext* aCx) |
496 | 0 | { |
497 | 0 | return GetConstructorObjectHandle(aCx); |
498 | 0 | } |
499 | | |
500 | | } // namespace XULScrollElement_Binding |
501 | | |
502 | | |
503 | | |
504 | | } // namespace dom |
505 | | } // namespace mozilla |