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