/work/obj-fuzz/dom/bindings/CaretStateChangedEventBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM CaretStateChangedEvent.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AtomList.h" |
4 | | #include "CaretStateChangedEventBinding.h" |
5 | | #include "EventBinding.h" |
6 | | #include "WrapperFactory.h" |
7 | | #include "jsapi.h" |
8 | | #include "mozilla/OwningNonNull.h" |
9 | | #include "mozilla/dom/BindingUtils.h" |
10 | | #include "mozilla/dom/CaretStateChangedEvent.h" |
11 | | #include "mozilla/dom/DOMJSClass.h" |
12 | | #include "mozilla/dom/DOMRect.h" |
13 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
14 | | #include "mozilla/dom/Nullable.h" |
15 | | #include "mozilla/dom/PrimitiveConversions.h" |
16 | | #include "mozilla/dom/ScriptSettings.h" |
17 | | #include "mozilla/dom/XrayExpandoClass.h" |
18 | | #include "nsContentUtils.h" |
19 | | |
20 | | namespace mozilla { |
21 | | namespace dom { |
22 | | |
23 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
24 | | using namespace mozilla::dom::binding_detail; |
25 | | |
26 | | |
27 | | namespace CaretChangedReasonValues { |
28 | | extern const EnumEntry strings[8] = { |
29 | | {"visibilitychange", 16}, |
30 | | {"updateposition", 14}, |
31 | | {"longpressonemptycontent", 23}, |
32 | | {"taponcaret", 10}, |
33 | | {"presscaret", 10}, |
34 | | {"releasecaret", 12}, |
35 | | {"scroll", 6}, |
36 | | { nullptr, 0 } |
37 | | }; |
38 | | } // namespace CaretChangedReasonValues |
39 | | |
40 | | bool |
41 | | ToJSValue(JSContext* aCx, CaretChangedReason aArgument, JS::MutableHandle<JS::Value> aValue) |
42 | 0 | { |
43 | 0 | MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(CaretChangedReasonValues::strings)); |
44 | 0 | JSString* resultStr = |
45 | 0 | JS_NewStringCopyN(aCx, CaretChangedReasonValues::strings[uint32_t(aArgument)].value, |
46 | 0 | CaretChangedReasonValues::strings[uint32_t(aArgument)].length); |
47 | 0 | if (!resultStr) { |
48 | 0 | return false; |
49 | 0 | } |
50 | 0 | aValue.setString(resultStr); |
51 | 0 | return true; |
52 | 0 | } |
53 | | |
54 | | |
55 | | |
56 | | CaretStateChangedEventInit::CaretStateChangedEventInit() |
57 | | : EventInit(FastDictionaryInitializer()) |
58 | 0 | { |
59 | 0 | // Safe to pass a null context if we pass a null value |
60 | 0 | Init(nullptr, JS::NullHandleValue); |
61 | 0 | } |
62 | | |
63 | | |
64 | | |
65 | | bool |
66 | | CaretStateChangedEventInit::InitIds(JSContext* cx, CaretStateChangedEventInitAtoms* atomsCache) |
67 | 0 | { |
68 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
69 | 0 |
|
70 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
71 | 0 | // uninitialized. |
72 | 0 | if (!atomsCache->selectionVisible_id.init(cx, "selectionVisible") || |
73 | 0 | !atomsCache->selectionEditable_id.init(cx, "selectionEditable") || |
74 | 0 | !atomsCache->selectedTextContent_id.init(cx, "selectedTextContent") || |
75 | 0 | !atomsCache->reason_id.init(cx, "reason") || |
76 | 0 | !atomsCache->collapsed_id.init(cx, "collapsed") || |
77 | 0 | !atomsCache->caretVisuallyVisible_id.init(cx, "caretVisuallyVisible") || |
78 | 0 | !atomsCache->caretVisible_id.init(cx, "caretVisible") || |
79 | 0 | !atomsCache->boundingClientRect_id.init(cx, "boundingClientRect")) { |
80 | 0 | return false; |
81 | 0 | } |
82 | 0 | return true; |
83 | 0 | } |
84 | | |
85 | | bool |
86 | | CaretStateChangedEventInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
87 | 0 | { |
88 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
89 | 0 | // Since in that case we will not have to do any property gets |
90 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
91 | 0 | // checkers by static analysis tools |
92 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
93 | 0 | CaretStateChangedEventInitAtoms* atomsCache = nullptr; |
94 | 0 | if (cx) { |
95 | 0 | atomsCache = GetAtomCache<CaretStateChangedEventInitAtoms>(cx); |
96 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
97 | 0 | return false; |
98 | 0 | } |
99 | 0 | } |
100 | 0 | |
101 | 0 | // Per spec, we init the parent's members first |
102 | 0 | if (!EventInit::Init(cx, val)) { |
103 | 0 | return false; |
104 | 0 | } |
105 | 0 | |
106 | 0 | bool isNull = val.isNullOrUndefined(); |
107 | 0 | // We only need these if !isNull, in which case we have |cx|. |
108 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
109 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
110 | 0 | if (!isNull) { |
111 | 0 | MOZ_ASSERT(cx); |
112 | 0 | object.emplace(cx, &val.toObject()); |
113 | 0 | temp.emplace(cx); |
114 | 0 | } |
115 | 0 | if (!isNull) { |
116 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->boundingClientRect_id, temp.ptr())) { |
117 | 0 | return false; |
118 | 0 | } |
119 | 0 | } |
120 | 0 | if (!isNull && !temp->isUndefined()) { |
121 | 0 | if (temp.ref().isObject()) { |
122 | 0 | static_assert(IsRefcounted<mozilla::dom::DOMRectReadOnly>::value, "We can only store refcounted classes.");{ |
123 | 0 | nsresult rv = UnwrapObject<prototypes::id::DOMRectReadOnly, mozilla::dom::DOMRectReadOnly>(temp.ptr(), mBoundingClientRect); |
124 | 0 | if (NS_FAILED(rv)) { |
125 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'boundingClientRect' member of CaretStateChangedEventInit", "DOMRectReadOnly"); |
126 | 0 | return false; |
127 | 0 | } |
128 | 0 | } |
129 | 0 | } else if (temp.ref().isNullOrUndefined()) { |
130 | 0 | mBoundingClientRect = nullptr; |
131 | 0 | } else { |
132 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'boundingClientRect' member of CaretStateChangedEventInit"); |
133 | 0 | return false; |
134 | 0 | } |
135 | 0 | } else { |
136 | 0 | mBoundingClientRect = nullptr; |
137 | 0 | } |
138 | 0 | mIsAnyMemberPresent = true; |
139 | 0 |
|
140 | 0 | if (!isNull) { |
141 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->caretVisible_id, temp.ptr())) { |
142 | 0 | return false; |
143 | 0 | } |
144 | 0 | } |
145 | 0 | if (!isNull && !temp->isUndefined()) { |
146 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mCaretVisible)) { |
147 | 0 | return false; |
148 | 0 | } |
149 | 0 | } else { |
150 | 0 | mCaretVisible = false; |
151 | 0 | } |
152 | 0 | mIsAnyMemberPresent = true; |
153 | 0 |
|
154 | 0 | if (!isNull) { |
155 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->caretVisuallyVisible_id, temp.ptr())) { |
156 | 0 | return false; |
157 | 0 | } |
158 | 0 | } |
159 | 0 | if (!isNull && !temp->isUndefined()) { |
160 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mCaretVisuallyVisible)) { |
161 | 0 | return false; |
162 | 0 | } |
163 | 0 | } else { |
164 | 0 | mCaretVisuallyVisible = false; |
165 | 0 | } |
166 | 0 | mIsAnyMemberPresent = true; |
167 | 0 |
|
168 | 0 | if (!isNull) { |
169 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->collapsed_id, temp.ptr())) { |
170 | 0 | return false; |
171 | 0 | } |
172 | 0 | } |
173 | 0 | if (!isNull && !temp->isUndefined()) { |
174 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mCollapsed)) { |
175 | 0 | return false; |
176 | 0 | } |
177 | 0 | } else { |
178 | 0 | mCollapsed = true; |
179 | 0 | } |
180 | 0 | mIsAnyMemberPresent = true; |
181 | 0 |
|
182 | 0 | if (!isNull) { |
183 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->reason_id, temp.ptr())) { |
184 | 0 | return false; |
185 | 0 | } |
186 | 0 | } |
187 | 0 | if (!isNull && !temp->isUndefined()) { |
188 | 0 | { |
189 | 0 | int index; |
190 | 0 | if (!FindEnumStringIndex<true>(cx, temp.ref(), CaretChangedReasonValues::strings, "CaretChangedReason", "'reason' member of CaretStateChangedEventInit", &index)) { |
191 | 0 | return false; |
192 | 0 | } |
193 | 0 | MOZ_ASSERT(index >= 0); |
194 | 0 | mReason = static_cast<CaretChangedReason>(index); |
195 | 0 | } |
196 | 0 | } else { |
197 | 0 | mReason = CaretChangedReason::Visibilitychange; |
198 | 0 | } |
199 | 0 | mIsAnyMemberPresent = true; |
200 | 0 |
|
201 | 0 | if (!isNull) { |
202 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->selectedTextContent_id, temp.ptr())) { |
203 | 0 | return false; |
204 | 0 | } |
205 | 0 | } |
206 | 0 | if (!isNull && !temp->isUndefined()) { |
207 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mSelectedTextContent)) { |
208 | 0 | return false; |
209 | 0 | } |
210 | 0 | } else { |
211 | 0 | static const char16_t data[] = { 0 }; |
212 | 0 | mSelectedTextContent.Rebind(data, ArrayLength(data) - 1); |
213 | 0 | } |
214 | 0 | mIsAnyMemberPresent = true; |
215 | 0 |
|
216 | 0 | if (!isNull) { |
217 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->selectionEditable_id, temp.ptr())) { |
218 | 0 | return false; |
219 | 0 | } |
220 | 0 | } |
221 | 0 | if (!isNull && !temp->isUndefined()) { |
222 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mSelectionEditable)) { |
223 | 0 | return false; |
224 | 0 | } |
225 | 0 | } else { |
226 | 0 | mSelectionEditable = false; |
227 | 0 | } |
228 | 0 | mIsAnyMemberPresent = true; |
229 | 0 |
|
230 | 0 | if (!isNull) { |
231 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->selectionVisible_id, temp.ptr())) { |
232 | 0 | return false; |
233 | 0 | } |
234 | 0 | } |
235 | 0 | if (!isNull && !temp->isUndefined()) { |
236 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mSelectionVisible)) { |
237 | 0 | return false; |
238 | 0 | } |
239 | 0 | } else { |
240 | 0 | mSelectionVisible = false; |
241 | 0 | } |
242 | 0 | mIsAnyMemberPresent = true; |
243 | 0 | return true; |
244 | 0 | } |
245 | | |
246 | | bool |
247 | | CaretStateChangedEventInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
248 | 0 | { |
249 | 0 | CaretStateChangedEventInitAtoms* atomsCache = GetAtomCache<CaretStateChangedEventInitAtoms>(cx); |
250 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
251 | 0 | return false; |
252 | 0 | } |
253 | 0 | |
254 | 0 | // Per spec, we define the parent's members first |
255 | 0 | if (!EventInit::ToObjectInternal(cx, rval)) { |
256 | 0 | return false; |
257 | 0 | } |
258 | 0 | JS::Rooted<JSObject*> obj(cx, &rval.toObject()); |
259 | 0 |
|
260 | 0 | do { |
261 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
262 | 0 | JS::Rooted<JS::Value> temp(cx); |
263 | 0 | RefPtr<mozilla::dom::DOMRectReadOnly> const & currentValue = mBoundingClientRect; |
264 | 0 | if (!currentValue) { |
265 | 0 | temp.setNull(); |
266 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->boundingClientRect_id, temp, JSPROP_ENUMERATE)) { |
267 | 0 | return false; |
268 | 0 | } |
269 | 0 | break; |
270 | 0 | } |
271 | 0 | if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) { |
272 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
273 | 0 | return false; |
274 | 0 | } |
275 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->boundingClientRect_id, temp, JSPROP_ENUMERATE)) { |
276 | 0 | return false; |
277 | 0 | } |
278 | 0 | break; |
279 | 0 | } while(false); |
280 | 0 |
|
281 | 0 | do { |
282 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
283 | 0 | JS::Rooted<JS::Value> temp(cx); |
284 | 0 | bool const & currentValue = mCaretVisible; |
285 | 0 | temp.setBoolean(currentValue); |
286 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->caretVisible_id, temp, JSPROP_ENUMERATE)) { |
287 | 0 | return false; |
288 | 0 | } |
289 | 0 | break; |
290 | 0 | } while(false); |
291 | 0 |
|
292 | 0 | do { |
293 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
294 | 0 | JS::Rooted<JS::Value> temp(cx); |
295 | 0 | bool const & currentValue = mCaretVisuallyVisible; |
296 | 0 | temp.setBoolean(currentValue); |
297 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->caretVisuallyVisible_id, temp, JSPROP_ENUMERATE)) { |
298 | 0 | return false; |
299 | 0 | } |
300 | 0 | break; |
301 | 0 | } while(false); |
302 | 0 |
|
303 | 0 | do { |
304 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
305 | 0 | JS::Rooted<JS::Value> temp(cx); |
306 | 0 | bool const & currentValue = mCollapsed; |
307 | 0 | temp.setBoolean(currentValue); |
308 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->collapsed_id, temp, JSPROP_ENUMERATE)) { |
309 | 0 | return false; |
310 | 0 | } |
311 | 0 | break; |
312 | 0 | } while(false); |
313 | 0 |
|
314 | 0 | do { |
315 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
316 | 0 | JS::Rooted<JS::Value> temp(cx); |
317 | 0 | CaretChangedReason const & currentValue = mReason; |
318 | 0 | if (!ToJSValue(cx, currentValue, &temp)) { |
319 | 0 | return false; |
320 | 0 | } |
321 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->reason_id, temp, JSPROP_ENUMERATE)) { |
322 | 0 | return false; |
323 | 0 | } |
324 | 0 | break; |
325 | 0 | } while(false); |
326 | 0 |
|
327 | 0 | do { |
328 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
329 | 0 | JS::Rooted<JS::Value> temp(cx); |
330 | 0 | nsString const & currentValue = mSelectedTextContent; |
331 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
332 | 0 | return false; |
333 | 0 | } |
334 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->selectedTextContent_id, temp, JSPROP_ENUMERATE)) { |
335 | 0 | return false; |
336 | 0 | } |
337 | 0 | break; |
338 | 0 | } while(false); |
339 | 0 |
|
340 | 0 | do { |
341 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
342 | 0 | JS::Rooted<JS::Value> temp(cx); |
343 | 0 | bool const & currentValue = mSelectionEditable; |
344 | 0 | temp.setBoolean(currentValue); |
345 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->selectionEditable_id, temp, JSPROP_ENUMERATE)) { |
346 | 0 | return false; |
347 | 0 | } |
348 | 0 | break; |
349 | 0 | } while(false); |
350 | 0 |
|
351 | 0 | do { |
352 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
353 | 0 | JS::Rooted<JS::Value> temp(cx); |
354 | 0 | bool const & currentValue = mSelectionVisible; |
355 | 0 | temp.setBoolean(currentValue); |
356 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->selectionVisible_id, temp, JSPROP_ENUMERATE)) { |
357 | 0 | return false; |
358 | 0 | } |
359 | 0 | break; |
360 | 0 | } while(false); |
361 | 0 |
|
362 | 0 | return true; |
363 | 0 | } |
364 | | |
365 | | void |
366 | | CaretStateChangedEventInit::TraceDictionary(JSTracer* trc) |
367 | 0 | { |
368 | 0 | EventInit::TraceDictionary(trc); |
369 | 0 | } |
370 | | |
371 | | |
372 | | |
373 | | CaretStateChangedEventInit& |
374 | | CaretStateChangedEventInit::operator=(const CaretStateChangedEventInit& aOther) |
375 | 0 | { |
376 | 0 | EventInit::operator=(aOther); |
377 | 0 | mBoundingClientRect = aOther.mBoundingClientRect; |
378 | 0 | mCaretVisible = aOther.mCaretVisible; |
379 | 0 | mCaretVisuallyVisible = aOther.mCaretVisuallyVisible; |
380 | 0 | mCollapsed = aOther.mCollapsed; |
381 | 0 | mReason = aOther.mReason; |
382 | 0 | mSelectedTextContent = aOther.mSelectedTextContent; |
383 | 0 | mSelectionEditable = aOther.mSelectionEditable; |
384 | 0 | mSelectionVisible = aOther.mSelectionVisible; |
385 | 0 | return *this; |
386 | 0 | } |
387 | | |
388 | | namespace binding_detail { |
389 | | } // namespace binding_detail |
390 | | |
391 | | |
392 | | namespace CaretStateChangedEvent_Binding { |
393 | | |
394 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<Event_Binding::NativeType>::value, |
395 | | "Can't inherit from an interface with a different ownership model."); |
396 | | |
397 | | MOZ_CAN_RUN_SCRIPT static bool |
398 | | get_collapsed(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CaretStateChangedEvent* self, JSJitGetterCallArgs args) |
399 | 0 | { |
400 | 0 | AUTO_PROFILER_LABEL_FAST("get CaretStateChangedEvent.collapsed", DOM, cx); |
401 | 0 |
|
402 | 0 | bool result(self->Collapsed()); |
403 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
404 | 0 | args.rval().setBoolean(result); |
405 | 0 | return true; |
406 | 0 | } |
407 | | |
408 | | static const JSJitInfo collapsed_getterinfo = { |
409 | | { (JSJitGetterOp)get_collapsed }, |
410 | | { prototypes::id::CaretStateChangedEvent }, |
411 | | { PrototypeTraits<prototypes::id::CaretStateChangedEvent>::Depth }, |
412 | | JSJitInfo::Getter, |
413 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
414 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
415 | | true, /* isInfallible. False in setters. */ |
416 | | false, /* isMovable. Not relevant for setters. */ |
417 | | false, /* isEliminatable. Not relevant for setters. */ |
418 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
419 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
420 | | false, /* isTypedMethod. Only relevant for methods. */ |
421 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
422 | | }; |
423 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
424 | | static_assert(0 < 1, "There is no slot for us"); |
425 | | |
426 | | MOZ_CAN_RUN_SCRIPT static bool |
427 | | get_boundingClientRect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CaretStateChangedEvent* self, JSJitGetterCallArgs args) |
428 | 0 | { |
429 | 0 | AUTO_PROFILER_LABEL_FAST("get CaretStateChangedEvent.boundingClientRect", DOM, cx); |
430 | 0 |
|
431 | 0 | auto result(StrongOrRawPtr<mozilla::dom::DOMRectReadOnly>(self->GetBoundingClientRect())); |
432 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
433 | 0 | if (!result) { |
434 | 0 | args.rval().setNull(); |
435 | 0 | return true; |
436 | 0 | } |
437 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
438 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
439 | 0 | return false; |
440 | 0 | } |
441 | 0 | return true; |
442 | 0 | } |
443 | | |
444 | | static const JSJitInfo boundingClientRect_getterinfo = { |
445 | | { (JSJitGetterOp)get_boundingClientRect }, |
446 | | { prototypes::id::CaretStateChangedEvent }, |
447 | | { PrototypeTraits<prototypes::id::CaretStateChangedEvent>::Depth }, |
448 | | JSJitInfo::Getter, |
449 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
450 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
451 | | false, /* isInfallible. False in setters. */ |
452 | | false, /* isMovable. Not relevant for setters. */ |
453 | | false, /* isEliminatable. Not relevant for setters. */ |
454 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
455 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
456 | | false, /* isTypedMethod. Only relevant for methods. */ |
457 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
458 | | }; |
459 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
460 | | static_assert(0 < 1, "There is no slot for us"); |
461 | | |
462 | | MOZ_CAN_RUN_SCRIPT static bool |
463 | | get_reason(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CaretStateChangedEvent* self, JSJitGetterCallArgs args) |
464 | 0 | { |
465 | 0 | AUTO_PROFILER_LABEL_FAST("get CaretStateChangedEvent.reason", DOM, cx); |
466 | 0 |
|
467 | 0 | CaretChangedReason result(self->Reason()); |
468 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
469 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
470 | 0 | return false; |
471 | 0 | } |
472 | 0 | return true; |
473 | 0 | } |
474 | | |
475 | | static const JSJitInfo reason_getterinfo = { |
476 | | { (JSJitGetterOp)get_reason }, |
477 | | { prototypes::id::CaretStateChangedEvent }, |
478 | | { PrototypeTraits<prototypes::id::CaretStateChangedEvent>::Depth }, |
479 | | JSJitInfo::Getter, |
480 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
481 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
482 | | false, /* isInfallible. False in setters. */ |
483 | | false, /* isMovable. Not relevant for setters. */ |
484 | | false, /* isEliminatable. Not relevant for setters. */ |
485 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
486 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
487 | | false, /* isTypedMethod. Only relevant for methods. */ |
488 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
489 | | }; |
490 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
491 | | static_assert(0 < 1, "There is no slot for us"); |
492 | | |
493 | | MOZ_CAN_RUN_SCRIPT static bool |
494 | | get_caretVisible(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CaretStateChangedEvent* self, JSJitGetterCallArgs args) |
495 | 0 | { |
496 | 0 | AUTO_PROFILER_LABEL_FAST("get CaretStateChangedEvent.caretVisible", DOM, cx); |
497 | 0 |
|
498 | 0 | bool result(self->CaretVisible()); |
499 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
500 | 0 | args.rval().setBoolean(result); |
501 | 0 | return true; |
502 | 0 | } |
503 | | |
504 | | static const JSJitInfo caretVisible_getterinfo = { |
505 | | { (JSJitGetterOp)get_caretVisible }, |
506 | | { prototypes::id::CaretStateChangedEvent }, |
507 | | { PrototypeTraits<prototypes::id::CaretStateChangedEvent>::Depth }, |
508 | | JSJitInfo::Getter, |
509 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
510 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
511 | | true, /* isInfallible. False in setters. */ |
512 | | false, /* isMovable. Not relevant for setters. */ |
513 | | false, /* isEliminatable. Not relevant for setters. */ |
514 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
515 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
516 | | false, /* isTypedMethod. Only relevant for methods. */ |
517 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
518 | | }; |
519 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
520 | | static_assert(0 < 1, "There is no slot for us"); |
521 | | |
522 | | MOZ_CAN_RUN_SCRIPT static bool |
523 | | get_caretVisuallyVisible(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CaretStateChangedEvent* self, JSJitGetterCallArgs args) |
524 | 0 | { |
525 | 0 | AUTO_PROFILER_LABEL_FAST("get CaretStateChangedEvent.caretVisuallyVisible", DOM, cx); |
526 | 0 |
|
527 | 0 | bool result(self->CaretVisuallyVisible()); |
528 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
529 | 0 | args.rval().setBoolean(result); |
530 | 0 | return true; |
531 | 0 | } |
532 | | |
533 | | static const JSJitInfo caretVisuallyVisible_getterinfo = { |
534 | | { (JSJitGetterOp)get_caretVisuallyVisible }, |
535 | | { prototypes::id::CaretStateChangedEvent }, |
536 | | { PrototypeTraits<prototypes::id::CaretStateChangedEvent>::Depth }, |
537 | | JSJitInfo::Getter, |
538 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
539 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
540 | | true, /* isInfallible. False in setters. */ |
541 | | false, /* isMovable. Not relevant for setters. */ |
542 | | false, /* isEliminatable. Not relevant for setters. */ |
543 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
544 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
545 | | false, /* isTypedMethod. Only relevant for methods. */ |
546 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
547 | | }; |
548 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
549 | | static_assert(0 < 1, "There is no slot for us"); |
550 | | |
551 | | MOZ_CAN_RUN_SCRIPT static bool |
552 | | get_selectionVisible(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CaretStateChangedEvent* self, JSJitGetterCallArgs args) |
553 | 0 | { |
554 | 0 | AUTO_PROFILER_LABEL_FAST("get CaretStateChangedEvent.selectionVisible", DOM, cx); |
555 | 0 |
|
556 | 0 | bool result(self->SelectionVisible()); |
557 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
558 | 0 | args.rval().setBoolean(result); |
559 | 0 | return true; |
560 | 0 | } |
561 | | |
562 | | static const JSJitInfo selectionVisible_getterinfo = { |
563 | | { (JSJitGetterOp)get_selectionVisible }, |
564 | | { prototypes::id::CaretStateChangedEvent }, |
565 | | { PrototypeTraits<prototypes::id::CaretStateChangedEvent>::Depth }, |
566 | | JSJitInfo::Getter, |
567 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
568 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
569 | | true, /* isInfallible. False in setters. */ |
570 | | false, /* isMovable. Not relevant for setters. */ |
571 | | false, /* isEliminatable. Not relevant for setters. */ |
572 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
573 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
574 | | false, /* isTypedMethod. Only relevant for methods. */ |
575 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
576 | | }; |
577 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
578 | | static_assert(0 < 1, "There is no slot for us"); |
579 | | |
580 | | MOZ_CAN_RUN_SCRIPT static bool |
581 | | get_selectionEditable(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CaretStateChangedEvent* self, JSJitGetterCallArgs args) |
582 | 0 | { |
583 | 0 | AUTO_PROFILER_LABEL_FAST("get CaretStateChangedEvent.selectionEditable", DOM, cx); |
584 | 0 |
|
585 | 0 | bool result(self->SelectionEditable()); |
586 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
587 | 0 | args.rval().setBoolean(result); |
588 | 0 | return true; |
589 | 0 | } |
590 | | |
591 | | static const JSJitInfo selectionEditable_getterinfo = { |
592 | | { (JSJitGetterOp)get_selectionEditable }, |
593 | | { prototypes::id::CaretStateChangedEvent }, |
594 | | { PrototypeTraits<prototypes::id::CaretStateChangedEvent>::Depth }, |
595 | | JSJitInfo::Getter, |
596 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
597 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
598 | | true, /* isInfallible. False in setters. */ |
599 | | false, /* isMovable. Not relevant for setters. */ |
600 | | false, /* isEliminatable. Not relevant for setters. */ |
601 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
602 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
603 | | false, /* isTypedMethod. Only relevant for methods. */ |
604 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
605 | | }; |
606 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
607 | | static_assert(0 < 1, "There is no slot for us"); |
608 | | |
609 | | MOZ_CAN_RUN_SCRIPT static bool |
610 | | get_selectedTextContent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CaretStateChangedEvent* self, JSJitGetterCallArgs args) |
611 | 0 | { |
612 | 0 | AUTO_PROFILER_LABEL_FAST("get CaretStateChangedEvent.selectedTextContent", DOM, cx); |
613 | 0 |
|
614 | 0 | DOMString result; |
615 | 0 | self->GetSelectedTextContent(result); |
616 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
617 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
618 | 0 | return false; |
619 | 0 | } |
620 | 0 | return true; |
621 | 0 | } |
622 | | |
623 | | static const JSJitInfo selectedTextContent_getterinfo = { |
624 | | { (JSJitGetterOp)get_selectedTextContent }, |
625 | | { prototypes::id::CaretStateChangedEvent }, |
626 | | { PrototypeTraits<prototypes::id::CaretStateChangedEvent>::Depth }, |
627 | | JSJitInfo::Getter, |
628 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
629 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
630 | | false, /* isInfallible. False in setters. */ |
631 | | false, /* isMovable. Not relevant for setters. */ |
632 | | false, /* isEliminatable. Not relevant for setters. */ |
633 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
634 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
635 | | false, /* isTypedMethod. Only relevant for methods. */ |
636 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
637 | | }; |
638 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
639 | | static_assert(0 < 1, "There is no slot for us"); |
640 | | |
641 | | MOZ_CAN_RUN_SCRIPT static bool |
642 | | get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CaretStateChangedEvent* self, JSJitGetterCallArgs args) |
643 | 0 | { |
644 | 0 | AUTO_PROFILER_LABEL_FAST("get CaretStateChangedEvent.isTrusted", DOM, cx); |
645 | 0 |
|
646 | 0 | bool result(self->IsTrusted()); |
647 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
648 | 0 | args.rval().setBoolean(result); |
649 | 0 | return true; |
650 | 0 | } |
651 | | |
652 | | static const JSJitInfo isTrusted_getterinfo = { |
653 | | { (JSJitGetterOp)get_isTrusted }, |
654 | | { prototypes::id::CaretStateChangedEvent }, |
655 | | { PrototypeTraits<prototypes::id::CaretStateChangedEvent>::Depth }, |
656 | | JSJitInfo::Getter, |
657 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
658 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
659 | | true, /* isInfallible. False in setters. */ |
660 | | true, /* isMovable. Not relevant for setters. */ |
661 | | true, /* isEliminatable. Not relevant for setters. */ |
662 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
663 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
664 | | false, /* isTypedMethod. Only relevant for methods. */ |
665 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
666 | | }; |
667 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
668 | | static_assert(0 < 1, "There is no slot for us"); |
669 | | |
670 | | static bool |
671 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
672 | 0 | { |
673 | 0 | mozilla::dom::CaretStateChangedEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CaretStateChangedEvent>(obj); |
674 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
675 | 0 | // obviously can't preserve if we're not initialized. |
676 | 0 | if (self && self->GetWrapperPreserveColor()) { |
677 | 0 | PreserveWrapper(self); |
678 | 0 | } |
679 | 0 | return true; |
680 | 0 | } |
681 | | |
682 | | static void |
683 | | _finalize(js::FreeOp* fop, JSObject* obj) |
684 | 0 | { |
685 | 0 | mozilla::dom::CaretStateChangedEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CaretStateChangedEvent>(obj); |
686 | 0 | if (self) { |
687 | 0 | ClearWrapper(self, self, obj); |
688 | 0 | AddForDeferredFinalization<mozilla::dom::CaretStateChangedEvent>(self); |
689 | 0 | } |
690 | 0 | } |
691 | | |
692 | | static size_t |
693 | | _objectMoved(JSObject* obj, JSObject* old) |
694 | 0 | { |
695 | 0 | mozilla::dom::CaretStateChangedEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CaretStateChangedEvent>(obj); |
696 | 0 | if (self) { |
697 | 0 | UpdateWrapper(self, self, obj, old); |
698 | 0 | } |
699 | 0 |
|
700 | 0 | return 0; |
701 | 0 | } |
702 | | |
703 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
704 | | #if defined(__clang__) |
705 | | #pragma clang diagnostic push |
706 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
707 | | #endif |
708 | | static const JSPropertySpec sAttributes_specs[] = { |
709 | | { "collapsed", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &collapsed_getterinfo, nullptr, nullptr }, |
710 | | { "boundingClientRect", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &boundingClientRect_getterinfo, nullptr, nullptr }, |
711 | | { "reason", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &reason_getterinfo, nullptr, nullptr }, |
712 | | { "caretVisible", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &caretVisible_getterinfo, nullptr, nullptr }, |
713 | | { "caretVisuallyVisible", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &caretVisuallyVisible_getterinfo, nullptr, nullptr }, |
714 | | { "selectionVisible", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &selectionVisible_getterinfo, nullptr, nullptr }, |
715 | | { "selectionEditable", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &selectionEditable_getterinfo, nullptr, nullptr }, |
716 | | { "selectedTextContent", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &selectedTextContent_getterinfo, nullptr, nullptr }, |
717 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
718 | | }; |
719 | | #if defined(__clang__) |
720 | | #pragma clang diagnostic pop |
721 | | #endif |
722 | | |
723 | | |
724 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
725 | | { nullptr, &sAttributes_specs[0] }, |
726 | | { nullptr, nullptr } |
727 | | }; |
728 | | |
729 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
730 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
731 | | static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
732 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
733 | | |
734 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
735 | | #if defined(__clang__) |
736 | | #pragma clang diagnostic push |
737 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
738 | | #endif |
739 | | static const JSPropertySpec sUnforgeableAttributes_specs[] = { |
740 | | { "isTrusted", JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isTrusted_getterinfo, nullptr, nullptr }, |
741 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
742 | | }; |
743 | | #if defined(__clang__) |
744 | | #pragma clang diagnostic pop |
745 | | #endif |
746 | | |
747 | | |
748 | | static const Prefable<const JSPropertySpec> sUnforgeableAttributes[] = { |
749 | | { nullptr, &sUnforgeableAttributes_specs[0] }, |
750 | | { nullptr, nullptr } |
751 | | }; |
752 | | |
753 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
754 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
755 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
756 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
757 | | |
758 | | |
759 | | static uint16_t sNativeProperties_sortedPropertyIndices[9]; |
760 | | static PropertyInfo sNativeProperties_propertyInfos[9]; |
761 | | |
762 | | static const NativePropertiesN<2> sNativeProperties = { |
763 | | false, 0, |
764 | | false, 0, |
765 | | false, 0, |
766 | | true, 0 /* sAttributes */, |
767 | | false, 0, |
768 | | true, 1 /* sUnforgeableAttributes */, |
769 | | false, 0, |
770 | | -1, |
771 | | 9, |
772 | | sNativeProperties_sortedPropertyIndices, |
773 | | { |
774 | | { sAttributes, &sNativeProperties_propertyInfos[0] }, |
775 | | { sUnforgeableAttributes, &sNativeProperties_propertyInfos[8] } |
776 | | } |
777 | | }; |
778 | | static_assert(9 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
779 | | "We have a property info count that is oversized"); |
780 | | |
781 | | static bool |
782 | | _constructor(JSContext* cx, unsigned argc, JS::Value* vp) |
783 | 0 | { |
784 | 0 | AUTO_PROFILER_LABEL_FAST("CaretStateChangedEvent constructor", DOM, cx); |
785 | 0 |
|
786 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
787 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
788 | 0 | if (!args.isConstructing()) { |
789 | 0 | // XXXbz wish I could get the name from the callee instead of |
790 | 0 | // Adding more relocations |
791 | 0 | return ThrowConstructorWithoutNew(cx, "CaretStateChangedEvent"); |
792 | 0 | } |
793 | 0 | |
794 | 0 | JS::Rooted<JSObject*> desiredProto(cx); |
795 | 0 | if (!GetDesiredProto(cx, args, &desiredProto)) { |
796 | 0 | return false; |
797 | 0 | } |
798 | 0 | |
799 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
800 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CaretStateChangedEvent"); |
801 | 0 | } |
802 | 0 | GlobalObject global(cx, obj); |
803 | 0 | if (global.Failed()) { |
804 | 0 | return false; |
805 | 0 | } |
806 | 0 | |
807 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
808 | 0 | binding_detail::FakeString arg0; |
809 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
810 | 0 | return false; |
811 | 0 | } |
812 | 0 | binding_detail::FastCaretStateChangedEventInit arg1; |
813 | 0 | if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2 of CaretStateChangedEvent.constructor", false)) { |
814 | 0 | return false; |
815 | 0 | } |
816 | 0 | Maybe<JSAutoRealm> ar; |
817 | 0 | if (objIsXray) { |
818 | 0 | obj = js::CheckedUnwrap(obj); |
819 | 0 | if (!obj) { |
820 | 0 | return false; |
821 | 0 | } |
822 | 0 | ar.emplace(cx, obj); |
823 | 0 | if (!JS_WrapObject(cx, &desiredProto)) { |
824 | 0 | return false; |
825 | 0 | } |
826 | 0 | } |
827 | 0 | FastErrorResult rv; |
828 | 0 | auto result(StrongOrRawPtr<mozilla::dom::CaretStateChangedEvent>(mozilla::dom::CaretStateChangedEvent::Constructor(global, NonNullHelper(Constify(arg0)), Constify(arg1), rv))); |
829 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
830 | 0 | return false; |
831 | 0 | } |
832 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
833 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
834 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
835 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) { |
836 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
837 | 0 | return false; |
838 | 0 | } |
839 | 0 | return true; |
840 | 0 | } |
841 | | |
842 | | static const js::ClassOps sInterfaceObjectClassOps = { |
843 | | nullptr, /* addProperty */ |
844 | | nullptr, /* delProperty */ |
845 | | nullptr, /* enumerate */ |
846 | | nullptr, /* newEnumerate */ |
847 | | nullptr, /* resolve */ |
848 | | nullptr, /* mayResolve */ |
849 | | nullptr, /* finalize */ |
850 | | _constructor, /* call */ |
851 | | nullptr, /* hasInstance */ |
852 | | _constructor, /* construct */ |
853 | | nullptr, /* trace */ |
854 | | }; |
855 | | |
856 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
857 | | { |
858 | | "Function", |
859 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
860 | | &sInterfaceObjectClassOps, |
861 | | JS_NULL_CLASS_SPEC, |
862 | | JS_NULL_CLASS_EXT, |
863 | | &sInterfaceObjectClassObjectOps |
864 | | }, |
865 | | eInterface, |
866 | | true, |
867 | | prototypes::id::CaretStateChangedEvent, |
868 | | PrototypeTraits<prototypes::id::CaretStateChangedEvent>::Depth, |
869 | | sNativePropertyHooks, |
870 | | "function CaretStateChangedEvent() {\n [native code]\n}", |
871 | | Event_Binding::GetConstructorObject |
872 | | }; |
873 | | |
874 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
875 | | { |
876 | | "CaretStateChangedEventPrototype", |
877 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */), |
878 | | JS_NULL_CLASS_OPS, |
879 | | JS_NULL_CLASS_SPEC, |
880 | | JS_NULL_CLASS_EXT, |
881 | | JS_NULL_OBJECT_OPS |
882 | | }, |
883 | | eInterfacePrototype, |
884 | | false, |
885 | | prototypes::id::CaretStateChangedEvent, |
886 | | PrototypeTraits<prototypes::id::CaretStateChangedEvent>::Depth, |
887 | | sNativePropertyHooks, |
888 | | "[object CaretStateChangedEventPrototype]", |
889 | | Event_Binding::GetProtoObject |
890 | | }; |
891 | | |
892 | | bool |
893 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
894 | 0 | { |
895 | 0 | return nsContentUtils::ThreadsafeIsSystemCaller(aCx); |
896 | 0 | } |
897 | | |
898 | | static const js::ClassOps sClassOps = { |
899 | | _addProperty, /* addProperty */ |
900 | | nullptr, /* delProperty */ |
901 | | nullptr, /* enumerate */ |
902 | | nullptr, /* newEnumerate */ |
903 | | nullptr, /* resolve */ |
904 | | nullptr, /* mayResolve */ |
905 | | _finalize, /* finalize */ |
906 | | nullptr, /* call */ |
907 | | nullptr, /* hasInstance */ |
908 | | nullptr, /* construct */ |
909 | | nullptr, /* trace */ |
910 | | }; |
911 | | |
912 | | static const js::ClassExtension sClassExtension = { |
913 | | nullptr, /* weakmapKeyDelegateOp */ |
914 | | _objectMoved /* objectMovedOp */ |
915 | | }; |
916 | | |
917 | | static const DOMJSClass sClass = { |
918 | | { "CaretStateChangedEvent", |
919 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE, |
920 | | &sClassOps, |
921 | | JS_NULL_CLASS_SPEC, |
922 | | &sClassExtension, |
923 | | JS_NULL_OBJECT_OPS |
924 | | }, |
925 | | { prototypes::id::Event, prototypes::id::CaretStateChangedEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
926 | | IsBaseOf<nsISupports, mozilla::dom::CaretStateChangedEvent >::value, |
927 | | sNativePropertyHooks, |
928 | | FindAssociatedGlobalForNative<mozilla::dom::CaretStateChangedEvent>::Get, |
929 | | GetProtoObjectHandle, |
930 | | GetCCParticipant<mozilla::dom::CaretStateChangedEvent>::Get() |
931 | | }; |
932 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
933 | | "Must have the right minimal number of reserved slots."); |
934 | | static_assert(1 >= 1, |
935 | | "Must have enough reserved slots."); |
936 | | |
937 | | const JSClass* |
938 | | GetJSClass() |
939 | 0 | { |
940 | 0 | return sClass.ToJSClass(); |
941 | 0 | } |
942 | | |
943 | | bool |
944 | | Wrap(JSContext* aCx, mozilla::dom::CaretStateChangedEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
945 | 0 | { |
946 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::CaretStateChangedEvent>::value, |
947 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
948 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::CaretStateChangedEvent*>(aObject) == |
949 | 0 | reinterpret_cast<mozilla::dom::CaretStateChangedEvent*>(aObject), |
950 | 0 | "Multiple inheritance for mozilla::dom::CaretStateChangedEvent is broken."); |
951 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) == |
952 | 0 | reinterpret_cast<mozilla::dom::Event*>(aObject), |
953 | 0 | "Multiple inheritance for mozilla::dom::Event is broken."); |
954 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
955 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
956 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
957 | 0 | "You should probably not be using Wrap() directly; use " |
958 | 0 | "GetOrCreateDOMReflector instead"); |
959 | 0 |
|
960 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
961 | 0 | "nsISupports must be on our primary inheritance chain"); |
962 | 0 |
|
963 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
964 | 0 | if (!global) { |
965 | 0 | return false; |
966 | 0 | } |
967 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
968 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
969 | 0 |
|
970 | 0 | // That might have ended up wrapping us already, due to the wonders |
971 | 0 | // of XBL. Check for that, and bail out as needed. |
972 | 0 | aReflector.set(aCache->GetWrapper()); |
973 | 0 | if (aReflector) { |
974 | | #ifdef DEBUG |
975 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
976 | | #endif // DEBUG |
977 | | return true; |
978 | 0 | } |
979 | 0 |
|
980 | 0 | JSAutoRealm ar(aCx, global); |
981 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
982 | 0 | if (!canonicalProto) { |
983 | 0 | return false; |
984 | 0 | } |
985 | 0 | JS::Rooted<JSObject*> proto(aCx); |
986 | 0 | if (aGivenProto) { |
987 | 0 | proto = aGivenProto; |
988 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
989 | 0 | // coming in, we changed compartments to that of "parent" so may need |
990 | 0 | // to wrap the proto here. |
991 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
992 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
993 | 0 | return false; |
994 | 0 | } |
995 | 0 | } |
996 | 0 | } else { |
997 | 0 | proto = canonicalProto; |
998 | 0 | } |
999 | 0 |
|
1000 | 0 | BindingJSObjectCreator<mozilla::dom::CaretStateChangedEvent> creator(aCx); |
1001 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
1002 | 0 | if (!aReflector) { |
1003 | 0 | return false; |
1004 | 0 | } |
1005 | 0 | |
1006 | 0 | aCache->SetWrapper(aReflector); |
1007 | 0 |
|
1008 | 0 | // Important: do unforgeable property setup after we have handed |
1009 | 0 | // over ownership of the C++ object to obj as needed, so that if |
1010 | 0 | // we fail and it ends up GCed it won't have problems in the |
1011 | 0 | // finalizer trying to drop its ownership of the C++ object. |
1012 | 0 | JS::Rooted<JSObject*> unforgeableHolder(aCx, |
1013 | 0 | &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject()); |
1014 | 0 | if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) { |
1015 | 0 | aCache->ReleaseWrapper(aObject); |
1016 | 0 | aCache->ClearWrapper(); |
1017 | 0 | return false; |
1018 | 0 | } |
1019 | 0 | creator.InitializationSucceeded(); |
1020 | 0 |
|
1021 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
1022 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
1023 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
1024 | 0 | // otherwise we won't be able to properly recreate it later, since |
1025 | 0 | // we won't know what proto to use. Note that we don't check |
1026 | 0 | // aGivenProto here, since it's entirely possible (and even |
1027 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
1028 | 0 | // same as canonicalProto. |
1029 | 0 | if (proto != canonicalProto) { |
1030 | 0 | PreserveWrapper(aObject); |
1031 | 0 | } |
1032 | 0 |
|
1033 | 0 | return true; |
1034 | 0 | } |
1035 | | |
1036 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
1037 | | nullptr, |
1038 | | nullptr, |
1039 | | nullptr, |
1040 | | { sNativeProperties.Upcast(), nullptr }, |
1041 | | prototypes::id::CaretStateChangedEvent, |
1042 | | constructors::id::CaretStateChangedEvent, |
1043 | | Event_Binding::sNativePropertyHooks, |
1044 | | &DefaultXrayExpandoObjectClass |
1045 | | } }; |
1046 | | |
1047 | | void |
1048 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
1049 | 0 | { |
1050 | 0 | JS::Handle<JSObject*> parentProto(Event_Binding::GetProtoObjectHandle(aCx)); |
1051 | 0 | if (!parentProto) { |
1052 | 0 | return; |
1053 | 0 | } |
1054 | 0 | |
1055 | 0 | JS::Handle<JSObject*> constructorProto(Event_Binding::GetConstructorObjectHandle(aCx)); |
1056 | 0 | if (!constructorProto) { |
1057 | 0 | return; |
1058 | 0 | } |
1059 | 0 | |
1060 | 0 | static bool sIdsInited = false; |
1061 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
1062 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
1063 | 0 | return; |
1064 | 0 | } |
1065 | 0 | sIdsInited = true; |
1066 | 0 | } |
1067 | 0 |
|
1068 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::CaretStateChangedEvent); |
1069 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::CaretStateChangedEvent); |
1070 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
1071 | 0 | &sPrototypeClass.mBase, protoCache, |
1072 | 0 | nullptr, |
1073 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr, |
1074 | 0 | interfaceCache, |
1075 | 0 | sNativeProperties.Upcast(), |
1076 | 0 | nullptr, |
1077 | 0 | "CaretStateChangedEvent", aDefineOnGlobal, |
1078 | 0 | nullptr, |
1079 | 0 | false); |
1080 | 0 |
|
1081 | 0 | JS::Rooted<JSObject*> unforgeableHolder(aCx); |
1082 | 0 | { |
1083 | 0 | JS::Rooted<JSObject*> holderProto(aCx, *protoCache); |
1084 | 0 | unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto); |
1085 | 0 | if (!unforgeableHolder) { |
1086 | 0 | *protoCache = nullptr; |
1087 | 0 | if (interfaceCache) { |
1088 | 0 | *interfaceCache = nullptr; |
1089 | 0 | } |
1090 | 0 | return; |
1091 | 0 | } |
1092 | 0 | } |
1093 | 0 |
|
1094 | 0 | if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) { |
1095 | 0 | *protoCache = nullptr; |
1096 | 0 | if (interfaceCache) { |
1097 | 0 | *interfaceCache = nullptr; |
1098 | 0 | } |
1099 | 0 | return; |
1100 | 0 | } |
1101 | 0 |
|
1102 | 0 | if (*protoCache) { |
1103 | 0 | js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE, |
1104 | 0 | JS::ObjectValue(*unforgeableHolder)); |
1105 | 0 | } |
1106 | 0 | } |
1107 | | |
1108 | | JSObject* |
1109 | | GetConstructorObject(JSContext* aCx) |
1110 | 0 | { |
1111 | 0 | return GetConstructorObjectHandle(aCx); |
1112 | 0 | } |
1113 | | |
1114 | | } // namespace CaretStateChangedEvent_Binding |
1115 | | |
1116 | | |
1117 | | |
1118 | | } // namespace dom |
1119 | | } // namespace mozilla |