/work/obj-fuzz/dom/bindings/PlacesEventBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM PlacesEvent.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "PlacesEventBinding.h" |
4 | | #include "WrapperFactory.h" |
5 | | #include "jsapi.h" |
6 | | #include "mozilla/OwningNonNull.h" |
7 | | #include "mozilla/dom/BindingUtils.h" |
8 | | #include "mozilla/dom/DOMJSClass.h" |
9 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
10 | | #include "mozilla/dom/Nullable.h" |
11 | | #include "mozilla/dom/PlacesEvent.h" |
12 | | #include "mozilla/dom/PlacesVisit.h" |
13 | | #include "mozilla/dom/PrimitiveConversions.h" |
14 | | #include "mozilla/dom/XrayExpandoClass.h" |
15 | | #include "nsContentUtils.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 PlacesEventTypeValues { |
25 | | extern const EnumEntry strings[3] = { |
26 | | {"none", 4}, |
27 | | {"page-visited", 12}, |
28 | | { nullptr, 0 } |
29 | | }; |
30 | | } // namespace PlacesEventTypeValues |
31 | | |
32 | | bool |
33 | | ToJSValue(JSContext* aCx, PlacesEventType aArgument, JS::MutableHandle<JS::Value> aValue) |
34 | 0 | { |
35 | 0 | MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(PlacesEventTypeValues::strings)); |
36 | 0 | JSString* resultStr = |
37 | 0 | JS_NewStringCopyN(aCx, PlacesEventTypeValues::strings[uint32_t(aArgument)].value, |
38 | 0 | PlacesEventTypeValues::strings[uint32_t(aArgument)].length); |
39 | 0 | if (!resultStr) { |
40 | 0 | return false; |
41 | 0 | } |
42 | 0 | aValue.setString(resultStr); |
43 | 0 | return true; |
44 | 0 | } |
45 | | |
46 | | |
47 | | namespace PlacesEvent_Binding { |
48 | | |
49 | | MOZ_CAN_RUN_SCRIPT static bool |
50 | | get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PlacesEvent* self, JSJitGetterCallArgs args) |
51 | 0 | { |
52 | 0 | AUTO_PROFILER_LABEL_FAST("get PlacesEvent.type", DOM, cx); |
53 | 0 |
|
54 | 0 | PlacesEventType result(self->Type()); |
55 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
56 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
57 | 0 | return false; |
58 | 0 | } |
59 | 0 | return true; |
60 | 0 | } |
61 | | |
62 | | static const JSJitInfo type_getterinfo = { |
63 | | { (JSJitGetterOp)get_type }, |
64 | | { prototypes::id::PlacesEvent }, |
65 | | { PrototypeTraits<prototypes::id::PlacesEvent>::Depth }, |
66 | | JSJitInfo::Getter, |
67 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
68 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
69 | | false, /* isInfallible. False in setters. */ |
70 | | false, /* isMovable. Not relevant for setters. */ |
71 | | false, /* isEliminatable. Not relevant for setters. */ |
72 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
73 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
74 | | false, /* isTypedMethod. Only relevant for methods. */ |
75 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
76 | | }; |
77 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
78 | | static_assert(0 < 1, "There is no slot for us"); |
79 | | |
80 | | static bool |
81 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
82 | 0 | { |
83 | 0 | mozilla::dom::PlacesEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PlacesEvent>(obj); |
84 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
85 | 0 | // obviously can't preserve if we're not initialized. |
86 | 0 | if (self && self->GetWrapperPreserveColor()) { |
87 | 0 | PreserveWrapper(self); |
88 | 0 | } |
89 | 0 | return true; |
90 | 0 | } |
91 | | |
92 | | static void |
93 | | _finalize(js::FreeOp* fop, JSObject* obj) |
94 | 0 | { |
95 | 0 | mozilla::dom::PlacesEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PlacesEvent>(obj); |
96 | 0 | if (self) { |
97 | 0 | ClearWrapper(self, self, obj); |
98 | 0 | AddForDeferredFinalization<mozilla::dom::PlacesEvent>(self); |
99 | 0 | } |
100 | 0 | } |
101 | | |
102 | | static size_t |
103 | | _objectMoved(JSObject* obj, JSObject* old) |
104 | 0 | { |
105 | 0 | mozilla::dom::PlacesEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PlacesEvent>(obj); |
106 | 0 | if (self) { |
107 | 0 | UpdateWrapper(self, self, obj, old); |
108 | 0 | } |
109 | 0 |
|
110 | 0 | return 0; |
111 | 0 | } |
112 | | |
113 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
114 | | #if defined(__clang__) |
115 | | #pragma clang diagnostic push |
116 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
117 | | #endif |
118 | | static const JSPropertySpec sAttributes_specs[] = { |
119 | | { "type", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &type_getterinfo, nullptr, nullptr }, |
120 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
121 | | }; |
122 | | #if defined(__clang__) |
123 | | #pragma clang diagnostic pop |
124 | | #endif |
125 | | |
126 | | |
127 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
128 | | { nullptr, &sAttributes_specs[0] }, |
129 | | { nullptr, nullptr } |
130 | | }; |
131 | | |
132 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
133 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
134 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
135 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
136 | | |
137 | | |
138 | | static uint16_t sNativeProperties_sortedPropertyIndices[1]; |
139 | | static PropertyInfo sNativeProperties_propertyInfos[1]; |
140 | | |
141 | | static const NativePropertiesN<1> sNativeProperties = { |
142 | | false, 0, |
143 | | false, 0, |
144 | | false, 0, |
145 | | true, 0 /* sAttributes */, |
146 | | false, 0, |
147 | | false, 0, |
148 | | false, 0, |
149 | | -1, |
150 | | 1, |
151 | | sNativeProperties_sortedPropertyIndices, |
152 | | { |
153 | | { sAttributes, &sNativeProperties_propertyInfos[0] } |
154 | | } |
155 | | }; |
156 | | static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
157 | | "We have a property info count that is oversized"); |
158 | | |
159 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
160 | | { |
161 | | "Function", |
162 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
163 | | &sBoringInterfaceObjectClassClassOps, |
164 | | JS_NULL_CLASS_SPEC, |
165 | | JS_NULL_CLASS_EXT, |
166 | | &sInterfaceObjectClassObjectOps |
167 | | }, |
168 | | eInterface, |
169 | | true, |
170 | | prototypes::id::PlacesEvent, |
171 | | PrototypeTraits<prototypes::id::PlacesEvent>::Depth, |
172 | | sNativePropertyHooks, |
173 | | "function PlacesEvent() {\n [native code]\n}", |
174 | | JS::GetRealmFunctionPrototype |
175 | | }; |
176 | | |
177 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
178 | | { |
179 | | "PlacesEventPrototype", |
180 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
181 | | JS_NULL_CLASS_OPS, |
182 | | JS_NULL_CLASS_SPEC, |
183 | | JS_NULL_CLASS_EXT, |
184 | | JS_NULL_OBJECT_OPS |
185 | | }, |
186 | | eInterfacePrototype, |
187 | | false, |
188 | | prototypes::id::PlacesEvent, |
189 | | PrototypeTraits<prototypes::id::PlacesEvent>::Depth, |
190 | | sNativePropertyHooks, |
191 | | "[object PlacesEventPrototype]", |
192 | | JS::GetRealmObjectPrototype |
193 | | }; |
194 | | |
195 | | bool |
196 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
197 | 0 | { |
198 | 0 | return nsContentUtils::ThreadsafeIsSystemCaller(aCx); |
199 | 0 | } |
200 | | |
201 | | static const js::ClassOps sClassOps = { |
202 | | _addProperty, /* addProperty */ |
203 | | nullptr, /* delProperty */ |
204 | | nullptr, /* enumerate */ |
205 | | nullptr, /* newEnumerate */ |
206 | | nullptr, /* resolve */ |
207 | | nullptr, /* mayResolve */ |
208 | | _finalize, /* finalize */ |
209 | | nullptr, /* call */ |
210 | | nullptr, /* hasInstance */ |
211 | | nullptr, /* construct */ |
212 | | nullptr, /* trace */ |
213 | | }; |
214 | | |
215 | | static const js::ClassExtension sClassExtension = { |
216 | | nullptr, /* weakmapKeyDelegateOp */ |
217 | | _objectMoved /* objectMovedOp */ |
218 | | }; |
219 | | |
220 | | static const DOMJSClass sClass = { |
221 | | { "PlacesEvent", |
222 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
223 | | &sClassOps, |
224 | | JS_NULL_CLASS_SPEC, |
225 | | &sClassExtension, |
226 | | JS_NULL_OBJECT_OPS |
227 | | }, |
228 | | { prototypes::id::PlacesEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
229 | | IsBaseOf<nsISupports, mozilla::dom::PlacesEvent >::value, |
230 | | sNativePropertyHooks, |
231 | | FindAssociatedGlobalForNative<mozilla::dom::PlacesEvent>::Get, |
232 | | GetProtoObjectHandle, |
233 | | GetCCParticipant<mozilla::dom::PlacesEvent>::Get() |
234 | | }; |
235 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
236 | | "Must have the right minimal number of reserved slots."); |
237 | | static_assert(1 >= 1, |
238 | | "Must have enough reserved slots."); |
239 | | |
240 | | const JSClass* |
241 | | GetJSClass() |
242 | 0 | { |
243 | 0 | return sClass.ToJSClass(); |
244 | 0 | } |
245 | | |
246 | | bool |
247 | | Wrap(JSContext* aCx, mozilla::dom::PlacesEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
248 | 0 | { |
249 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::PlacesEvent>::value, |
250 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
251 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::PlacesEvent*>(aObject) == |
252 | 0 | reinterpret_cast<mozilla::dom::PlacesEvent*>(aObject), |
253 | 0 | "Multiple inheritance for mozilla::dom::PlacesEvent is broken."); |
254 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
255 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
256 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
257 | 0 | "You should probably not be using Wrap() directly; use " |
258 | 0 | "GetOrCreateDOMReflector instead"); |
259 | 0 |
|
260 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
261 | 0 | "nsISupports must be on our primary inheritance chain"); |
262 | 0 |
|
263 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
264 | 0 | if (!global) { |
265 | 0 | return false; |
266 | 0 | } |
267 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
268 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
269 | 0 |
|
270 | 0 | // That might have ended up wrapping us already, due to the wonders |
271 | 0 | // of XBL. Check for that, and bail out as needed. |
272 | 0 | aReflector.set(aCache->GetWrapper()); |
273 | 0 | if (aReflector) { |
274 | | #ifdef DEBUG |
275 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
276 | | #endif // DEBUG |
277 | | return true; |
278 | 0 | } |
279 | 0 |
|
280 | 0 | JSAutoRealm ar(aCx, global); |
281 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
282 | 0 | if (!canonicalProto) { |
283 | 0 | return false; |
284 | 0 | } |
285 | 0 | JS::Rooted<JSObject*> proto(aCx); |
286 | 0 | if (aGivenProto) { |
287 | 0 | proto = aGivenProto; |
288 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
289 | 0 | // coming in, we changed compartments to that of "parent" so may need |
290 | 0 | // to wrap the proto here. |
291 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
292 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
293 | 0 | return false; |
294 | 0 | } |
295 | 0 | } |
296 | 0 | } else { |
297 | 0 | proto = canonicalProto; |
298 | 0 | } |
299 | 0 |
|
300 | 0 | BindingJSObjectCreator<mozilla::dom::PlacesEvent> creator(aCx); |
301 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
302 | 0 | if (!aReflector) { |
303 | 0 | return false; |
304 | 0 | } |
305 | 0 | |
306 | 0 | aCache->SetWrapper(aReflector); |
307 | 0 | creator.InitializationSucceeded(); |
308 | 0 |
|
309 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
310 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
311 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
312 | 0 | // otherwise we won't be able to properly recreate it later, since |
313 | 0 | // we won't know what proto to use. Note that we don't check |
314 | 0 | // aGivenProto here, since it's entirely possible (and even |
315 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
316 | 0 | // same as canonicalProto. |
317 | 0 | if (proto != canonicalProto) { |
318 | 0 | PreserveWrapper(aObject); |
319 | 0 | } |
320 | 0 |
|
321 | 0 | return true; |
322 | 0 | } |
323 | | |
324 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
325 | | nullptr, |
326 | | nullptr, |
327 | | nullptr, |
328 | | { sNativeProperties.Upcast(), nullptr }, |
329 | | prototypes::id::PlacesEvent, |
330 | | constructors::id::PlacesEvent, |
331 | | nullptr, |
332 | | &DefaultXrayExpandoObjectClass |
333 | | } }; |
334 | | |
335 | | void |
336 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
337 | 0 | { |
338 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
339 | 0 | if (!parentProto) { |
340 | 0 | return; |
341 | 0 | } |
342 | 0 | |
343 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
344 | 0 | if (!constructorProto) { |
345 | 0 | return; |
346 | 0 | } |
347 | 0 | |
348 | 0 | static bool sIdsInited = false; |
349 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
350 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
351 | 0 | return; |
352 | 0 | } |
353 | 0 | sIdsInited = true; |
354 | 0 | } |
355 | 0 |
|
356 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PlacesEvent); |
357 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::PlacesEvent); |
358 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
359 | 0 | &sPrototypeClass.mBase, protoCache, |
360 | 0 | nullptr, |
361 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
362 | 0 | interfaceCache, |
363 | 0 | sNativeProperties.Upcast(), |
364 | 0 | nullptr, |
365 | 0 | "PlacesEvent", aDefineOnGlobal, |
366 | 0 | nullptr, |
367 | 0 | false); |
368 | 0 | } |
369 | | |
370 | | JSObject* |
371 | | GetProtoObject(JSContext* aCx) |
372 | 0 | { |
373 | 0 | return GetProtoObjectHandle(aCx); |
374 | 0 | } |
375 | | |
376 | | JSObject* |
377 | | GetConstructorObject(JSContext* aCx) |
378 | 0 | { |
379 | 0 | return GetConstructorObjectHandle(aCx); |
380 | 0 | } |
381 | | |
382 | | } // namespace PlacesEvent_Binding |
383 | | |
384 | | |
385 | | |
386 | | namespace PlacesVisit_Binding { |
387 | | |
388 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<PlacesEvent_Binding::NativeType>::value, |
389 | | "Can't inherit from an interface with a different ownership model."); |
390 | | |
391 | | MOZ_CAN_RUN_SCRIPT static bool |
392 | | get_url(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PlacesVisit* self, JSJitGetterCallArgs args) |
393 | 0 | { |
394 | 0 | AUTO_PROFILER_LABEL_FAST("get PlacesVisit.url", DOM, cx); |
395 | 0 |
|
396 | 0 | DOMString result; |
397 | 0 | self->GetUrl(result); |
398 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
399 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
400 | 0 | return false; |
401 | 0 | } |
402 | 0 | return true; |
403 | 0 | } |
404 | | |
405 | | static const JSJitInfo url_getterinfo = { |
406 | | { (JSJitGetterOp)get_url }, |
407 | | { prototypes::id::PlacesVisit }, |
408 | | { PrototypeTraits<prototypes::id::PlacesVisit>::Depth }, |
409 | | JSJitInfo::Getter, |
410 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
411 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
412 | | false, /* isInfallible. False in setters. */ |
413 | | false, /* isMovable. Not relevant for setters. */ |
414 | | false, /* isEliminatable. Not relevant for setters. */ |
415 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
416 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
417 | | false, /* isTypedMethod. Only relevant for methods. */ |
418 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
419 | | }; |
420 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
421 | | static_assert(0 < 1, "There is no slot for us"); |
422 | | |
423 | | MOZ_CAN_RUN_SCRIPT static bool |
424 | | get_visitId(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PlacesVisit* self, JSJitGetterCallArgs args) |
425 | 0 | { |
426 | 0 | AUTO_PROFILER_LABEL_FAST("get PlacesVisit.visitId", DOM, cx); |
427 | 0 |
|
428 | 0 | uint64_t result(self->VisitId()); |
429 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
430 | 0 | args.rval().set(JS_NumberValue(double(result))); |
431 | 0 | return true; |
432 | 0 | } |
433 | | |
434 | | static const JSJitInfo visitId_getterinfo = { |
435 | | { (JSJitGetterOp)get_visitId }, |
436 | | { prototypes::id::PlacesVisit }, |
437 | | { PrototypeTraits<prototypes::id::PlacesVisit>::Depth }, |
438 | | JSJitInfo::Getter, |
439 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
440 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
441 | | true, /* isInfallible. False in setters. */ |
442 | | false, /* isMovable. Not relevant for setters. */ |
443 | | false, /* isEliminatable. Not relevant for setters. */ |
444 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
445 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
446 | | false, /* isTypedMethod. Only relevant for methods. */ |
447 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
448 | | }; |
449 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
450 | | static_assert(0 < 1, "There is no slot for us"); |
451 | | |
452 | | MOZ_CAN_RUN_SCRIPT static bool |
453 | | get_visitTime(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PlacesVisit* self, JSJitGetterCallArgs args) |
454 | 0 | { |
455 | 0 | AUTO_PROFILER_LABEL_FAST("get PlacesVisit.visitTime", DOM, cx); |
456 | 0 |
|
457 | 0 | uint64_t result(self->VisitTime()); |
458 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
459 | 0 | args.rval().set(JS_NumberValue(double(result))); |
460 | 0 | return true; |
461 | 0 | } |
462 | | |
463 | | static const JSJitInfo visitTime_getterinfo = { |
464 | | { (JSJitGetterOp)get_visitTime }, |
465 | | { prototypes::id::PlacesVisit }, |
466 | | { PrototypeTraits<prototypes::id::PlacesVisit>::Depth }, |
467 | | JSJitInfo::Getter, |
468 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
469 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
470 | | true, /* isInfallible. False in setters. */ |
471 | | false, /* isMovable. Not relevant for setters. */ |
472 | | false, /* isEliminatable. Not relevant for setters. */ |
473 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
474 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
475 | | false, /* isTypedMethod. Only relevant for methods. */ |
476 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
477 | | }; |
478 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
479 | | static_assert(0 < 1, "There is no slot for us"); |
480 | | |
481 | | MOZ_CAN_RUN_SCRIPT static bool |
482 | | get_referringVisitId(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PlacesVisit* self, JSJitGetterCallArgs args) |
483 | 0 | { |
484 | 0 | AUTO_PROFILER_LABEL_FAST("get PlacesVisit.referringVisitId", DOM, cx); |
485 | 0 |
|
486 | 0 | uint64_t result(self->ReferringVisitId()); |
487 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
488 | 0 | args.rval().set(JS_NumberValue(double(result))); |
489 | 0 | return true; |
490 | 0 | } |
491 | | |
492 | | static const JSJitInfo referringVisitId_getterinfo = { |
493 | | { (JSJitGetterOp)get_referringVisitId }, |
494 | | { prototypes::id::PlacesVisit }, |
495 | | { PrototypeTraits<prototypes::id::PlacesVisit>::Depth }, |
496 | | JSJitInfo::Getter, |
497 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
498 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
499 | | true, /* isInfallible. False in setters. */ |
500 | | false, /* isMovable. Not relevant for setters. */ |
501 | | false, /* isEliminatable. Not relevant for setters. */ |
502 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
503 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
504 | | false, /* isTypedMethod. Only relevant for methods. */ |
505 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
506 | | }; |
507 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
508 | | static_assert(0 < 1, "There is no slot for us"); |
509 | | |
510 | | MOZ_CAN_RUN_SCRIPT static bool |
511 | | get_transitionType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PlacesVisit* self, JSJitGetterCallArgs args) |
512 | 0 | { |
513 | 0 | AUTO_PROFILER_LABEL_FAST("get PlacesVisit.transitionType", DOM, cx); |
514 | 0 |
|
515 | 0 | uint32_t result(self->TransitionType()); |
516 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
517 | 0 | args.rval().setNumber(result); |
518 | 0 | return true; |
519 | 0 | } |
520 | | |
521 | | static const JSJitInfo transitionType_getterinfo = { |
522 | | { (JSJitGetterOp)get_transitionType }, |
523 | | { prototypes::id::PlacesVisit }, |
524 | | { PrototypeTraits<prototypes::id::PlacesVisit>::Depth }, |
525 | | JSJitInfo::Getter, |
526 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
527 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
528 | | true, /* isInfallible. False in setters. */ |
529 | | false, /* isMovable. Not relevant for setters. */ |
530 | | false, /* isEliminatable. Not relevant for setters. */ |
531 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
532 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
533 | | false, /* isTypedMethod. Only relevant for methods. */ |
534 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
535 | | }; |
536 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
537 | | static_assert(0 < 1, "There is no slot for us"); |
538 | | |
539 | | MOZ_CAN_RUN_SCRIPT static bool |
540 | | get_pageGuid(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PlacesVisit* self, JSJitGetterCallArgs args) |
541 | 0 | { |
542 | 0 | AUTO_PROFILER_LABEL_FAST("get PlacesVisit.pageGuid", DOM, cx); |
543 | 0 |
|
544 | 0 | nsCString result; |
545 | 0 | self->GetPageGuid(result); |
546 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
547 | 0 | if (!NonVoidByteStringToJsval(cx, result, args.rval())) { |
548 | 0 | return false; |
549 | 0 | } |
550 | 0 | return true; |
551 | 0 | } |
552 | | |
553 | | static const JSJitInfo pageGuid_getterinfo = { |
554 | | { (JSJitGetterOp)get_pageGuid }, |
555 | | { prototypes::id::PlacesVisit }, |
556 | | { PrototypeTraits<prototypes::id::PlacesVisit>::Depth }, |
557 | | JSJitInfo::Getter, |
558 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
559 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
560 | | false, /* isInfallible. False in setters. */ |
561 | | false, /* isMovable. Not relevant for setters. */ |
562 | | false, /* isEliminatable. Not relevant for setters. */ |
563 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
564 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
565 | | false, /* isTypedMethod. Only relevant for methods. */ |
566 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
567 | | }; |
568 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
569 | | static_assert(0 < 1, "There is no slot for us"); |
570 | | |
571 | | MOZ_CAN_RUN_SCRIPT static bool |
572 | | get_hidden(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PlacesVisit* self, JSJitGetterCallArgs args) |
573 | 0 | { |
574 | 0 | AUTO_PROFILER_LABEL_FAST("get PlacesVisit.hidden", DOM, cx); |
575 | 0 |
|
576 | 0 | bool result(self->Hidden()); |
577 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
578 | 0 | args.rval().setBoolean(result); |
579 | 0 | return true; |
580 | 0 | } |
581 | | |
582 | | static const JSJitInfo hidden_getterinfo = { |
583 | | { (JSJitGetterOp)get_hidden }, |
584 | | { prototypes::id::PlacesVisit }, |
585 | | { PrototypeTraits<prototypes::id::PlacesVisit>::Depth }, |
586 | | JSJitInfo::Getter, |
587 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
588 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
589 | | true, /* isInfallible. False in setters. */ |
590 | | false, /* isMovable. Not relevant for setters. */ |
591 | | false, /* isEliminatable. Not relevant for setters. */ |
592 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
593 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
594 | | false, /* isTypedMethod. Only relevant for methods. */ |
595 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
596 | | }; |
597 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
598 | | static_assert(0 < 1, "There is no slot for us"); |
599 | | |
600 | | MOZ_CAN_RUN_SCRIPT static bool |
601 | | get_visitCount(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PlacesVisit* self, JSJitGetterCallArgs args) |
602 | 0 | { |
603 | 0 | AUTO_PROFILER_LABEL_FAST("get PlacesVisit.visitCount", DOM, cx); |
604 | 0 |
|
605 | 0 | uint32_t result(self->VisitCount()); |
606 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
607 | 0 | args.rval().setNumber(result); |
608 | 0 | return true; |
609 | 0 | } |
610 | | |
611 | | static const JSJitInfo visitCount_getterinfo = { |
612 | | { (JSJitGetterOp)get_visitCount }, |
613 | | { prototypes::id::PlacesVisit }, |
614 | | { PrototypeTraits<prototypes::id::PlacesVisit>::Depth }, |
615 | | JSJitInfo::Getter, |
616 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
617 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
618 | | true, /* isInfallible. False in setters. */ |
619 | | false, /* isMovable. Not relevant for setters. */ |
620 | | false, /* isEliminatable. Not relevant for setters. */ |
621 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
622 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
623 | | false, /* isTypedMethod. Only relevant for methods. */ |
624 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
625 | | }; |
626 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
627 | | static_assert(0 < 1, "There is no slot for us"); |
628 | | |
629 | | MOZ_CAN_RUN_SCRIPT static bool |
630 | | get_typedCount(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PlacesVisit* self, JSJitGetterCallArgs args) |
631 | 0 | { |
632 | 0 | AUTO_PROFILER_LABEL_FAST("get PlacesVisit.typedCount", DOM, cx); |
633 | 0 |
|
634 | 0 | uint32_t result(self->TypedCount()); |
635 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
636 | 0 | args.rval().setNumber(result); |
637 | 0 | return true; |
638 | 0 | } |
639 | | |
640 | | static const JSJitInfo typedCount_getterinfo = { |
641 | | { (JSJitGetterOp)get_typedCount }, |
642 | | { prototypes::id::PlacesVisit }, |
643 | | { PrototypeTraits<prototypes::id::PlacesVisit>::Depth }, |
644 | | JSJitInfo::Getter, |
645 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
646 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
647 | | true, /* isInfallible. False in setters. */ |
648 | | false, /* isMovable. Not relevant for setters. */ |
649 | | false, /* isEliminatable. Not relevant for setters. */ |
650 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
651 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
652 | | false, /* isTypedMethod. Only relevant for methods. */ |
653 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
654 | | }; |
655 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
656 | | static_assert(0 < 1, "There is no slot for us"); |
657 | | |
658 | | MOZ_CAN_RUN_SCRIPT static bool |
659 | | get_lastKnownTitle(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PlacesVisit* self, JSJitGetterCallArgs args) |
660 | 0 | { |
661 | 0 | AUTO_PROFILER_LABEL_FAST("get PlacesVisit.lastKnownTitle", DOM, cx); |
662 | 0 |
|
663 | 0 | DOMString result; |
664 | 0 | self->GetLastKnownTitle(result); |
665 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
666 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
667 | 0 | return false; |
668 | 0 | } |
669 | 0 | return true; |
670 | 0 | } |
671 | | |
672 | | static const JSJitInfo lastKnownTitle_getterinfo = { |
673 | | { (JSJitGetterOp)get_lastKnownTitle }, |
674 | | { prototypes::id::PlacesVisit }, |
675 | | { PrototypeTraits<prototypes::id::PlacesVisit>::Depth }, |
676 | | JSJitInfo::Getter, |
677 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
678 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
679 | | false, /* isInfallible. False in setters. */ |
680 | | false, /* isMovable. Not relevant for setters. */ |
681 | | false, /* isEliminatable. Not relevant for setters. */ |
682 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
683 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
684 | | false, /* isTypedMethod. Only relevant for methods. */ |
685 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
686 | | }; |
687 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
688 | | static_assert(0 < 1, "There is no slot for us"); |
689 | | |
690 | | static bool |
691 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
692 | 0 | { |
693 | 0 | mozilla::dom::PlacesVisit* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PlacesVisit>(obj); |
694 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
695 | 0 | // obviously can't preserve if we're not initialized. |
696 | 0 | if (self && self->GetWrapperPreserveColor()) { |
697 | 0 | PreserveWrapper(self); |
698 | 0 | } |
699 | 0 | return true; |
700 | 0 | } |
701 | | |
702 | | static void |
703 | | _finalize(js::FreeOp* fop, JSObject* obj) |
704 | 0 | { |
705 | 0 | mozilla::dom::PlacesVisit* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PlacesVisit>(obj); |
706 | 0 | if (self) { |
707 | 0 | ClearWrapper(self, self, obj); |
708 | 0 | AddForDeferredFinalization<mozilla::dom::PlacesVisit>(self); |
709 | 0 | } |
710 | 0 | } |
711 | | |
712 | | static size_t |
713 | | _objectMoved(JSObject* obj, JSObject* old) |
714 | 0 | { |
715 | 0 | mozilla::dom::PlacesVisit* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PlacesVisit>(obj); |
716 | 0 | if (self) { |
717 | 0 | UpdateWrapper(self, self, obj, old); |
718 | 0 | } |
719 | 0 |
|
720 | 0 | return 0; |
721 | 0 | } |
722 | | |
723 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
724 | | #if defined(__clang__) |
725 | | #pragma clang diagnostic push |
726 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
727 | | #endif |
728 | | static const JSPropertySpec sAttributes_specs[] = { |
729 | | { "url", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &url_getterinfo, nullptr, nullptr }, |
730 | | { "visitId", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &visitId_getterinfo, nullptr, nullptr }, |
731 | | { "visitTime", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &visitTime_getterinfo, nullptr, nullptr }, |
732 | | { "referringVisitId", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &referringVisitId_getterinfo, nullptr, nullptr }, |
733 | | { "transitionType", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &transitionType_getterinfo, nullptr, nullptr }, |
734 | | { "pageGuid", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &pageGuid_getterinfo, nullptr, nullptr }, |
735 | | { "hidden", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &hidden_getterinfo, nullptr, nullptr }, |
736 | | { "visitCount", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &visitCount_getterinfo, nullptr, nullptr }, |
737 | | { "typedCount", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &typedCount_getterinfo, nullptr, nullptr }, |
738 | | { "lastKnownTitle", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &lastKnownTitle_getterinfo, nullptr, nullptr }, |
739 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
740 | | }; |
741 | | #if defined(__clang__) |
742 | | #pragma clang diagnostic pop |
743 | | #endif |
744 | | |
745 | | |
746 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
747 | | { nullptr, &sAttributes_specs[0] }, |
748 | | { nullptr, nullptr } |
749 | | }; |
750 | | |
751 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
752 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
753 | | static_assert(10 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
754 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
755 | | |
756 | | |
757 | | static uint16_t sNativeProperties_sortedPropertyIndices[10]; |
758 | | static PropertyInfo sNativeProperties_propertyInfos[10]; |
759 | | |
760 | | static const NativePropertiesN<1> sNativeProperties = { |
761 | | false, 0, |
762 | | false, 0, |
763 | | false, 0, |
764 | | true, 0 /* sAttributes */, |
765 | | false, 0, |
766 | | false, 0, |
767 | | false, 0, |
768 | | -1, |
769 | | 10, |
770 | | sNativeProperties_sortedPropertyIndices, |
771 | | { |
772 | | { sAttributes, &sNativeProperties_propertyInfos[0] } |
773 | | } |
774 | | }; |
775 | | static_assert(10 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
776 | | "We have a property info count that is oversized"); |
777 | | |
778 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
779 | | { |
780 | | "Function", |
781 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
782 | | &sBoringInterfaceObjectClassClassOps, |
783 | | JS_NULL_CLASS_SPEC, |
784 | | JS_NULL_CLASS_EXT, |
785 | | &sInterfaceObjectClassObjectOps |
786 | | }, |
787 | | eInterface, |
788 | | true, |
789 | | prototypes::id::PlacesVisit, |
790 | | PrototypeTraits<prototypes::id::PlacesVisit>::Depth, |
791 | | sNativePropertyHooks, |
792 | | "function PlacesVisit() {\n [native code]\n}", |
793 | | PlacesEvent_Binding::GetConstructorObject |
794 | | }; |
795 | | |
796 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
797 | | { |
798 | | "PlacesVisitPrototype", |
799 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
800 | | JS_NULL_CLASS_OPS, |
801 | | JS_NULL_CLASS_SPEC, |
802 | | JS_NULL_CLASS_EXT, |
803 | | JS_NULL_OBJECT_OPS |
804 | | }, |
805 | | eInterfacePrototype, |
806 | | false, |
807 | | prototypes::id::PlacesVisit, |
808 | | PrototypeTraits<prototypes::id::PlacesVisit>::Depth, |
809 | | sNativePropertyHooks, |
810 | | "[object PlacesVisitPrototype]", |
811 | | PlacesEvent_Binding::GetProtoObject |
812 | | }; |
813 | | |
814 | | bool |
815 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
816 | 0 | { |
817 | 0 | return nsContentUtils::ThreadsafeIsSystemCaller(aCx); |
818 | 0 | } |
819 | | |
820 | | static const js::ClassOps sClassOps = { |
821 | | _addProperty, /* addProperty */ |
822 | | nullptr, /* delProperty */ |
823 | | nullptr, /* enumerate */ |
824 | | nullptr, /* newEnumerate */ |
825 | | nullptr, /* resolve */ |
826 | | nullptr, /* mayResolve */ |
827 | | _finalize, /* finalize */ |
828 | | nullptr, /* call */ |
829 | | nullptr, /* hasInstance */ |
830 | | nullptr, /* construct */ |
831 | | nullptr, /* trace */ |
832 | | }; |
833 | | |
834 | | static const js::ClassExtension sClassExtension = { |
835 | | nullptr, /* weakmapKeyDelegateOp */ |
836 | | _objectMoved /* objectMovedOp */ |
837 | | }; |
838 | | |
839 | | static const DOMJSClass sClass = { |
840 | | { "PlacesVisit", |
841 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
842 | | &sClassOps, |
843 | | JS_NULL_CLASS_SPEC, |
844 | | &sClassExtension, |
845 | | JS_NULL_OBJECT_OPS |
846 | | }, |
847 | | { prototypes::id::PlacesEvent, prototypes::id::PlacesVisit, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
848 | | IsBaseOf<nsISupports, mozilla::dom::PlacesVisit >::value, |
849 | | sNativePropertyHooks, |
850 | | FindAssociatedGlobalForNative<mozilla::dom::PlacesVisit>::Get, |
851 | | GetProtoObjectHandle, |
852 | | GetCCParticipant<mozilla::dom::PlacesVisit>::Get() |
853 | | }; |
854 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
855 | | "Must have the right minimal number of reserved slots."); |
856 | | static_assert(1 >= 1, |
857 | | "Must have enough reserved slots."); |
858 | | |
859 | | const JSClass* |
860 | | GetJSClass() |
861 | 0 | { |
862 | 0 | return sClass.ToJSClass(); |
863 | 0 | } |
864 | | |
865 | | bool |
866 | | Wrap(JSContext* aCx, mozilla::dom::PlacesVisit* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
867 | 0 | { |
868 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::PlacesVisit>::value, |
869 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
870 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::PlacesVisit*>(aObject) == |
871 | 0 | reinterpret_cast<mozilla::dom::PlacesVisit*>(aObject), |
872 | 0 | "Multiple inheritance for mozilla::dom::PlacesVisit is broken."); |
873 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::PlacesEvent*>(aObject) == |
874 | 0 | reinterpret_cast<mozilla::dom::PlacesEvent*>(aObject), |
875 | 0 | "Multiple inheritance for mozilla::dom::PlacesEvent is broken."); |
876 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
877 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
878 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
879 | 0 | "You should probably not be using Wrap() directly; use " |
880 | 0 | "GetOrCreateDOMReflector instead"); |
881 | 0 |
|
882 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
883 | 0 | "nsISupports must be on our primary inheritance chain"); |
884 | 0 |
|
885 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
886 | 0 | if (!global) { |
887 | 0 | return false; |
888 | 0 | } |
889 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
890 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
891 | 0 |
|
892 | 0 | // That might have ended up wrapping us already, due to the wonders |
893 | 0 | // of XBL. Check for that, and bail out as needed. |
894 | 0 | aReflector.set(aCache->GetWrapper()); |
895 | 0 | if (aReflector) { |
896 | | #ifdef DEBUG |
897 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
898 | | #endif // DEBUG |
899 | | return true; |
900 | 0 | } |
901 | 0 |
|
902 | 0 | JSAutoRealm ar(aCx, global); |
903 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
904 | 0 | if (!canonicalProto) { |
905 | 0 | return false; |
906 | 0 | } |
907 | 0 | JS::Rooted<JSObject*> proto(aCx); |
908 | 0 | if (aGivenProto) { |
909 | 0 | proto = aGivenProto; |
910 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
911 | 0 | // coming in, we changed compartments to that of "parent" so may need |
912 | 0 | // to wrap the proto here. |
913 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
914 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
915 | 0 | return false; |
916 | 0 | } |
917 | 0 | } |
918 | 0 | } else { |
919 | 0 | proto = canonicalProto; |
920 | 0 | } |
921 | 0 |
|
922 | 0 | BindingJSObjectCreator<mozilla::dom::PlacesVisit> creator(aCx); |
923 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
924 | 0 | if (!aReflector) { |
925 | 0 | return false; |
926 | 0 | } |
927 | 0 | |
928 | 0 | aCache->SetWrapper(aReflector); |
929 | 0 | creator.InitializationSucceeded(); |
930 | 0 |
|
931 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
932 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
933 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
934 | 0 | // otherwise we won't be able to properly recreate it later, since |
935 | 0 | // we won't know what proto to use. Note that we don't check |
936 | 0 | // aGivenProto here, since it's entirely possible (and even |
937 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
938 | 0 | // same as canonicalProto. |
939 | 0 | if (proto != canonicalProto) { |
940 | 0 | PreserveWrapper(aObject); |
941 | 0 | } |
942 | 0 |
|
943 | 0 | return true; |
944 | 0 | } |
945 | | |
946 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
947 | | nullptr, |
948 | | nullptr, |
949 | | nullptr, |
950 | | { sNativeProperties.Upcast(), nullptr }, |
951 | | prototypes::id::PlacesVisit, |
952 | | constructors::id::PlacesVisit, |
953 | | PlacesEvent_Binding::sNativePropertyHooks, |
954 | | &DefaultXrayExpandoObjectClass |
955 | | } }; |
956 | | |
957 | | void |
958 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
959 | 0 | { |
960 | 0 | JS::Handle<JSObject*> parentProto(PlacesEvent_Binding::GetProtoObjectHandle(aCx)); |
961 | 0 | if (!parentProto) { |
962 | 0 | return; |
963 | 0 | } |
964 | 0 | |
965 | 0 | JS::Handle<JSObject*> constructorProto(PlacesEvent_Binding::GetConstructorObjectHandle(aCx)); |
966 | 0 | if (!constructorProto) { |
967 | 0 | return; |
968 | 0 | } |
969 | 0 | |
970 | 0 | static bool sIdsInited = false; |
971 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
972 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
973 | 0 | return; |
974 | 0 | } |
975 | 0 | sIdsInited = true; |
976 | 0 | } |
977 | 0 |
|
978 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PlacesVisit); |
979 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::PlacesVisit); |
980 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
981 | 0 | &sPrototypeClass.mBase, protoCache, |
982 | 0 | nullptr, |
983 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
984 | 0 | interfaceCache, |
985 | 0 | sNativeProperties.Upcast(), |
986 | 0 | nullptr, |
987 | 0 | "PlacesVisit", aDefineOnGlobal, |
988 | 0 | nullptr, |
989 | 0 | false); |
990 | 0 | } |
991 | | |
992 | | JSObject* |
993 | | GetConstructorObject(JSContext* aCx) |
994 | 0 | { |
995 | 0 | return GetConstructorObjectHandle(aCx); |
996 | 0 | } |
997 | | |
998 | | } // namespace PlacesVisit_Binding |
999 | | |
1000 | | |
1001 | | |
1002 | | } // namespace dom |
1003 | | } // namespace mozilla |