Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM Selection.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "SelectionBinding.h"
4 : #include "WrapperFactory.h"
5 : #include "mozilla/OwningNonNull.h"
6 : #include "mozilla/Preferences.h"
7 : #include "mozilla/dom/BindingUtils.h"
8 : #include "mozilla/dom/CustomElementRegistry.h"
9 : #include "mozilla/dom/DOMJSClass.h"
10 : #include "mozilla/dom/NonRefcountedDOMObject.h"
11 : #include "mozilla/dom/Nullable.h"
12 : #include "mozilla/dom/PrimitiveConversions.h"
13 : #include "mozilla/dom/Selection.h"
14 : #include "mozilla/dom/XrayExpandoClass.h"
15 : #include "nsContentUtils.h"
16 : #include "nsINode.h"
17 : #include "nsISelectionListener.h"
18 : #include "nsISupports.h"
19 : #include "nsRange.h"
20 : #include "xpcjsid.h"
21 :
22 : namespace mozilla {
23 : namespace dom {
24 :
25 : namespace SelectionBinding {
26 :
27 : static bool
28 0 : get_anchorNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, JSJitGetterCallArgs args)
29 : {
30 0 : auto result(StrongOrRawPtr<nsINode>(self->GetAnchorNode()));
31 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
32 0 : if (!result) {
33 0 : args.rval().setNull();
34 0 : return true;
35 : }
36 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
37 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
38 0 : return false;
39 : }
40 0 : return true;
41 : }
42 :
43 : static const JSJitInfo anchorNode_getterinfo = {
44 : { (JSJitGetterOp)get_anchorNode },
45 : { prototypes::id::Selection },
46 : { PrototypeTraits<prototypes::id::Selection>::Depth },
47 : JSJitInfo::Getter,
48 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
49 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
50 : false, /* isInfallible. False in setters. */
51 : false, /* isMovable. Not relevant for setters. */
52 : false, /* isEliminatable. Not relevant for setters. */
53 : false, /* isAlwaysInSlot. Only relevant for getters. */
54 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
55 : false, /* isTypedMethod. Only relevant for methods. */
56 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
57 : };
58 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
59 : static_assert(0 < 1, "There is no slot for us");
60 :
61 : static bool
62 0 : get_anchorOffset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, JSJitGetterCallArgs args)
63 : {
64 0 : uint32_t result(self->AnchorOffset());
65 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
66 0 : args.rval().setNumber(result);
67 0 : return true;
68 : }
69 :
70 : static const JSJitInfo anchorOffset_getterinfo = {
71 : { (JSJitGetterOp)get_anchorOffset },
72 : { prototypes::id::Selection },
73 : { PrototypeTraits<prototypes::id::Selection>::Depth },
74 : JSJitInfo::Getter,
75 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
76 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
77 : true, /* isInfallible. False in setters. */
78 : false, /* isMovable. Not relevant for setters. */
79 : false, /* isEliminatable. Not relevant for setters. */
80 : false, /* isAlwaysInSlot. Only relevant for getters. */
81 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
82 : false, /* isTypedMethod. Only relevant for methods. */
83 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
84 : };
85 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
86 : static_assert(0 < 1, "There is no slot for us");
87 :
88 : static bool
89 0 : get_focusNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, JSJitGetterCallArgs args)
90 : {
91 0 : auto result(StrongOrRawPtr<nsINode>(self->GetFocusNode()));
92 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
93 0 : if (!result) {
94 0 : args.rval().setNull();
95 0 : return true;
96 : }
97 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
98 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
99 0 : return false;
100 : }
101 0 : return true;
102 : }
103 :
104 : static const JSJitInfo focusNode_getterinfo = {
105 : { (JSJitGetterOp)get_focusNode },
106 : { prototypes::id::Selection },
107 : { PrototypeTraits<prototypes::id::Selection>::Depth },
108 : JSJitInfo::Getter,
109 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
110 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
111 : false, /* isInfallible. False in setters. */
112 : false, /* isMovable. Not relevant for setters. */
113 : false, /* isEliminatable. Not relevant for setters. */
114 : false, /* isAlwaysInSlot. Only relevant for getters. */
115 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
116 : false, /* isTypedMethod. Only relevant for methods. */
117 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
118 : };
119 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
120 : static_assert(0 < 1, "There is no slot for us");
121 :
122 : static bool
123 0 : get_focusOffset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, JSJitGetterCallArgs args)
124 : {
125 0 : uint32_t result(self->FocusOffset());
126 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
127 0 : args.rval().setNumber(result);
128 0 : return true;
129 : }
130 :
131 : static const JSJitInfo focusOffset_getterinfo = {
132 : { (JSJitGetterOp)get_focusOffset },
133 : { prototypes::id::Selection },
134 : { PrototypeTraits<prototypes::id::Selection>::Depth },
135 : JSJitInfo::Getter,
136 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
137 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
138 : true, /* isInfallible. False in setters. */
139 : false, /* isMovable. Not relevant for setters. */
140 : false, /* isEliminatable. Not relevant for setters. */
141 : false, /* isAlwaysInSlot. Only relevant for getters. */
142 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
143 : false, /* isTypedMethod. Only relevant for methods. */
144 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
145 : };
146 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
147 : static_assert(0 < 1, "There is no slot for us");
148 :
149 : static bool
150 0 : get_isCollapsed(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, JSJitGetterCallArgs args)
151 : {
152 0 : bool result(self->IsCollapsed());
153 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
154 0 : args.rval().setBoolean(result);
155 0 : return true;
156 : }
157 :
158 : static const JSJitInfo isCollapsed_getterinfo = {
159 : { (JSJitGetterOp)get_isCollapsed },
160 : { prototypes::id::Selection },
161 : { PrototypeTraits<prototypes::id::Selection>::Depth },
162 : JSJitInfo::Getter,
163 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
164 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
165 : true, /* isInfallible. False in setters. */
166 : false, /* isMovable. Not relevant for setters. */
167 : false, /* isEliminatable. Not relevant for setters. */
168 : false, /* isAlwaysInSlot. Only relevant for getters. */
169 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
170 : false, /* isTypedMethod. Only relevant for methods. */
171 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
172 : };
173 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
174 : static_assert(0 < 1, "There is no slot for us");
175 :
176 : static bool
177 0 : get_rangeCount(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, JSJitGetterCallArgs args)
178 : {
179 0 : uint32_t result(self->RangeCount());
180 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
181 0 : args.rval().setNumber(result);
182 0 : return true;
183 : }
184 :
185 : static const JSJitInfo rangeCount_getterinfo = {
186 : { (JSJitGetterOp)get_rangeCount },
187 : { prototypes::id::Selection },
188 : { PrototypeTraits<prototypes::id::Selection>::Depth },
189 : JSJitInfo::Getter,
190 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
191 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
192 : true, /* isInfallible. False in setters. */
193 : false, /* isMovable. Not relevant for setters. */
194 : false, /* isEliminatable. Not relevant for setters. */
195 : false, /* isAlwaysInSlot. Only relevant for getters. */
196 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
197 : false, /* isTypedMethod. Only relevant for methods. */
198 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
199 : };
200 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
201 : static_assert(0 < 1, "There is no slot for us");
202 :
203 : static bool
204 0 : getRangeAt(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
205 : {
206 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
207 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Selection.getRangeAt");
208 : }
209 : uint32_t arg0;
210 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
211 0 : return false;
212 : }
213 0 : binding_detail::FastErrorResult rv;
214 0 : auto result(StrongOrRawPtr<nsRange>(self->GetRangeAt(arg0, rv)));
215 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
216 0 : return false;
217 : }
218 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
219 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
220 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
221 0 : return false;
222 : }
223 0 : return true;
224 : }
225 :
226 : static const JSJitInfo getRangeAt_methodinfo = {
227 : { (JSJitGetterOp)getRangeAt },
228 : { prototypes::id::Selection },
229 : { PrototypeTraits<prototypes::id::Selection>::Depth },
230 : JSJitInfo::Method,
231 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
232 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
233 : false, /* isInfallible. False in setters. */
234 : false, /* isMovable. Not relevant for setters. */
235 : false, /* isEliminatable. Not relevant for setters. */
236 : false, /* isAlwaysInSlot. Only relevant for getters. */
237 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
238 : false, /* isTypedMethod. Only relevant for methods. */
239 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
240 : };
241 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
242 : static_assert(0 < 1, "There is no slot for us");
243 :
244 : static bool
245 2 : addRange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
246 : {
247 2 : if (MOZ_UNLIKELY(args.length() < 1)) {
248 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Selection.addRange");
249 : }
250 2 : NonNull<nsRange> arg0;
251 2 : if (args[0].isObject()) {
252 : {
253 2 : nsresult rv = UnwrapObject<prototypes::id::Range, nsRange>(args[0], arg0);
254 2 : if (NS_FAILED(rv)) {
255 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Selection.addRange", "Range");
256 0 : return false;
257 : }
258 : }
259 : } else {
260 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Selection.addRange");
261 0 : return false;
262 : }
263 4 : binding_detail::FastErrorResult rv;
264 2 : self->AddRangeJS(NonNullHelper(arg0), rv);
265 2 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
266 0 : return false;
267 : }
268 2 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
269 2 : args.rval().setUndefined();
270 2 : return true;
271 : }
272 :
273 : static const JSJitInfo addRange_methodinfo = {
274 : { (JSJitGetterOp)addRange },
275 : { prototypes::id::Selection },
276 : { PrototypeTraits<prototypes::id::Selection>::Depth },
277 : JSJitInfo::Method,
278 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
279 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
280 : false, /* isInfallible. False in setters. */
281 : false, /* isMovable. Not relevant for setters. */
282 : false, /* isEliminatable. Not relevant for setters. */
283 : false, /* isAlwaysInSlot. Only relevant for getters. */
284 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
285 : false, /* isTypedMethod. Only relevant for methods. */
286 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
287 : };
288 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
289 : static_assert(0 < 1, "There is no slot for us");
290 :
291 : static bool
292 0 : removeRange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
293 : {
294 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
295 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Selection.removeRange");
296 : }
297 0 : NonNull<nsRange> arg0;
298 0 : if (args[0].isObject()) {
299 : {
300 0 : nsresult rv = UnwrapObject<prototypes::id::Range, nsRange>(args[0], arg0);
301 0 : if (NS_FAILED(rv)) {
302 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Selection.removeRange", "Range");
303 0 : return false;
304 : }
305 : }
306 : } else {
307 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Selection.removeRange");
308 0 : return false;
309 : }
310 0 : binding_detail::FastErrorResult rv;
311 0 : self->RemoveRange(NonNullHelper(arg0), rv);
312 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
313 0 : return false;
314 : }
315 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
316 0 : args.rval().setUndefined();
317 0 : return true;
318 : }
319 :
320 : static const JSJitInfo removeRange_methodinfo = {
321 : { (JSJitGetterOp)removeRange },
322 : { prototypes::id::Selection },
323 : { PrototypeTraits<prototypes::id::Selection>::Depth },
324 : JSJitInfo::Method,
325 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
326 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
327 : false, /* isInfallible. False in setters. */
328 : false, /* isMovable. Not relevant for setters. */
329 : false, /* isEliminatable. Not relevant for setters. */
330 : false, /* isAlwaysInSlot. Only relevant for getters. */
331 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
332 : false, /* isTypedMethod. Only relevant for methods. */
333 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
334 : };
335 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
336 : static_assert(0 < 1, "There is no slot for us");
337 :
338 : static bool
339 6 : removeAllRanges(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
340 : {
341 12 : binding_detail::FastErrorResult rv;
342 6 : self->RemoveAllRanges(rv);
343 6 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
344 0 : return false;
345 : }
346 6 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
347 6 : args.rval().setUndefined();
348 6 : return true;
349 : }
350 :
351 : static const JSJitInfo removeAllRanges_methodinfo = {
352 : { (JSJitGetterOp)removeAllRanges },
353 : { prototypes::id::Selection },
354 : { PrototypeTraits<prototypes::id::Selection>::Depth },
355 : JSJitInfo::Method,
356 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
357 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
358 : false, /* isInfallible. False in setters. */
359 : false, /* isMovable. Not relevant for setters. */
360 : false, /* isEliminatable. Not relevant for setters. */
361 : false, /* isAlwaysInSlot. Only relevant for getters. */
362 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
363 : false, /* isTypedMethod. Only relevant for methods. */
364 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
365 : };
366 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
367 : static_assert(0 < 1, "There is no slot for us");
368 :
369 : static bool
370 0 : empty(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
371 : {
372 0 : binding_detail::FastErrorResult rv;
373 0 : self->RemoveAllRanges(rv);
374 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
375 0 : return false;
376 : }
377 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
378 0 : args.rval().setUndefined();
379 0 : return true;
380 : }
381 :
382 : static const JSJitInfo empty_methodinfo = {
383 : { (JSJitGetterOp)empty },
384 : { prototypes::id::Selection },
385 : { PrototypeTraits<prototypes::id::Selection>::Depth },
386 : JSJitInfo::Method,
387 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
388 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
389 : false, /* isInfallible. False in setters. */
390 : false, /* isMovable. Not relevant for setters. */
391 : false, /* isEliminatable. Not relevant for setters. */
392 : false, /* isAlwaysInSlot. Only relevant for getters. */
393 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
394 : false, /* isTypedMethod. Only relevant for methods. */
395 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
396 : };
397 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
398 : static_assert(0 < 1, "There is no slot for us");
399 :
400 : static bool
401 0 : collapse(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
402 : {
403 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
404 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Selection.collapse");
405 : }
406 : nsINode* arg0;
407 0 : if (args[0].isObject()) {
408 : {
409 0 : nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0);
410 0 : if (NS_FAILED(rv)) {
411 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Selection.collapse", "Node");
412 0 : return false;
413 : }
414 : }
415 0 : } else if (args[0].isNullOrUndefined()) {
416 0 : arg0 = nullptr;
417 : } else {
418 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Selection.collapse");
419 0 : return false;
420 : }
421 : uint32_t arg1;
422 0 : if (args.hasDefined(1)) {
423 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
424 0 : return false;
425 : }
426 : } else {
427 0 : arg1 = 0U;
428 : }
429 0 : binding_detail::FastErrorResult rv;
430 0 : self->CollapseJS(Constify(arg0), arg1, rv);
431 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
432 0 : return false;
433 : }
434 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
435 0 : args.rval().setUndefined();
436 0 : return true;
437 : }
438 :
439 : static const JSJitInfo collapse_methodinfo = {
440 : { (JSJitGetterOp)collapse },
441 : { prototypes::id::Selection },
442 : { PrototypeTraits<prototypes::id::Selection>::Depth },
443 : JSJitInfo::Method,
444 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
445 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
446 : false, /* isInfallible. False in setters. */
447 : false, /* isMovable. Not relevant for setters. */
448 : false, /* isEliminatable. Not relevant for setters. */
449 : false, /* isAlwaysInSlot. Only relevant for getters. */
450 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
451 : false, /* isTypedMethod. Only relevant for methods. */
452 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
453 : };
454 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
455 : static_assert(0 < 1, "There is no slot for us");
456 :
457 : static bool
458 0 : setPosition(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
459 : {
460 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
461 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Selection.setPosition");
462 : }
463 : nsINode* arg0;
464 0 : if (args[0].isObject()) {
465 : {
466 0 : nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0);
467 0 : if (NS_FAILED(rv)) {
468 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Selection.setPosition", "Node");
469 0 : return false;
470 : }
471 : }
472 0 : } else if (args[0].isNullOrUndefined()) {
473 0 : arg0 = nullptr;
474 : } else {
475 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Selection.setPosition");
476 0 : return false;
477 : }
478 : uint32_t arg1;
479 0 : if (args.hasDefined(1)) {
480 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
481 0 : return false;
482 : }
483 : } else {
484 0 : arg1 = 0U;
485 : }
486 0 : binding_detail::FastErrorResult rv;
487 0 : self->CollapseJS(Constify(arg0), arg1, rv);
488 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
489 0 : return false;
490 : }
491 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
492 0 : args.rval().setUndefined();
493 0 : return true;
494 : }
495 :
496 : static const JSJitInfo setPosition_methodinfo = {
497 : { (JSJitGetterOp)setPosition },
498 : { prototypes::id::Selection },
499 : { PrototypeTraits<prototypes::id::Selection>::Depth },
500 : JSJitInfo::Method,
501 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
502 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
503 : false, /* isInfallible. False in setters. */
504 : false, /* isMovable. Not relevant for setters. */
505 : false, /* isEliminatable. Not relevant for setters. */
506 : false, /* isAlwaysInSlot. Only relevant for getters. */
507 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
508 : false, /* isTypedMethod. Only relevant for methods. */
509 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
510 : };
511 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
512 : static_assert(0 < 1, "There is no slot for us");
513 :
514 : static bool
515 0 : collapseToStart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
516 : {
517 0 : binding_detail::FastErrorResult rv;
518 0 : self->CollapseToStartJS(rv);
519 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
520 0 : return false;
521 : }
522 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
523 0 : args.rval().setUndefined();
524 0 : return true;
525 : }
526 :
527 : static const JSJitInfo collapseToStart_methodinfo = {
528 : { (JSJitGetterOp)collapseToStart },
529 : { prototypes::id::Selection },
530 : { PrototypeTraits<prototypes::id::Selection>::Depth },
531 : JSJitInfo::Method,
532 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
533 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
534 : false, /* isInfallible. False in setters. */
535 : false, /* isMovable. Not relevant for setters. */
536 : false, /* isEliminatable. Not relevant for setters. */
537 : false, /* isAlwaysInSlot. Only relevant for getters. */
538 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
539 : false, /* isTypedMethod. Only relevant for methods. */
540 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
541 : };
542 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
543 : static_assert(0 < 1, "There is no slot for us");
544 :
545 : static bool
546 0 : collapseToEnd(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
547 : {
548 0 : binding_detail::FastErrorResult rv;
549 0 : self->CollapseToEndJS(rv);
550 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
551 0 : return false;
552 : }
553 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
554 0 : args.rval().setUndefined();
555 0 : return true;
556 : }
557 :
558 : static const JSJitInfo collapseToEnd_methodinfo = {
559 : { (JSJitGetterOp)collapseToEnd },
560 : { prototypes::id::Selection },
561 : { PrototypeTraits<prototypes::id::Selection>::Depth },
562 : JSJitInfo::Method,
563 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
564 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
565 : false, /* isInfallible. False in setters. */
566 : false, /* isMovable. Not relevant for setters. */
567 : false, /* isEliminatable. Not relevant for setters. */
568 : false, /* isAlwaysInSlot. Only relevant for getters. */
569 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
570 : false, /* isTypedMethod. Only relevant for methods. */
571 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
572 : };
573 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
574 : static_assert(0 < 1, "There is no slot for us");
575 :
576 : static bool
577 0 : extend(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
578 : {
579 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
580 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Selection.extend");
581 : }
582 0 : NonNull<nsINode> arg0;
583 0 : if (args[0].isObject()) {
584 : {
585 0 : nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0);
586 0 : if (NS_FAILED(rv)) {
587 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Selection.extend", "Node");
588 0 : return false;
589 : }
590 : }
591 : } else {
592 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Selection.extend");
593 0 : return false;
594 : }
595 : uint32_t arg1;
596 0 : if (args.hasDefined(1)) {
597 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
598 0 : return false;
599 : }
600 : } else {
601 0 : arg1 = 0U;
602 : }
603 0 : binding_detail::FastErrorResult rv;
604 0 : self->ExtendJS(NonNullHelper(arg0), arg1, rv);
605 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
606 0 : return false;
607 : }
608 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
609 0 : args.rval().setUndefined();
610 0 : return true;
611 : }
612 :
613 : static const JSJitInfo extend_methodinfo = {
614 : { (JSJitGetterOp)extend },
615 : { prototypes::id::Selection },
616 : { PrototypeTraits<prototypes::id::Selection>::Depth },
617 : JSJitInfo::Method,
618 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
619 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
620 : false, /* isInfallible. False in setters. */
621 : false, /* isMovable. Not relevant for setters. */
622 : false, /* isEliminatable. Not relevant for setters. */
623 : false, /* isAlwaysInSlot. Only relevant for getters. */
624 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
625 : false, /* isTypedMethod. Only relevant for methods. */
626 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
627 : };
628 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
629 : static_assert(0 < 1, "There is no slot for us");
630 :
631 : static bool
632 0 : setBaseAndExtent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
633 : {
634 0 : if (MOZ_UNLIKELY(args.length() < 4)) {
635 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Selection.setBaseAndExtent");
636 : }
637 0 : NonNull<nsINode> arg0;
638 0 : if (args[0].isObject()) {
639 : {
640 0 : nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0);
641 0 : if (NS_FAILED(rv)) {
642 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Selection.setBaseAndExtent", "Node");
643 0 : return false;
644 : }
645 : }
646 : } else {
647 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Selection.setBaseAndExtent");
648 0 : return false;
649 : }
650 : uint32_t arg1;
651 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
652 0 : return false;
653 : }
654 0 : NonNull<nsINode> arg2;
655 0 : if (args[2].isObject()) {
656 : {
657 0 : nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[2], arg2);
658 0 : if (NS_FAILED(rv)) {
659 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 3 of Selection.setBaseAndExtent", "Node");
660 0 : return false;
661 : }
662 : }
663 : } else {
664 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 3 of Selection.setBaseAndExtent");
665 0 : return false;
666 : }
667 : uint32_t arg3;
668 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[3], &arg3)) {
669 0 : return false;
670 : }
671 0 : binding_detail::FastErrorResult rv;
672 0 : self->SetBaseAndExtentJS(NonNullHelper(arg0), arg1, NonNullHelper(arg2), arg3, rv);
673 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
674 0 : return false;
675 : }
676 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
677 0 : args.rval().setUndefined();
678 0 : return true;
679 : }
680 :
681 : static const JSJitInfo setBaseAndExtent_methodinfo = {
682 : { (JSJitGetterOp)setBaseAndExtent },
683 : { prototypes::id::Selection },
684 : { PrototypeTraits<prototypes::id::Selection>::Depth },
685 : JSJitInfo::Method,
686 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
687 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
688 : false, /* isInfallible. False in setters. */
689 : false, /* isMovable. Not relevant for setters. */
690 : false, /* isEliminatable. Not relevant for setters. */
691 : false, /* isAlwaysInSlot. Only relevant for getters. */
692 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
693 : false, /* isTypedMethod. Only relevant for methods. */
694 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
695 : };
696 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
697 : static_assert(0 < 1, "There is no slot for us");
698 :
699 : static bool
700 0 : selectAllChildren(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
701 : {
702 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
703 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Selection.selectAllChildren");
704 : }
705 0 : NonNull<nsINode> arg0;
706 0 : if (args[0].isObject()) {
707 : {
708 0 : nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0);
709 0 : if (NS_FAILED(rv)) {
710 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Selection.selectAllChildren", "Node");
711 0 : return false;
712 : }
713 : }
714 : } else {
715 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Selection.selectAllChildren");
716 0 : return false;
717 : }
718 0 : binding_detail::FastErrorResult rv;
719 0 : self->SelectAllChildrenJS(NonNullHelper(arg0), rv);
720 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
721 0 : return false;
722 : }
723 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
724 0 : args.rval().setUndefined();
725 0 : return true;
726 : }
727 :
728 : static const JSJitInfo selectAllChildren_methodinfo = {
729 : { (JSJitGetterOp)selectAllChildren },
730 : { prototypes::id::Selection },
731 : { PrototypeTraits<prototypes::id::Selection>::Depth },
732 : JSJitInfo::Method,
733 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
734 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
735 : false, /* isInfallible. False in setters. */
736 : false, /* isMovable. Not relevant for setters. */
737 : false, /* isEliminatable. Not relevant for setters. */
738 : false, /* isAlwaysInSlot. Only relevant for getters. */
739 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
740 : false, /* isTypedMethod. Only relevant for methods. */
741 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
742 : };
743 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
744 : static_assert(0 < 1, "There is no slot for us");
745 :
746 : static bool
747 0 : deleteFromDocument(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
748 : {
749 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
750 0 : Maybe<AutoCEReaction> ceReaction;
751 0 : if (reactionsStack) {
752 0 : ceReaction.emplace(reactionsStack);
753 : }
754 0 : binding_detail::FastErrorResult rv;
755 0 : self->DeleteFromDocument(rv);
756 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
757 0 : return false;
758 : }
759 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
760 0 : args.rval().setUndefined();
761 0 : return true;
762 : }
763 :
764 : static const JSJitInfo deleteFromDocument_methodinfo = {
765 : { (JSJitGetterOp)deleteFromDocument },
766 : { prototypes::id::Selection },
767 : { PrototypeTraits<prototypes::id::Selection>::Depth },
768 : JSJitInfo::Method,
769 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
770 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
771 : false, /* isInfallible. False in setters. */
772 : false, /* isMovable. Not relevant for setters. */
773 : false, /* isEliminatable. Not relevant for setters. */
774 : false, /* isAlwaysInSlot. Only relevant for getters. */
775 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
776 : false, /* isTypedMethod. Only relevant for methods. */
777 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
778 : };
779 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
780 : static_assert(0 < 1, "There is no slot for us");
781 :
782 : static bool
783 0 : containsNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
784 : {
785 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
786 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Selection.containsNode");
787 : }
788 0 : NonNull<nsINode> arg0;
789 0 : if (args[0].isObject()) {
790 : {
791 0 : nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0);
792 0 : if (NS_FAILED(rv)) {
793 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Selection.containsNode", "Node");
794 0 : return false;
795 : }
796 : }
797 : } else {
798 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Selection.containsNode");
799 0 : return false;
800 : }
801 : bool arg1;
802 0 : if (args.hasDefined(1)) {
803 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
804 0 : return false;
805 : }
806 : } else {
807 0 : arg1 = false;
808 : }
809 0 : binding_detail::FastErrorResult rv;
810 0 : bool result(self->ContainsNode(NonNullHelper(arg0), arg1, rv));
811 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
812 0 : return false;
813 : }
814 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
815 0 : args.rval().setBoolean(result);
816 0 : return true;
817 : }
818 :
819 : static const JSJitInfo containsNode_methodinfo = {
820 : { (JSJitGetterOp)containsNode },
821 : { prototypes::id::Selection },
822 : { PrototypeTraits<prototypes::id::Selection>::Depth },
823 : JSJitInfo::Method,
824 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
825 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
826 : false, /* isInfallible. False in setters. */
827 : false, /* isMovable. Not relevant for setters. */
828 : false, /* isEliminatable. Not relevant for setters. */
829 : false, /* isAlwaysInSlot. Only relevant for getters. */
830 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
831 : false, /* isTypedMethod. Only relevant for methods. */
832 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
833 : };
834 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
835 : static_assert(0 < 1, "There is no slot for us");
836 :
837 : static bool
838 0 : __stringifier(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
839 : {
840 0 : DOMString result;
841 0 : self->Stringify(result);
842 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
843 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
844 0 : return false;
845 : }
846 0 : return true;
847 : }
848 :
849 : static const JSJitInfo __stringifier_methodinfo = {
850 : { (JSJitGetterOp)__stringifier },
851 : { prototypes::id::Selection },
852 : { PrototypeTraits<prototypes::id::Selection>::Depth },
853 : JSJitInfo::Method,
854 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
855 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
856 : false, /* isInfallible. False in setters. */
857 : false, /* isMovable. Not relevant for setters. */
858 : false, /* isEliminatable. Not relevant for setters. */
859 : false, /* isAlwaysInSlot. Only relevant for getters. */
860 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
861 : false, /* isTypedMethod. Only relevant for methods. */
862 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
863 : };
864 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
865 : static_assert(0 < 1, "There is no slot for us");
866 :
867 : static bool
868 0 : modify(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
869 : {
870 0 : if (MOZ_UNLIKELY(args.length() < 3)) {
871 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Selection.modify");
872 : }
873 0 : binding_detail::FakeString arg0;
874 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
875 0 : return false;
876 : }
877 0 : binding_detail::FakeString arg1;
878 0 : if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
879 0 : return false;
880 : }
881 0 : binding_detail::FakeString arg2;
882 0 : if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2)) {
883 0 : return false;
884 : }
885 0 : binding_detail::FastErrorResult rv;
886 0 : self->Modify(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), NonNullHelper(Constify(arg2)), rv);
887 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
888 0 : return false;
889 : }
890 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
891 0 : args.rval().setUndefined();
892 0 : return true;
893 : }
894 :
895 : static const JSJitInfo modify_methodinfo = {
896 : { (JSJitGetterOp)modify },
897 : { prototypes::id::Selection },
898 : { PrototypeTraits<prototypes::id::Selection>::Depth },
899 : JSJitInfo::Method,
900 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
901 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
902 : false, /* isInfallible. False in setters. */
903 : false, /* isMovable. Not relevant for setters. */
904 : false, /* isEliminatable. Not relevant for setters. */
905 : false, /* isAlwaysInSlot. Only relevant for getters. */
906 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
907 : false, /* isTypedMethod. Only relevant for methods. */
908 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
909 : };
910 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
911 : static_assert(0 < 1, "There is no slot for us");
912 :
913 : static bool
914 0 : get_interlinePosition(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, JSJitGetterCallArgs args)
915 : {
916 0 : binding_detail::FastErrorResult rv;
917 0 : bool result(self->GetInterlinePosition(rv));
918 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
919 0 : return false;
920 : }
921 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
922 0 : args.rval().setBoolean(result);
923 0 : return true;
924 : }
925 :
926 : static bool
927 0 : set_interlinePosition(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, JSJitSetterCallArgs args)
928 : {
929 : bool arg0;
930 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
931 0 : return false;
932 : }
933 0 : binding_detail::FastErrorResult rv;
934 0 : self->SetInterlinePosition(arg0, rv);
935 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
936 0 : return false;
937 : }
938 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
939 :
940 0 : return true;
941 : }
942 :
943 : static const JSJitInfo interlinePosition_getterinfo = {
944 : { (JSJitGetterOp)get_interlinePosition },
945 : { prototypes::id::Selection },
946 : { PrototypeTraits<prototypes::id::Selection>::Depth },
947 : JSJitInfo::Getter,
948 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
949 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
950 : false, /* isInfallible. False in setters. */
951 : false, /* isMovable. Not relevant for setters. */
952 : false, /* isEliminatable. Not relevant for setters. */
953 : false, /* isAlwaysInSlot. Only relevant for getters. */
954 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
955 : false, /* isTypedMethod. Only relevant for methods. */
956 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
957 : };
958 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
959 : static_assert(0 < 1, "There is no slot for us");
960 : static const JSJitInfo interlinePosition_setterinfo = {
961 : { (JSJitGetterOp)set_interlinePosition },
962 : { prototypes::id::Selection },
963 : { PrototypeTraits<prototypes::id::Selection>::Depth },
964 : JSJitInfo::Setter,
965 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
966 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
967 : false, /* isInfallible. False in setters. */
968 : false, /* isMovable. Not relevant for setters. */
969 : false, /* isEliminatable. Not relevant for setters. */
970 : false, /* isAlwaysInSlot. Only relevant for getters. */
971 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
972 : false, /* isTypedMethod. Only relevant for methods. */
973 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
974 : };
975 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
976 : static_assert(0 < 1, "There is no slot for us");
977 :
978 : static bool
979 0 : get_caretBidiLevel(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, JSJitGetterCallArgs args)
980 : {
981 0 : binding_detail::FastErrorResult rv;
982 0 : Nullable<int16_t> result(self->GetCaretBidiLevel(rv));
983 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
984 0 : return false;
985 : }
986 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
987 0 : if (result.IsNull()) {
988 0 : args.rval().setNull();
989 0 : return true;
990 : }
991 0 : args.rval().setInt32(int32_t(result.Value()));
992 0 : return true;
993 : }
994 :
995 : static bool
996 0 : set_caretBidiLevel(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, JSJitSetterCallArgs args)
997 : {
998 0 : Nullable<int16_t> arg0;
999 0 : if (args[0].isNullOrUndefined()) {
1000 0 : arg0.SetNull();
1001 0 : } else if (!ValueToPrimitive<int16_t, eDefault>(cx, args[0], &arg0.SetValue())) {
1002 0 : return false;
1003 : }
1004 0 : binding_detail::FastErrorResult rv;
1005 0 : self->SetCaretBidiLevel(Constify(arg0), rv);
1006 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1007 0 : return false;
1008 : }
1009 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1010 :
1011 0 : return true;
1012 : }
1013 :
1014 : static const JSJitInfo caretBidiLevel_getterinfo = {
1015 : { (JSJitGetterOp)get_caretBidiLevel },
1016 : { prototypes::id::Selection },
1017 : { PrototypeTraits<prototypes::id::Selection>::Depth },
1018 : JSJitInfo::Getter,
1019 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1020 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
1021 : false, /* isInfallible. False in setters. */
1022 : false, /* isMovable. Not relevant for setters. */
1023 : false, /* isEliminatable. Not relevant for setters. */
1024 : false, /* isAlwaysInSlot. Only relevant for getters. */
1025 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1026 : false, /* isTypedMethod. Only relevant for methods. */
1027 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1028 : };
1029 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1030 : static_assert(0 < 1, "There is no slot for us");
1031 : static const JSJitInfo caretBidiLevel_setterinfo = {
1032 : { (JSJitGetterOp)set_caretBidiLevel },
1033 : { prototypes::id::Selection },
1034 : { PrototypeTraits<prototypes::id::Selection>::Depth },
1035 : JSJitInfo::Setter,
1036 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1037 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1038 : false, /* isInfallible. False in setters. */
1039 : false, /* isMovable. Not relevant for setters. */
1040 : false, /* isEliminatable. Not relevant for setters. */
1041 : false, /* isAlwaysInSlot. Only relevant for getters. */
1042 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1043 : false, /* isTypedMethod. Only relevant for methods. */
1044 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1045 : };
1046 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1047 : static_assert(0 < 1, "There is no slot for us");
1048 :
1049 : static bool
1050 0 : toStringWithFormat(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
1051 : {
1052 0 : if (MOZ_UNLIKELY(args.length() < 3)) {
1053 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Selection.toStringWithFormat");
1054 : }
1055 0 : binding_detail::FakeString arg0;
1056 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1057 0 : return false;
1058 : }
1059 : uint32_t arg1;
1060 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
1061 0 : return false;
1062 : }
1063 : int32_t arg2;
1064 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) {
1065 0 : return false;
1066 : }
1067 0 : binding_detail::FastErrorResult rv;
1068 0 : DOMString result;
1069 0 : self->ToStringWithFormat(NonNullHelper(Constify(arg0)), arg1, arg2, result, rv);
1070 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1071 0 : return false;
1072 : }
1073 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1074 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1075 0 : return false;
1076 : }
1077 0 : return true;
1078 : }
1079 :
1080 : static const JSJitInfo toStringWithFormat_methodinfo = {
1081 : { (JSJitGetterOp)toStringWithFormat },
1082 : { prototypes::id::Selection },
1083 : { PrototypeTraits<prototypes::id::Selection>::Depth },
1084 : JSJitInfo::Method,
1085 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1086 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
1087 : false, /* isInfallible. False in setters. */
1088 : false, /* isMovable. Not relevant for setters. */
1089 : false, /* isEliminatable. Not relevant for setters. */
1090 : false, /* isAlwaysInSlot. Only relevant for getters. */
1091 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1092 : false, /* isTypedMethod. Only relevant for methods. */
1093 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1094 : };
1095 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1096 : static_assert(0 < 1, "There is no slot for us");
1097 :
1098 : static bool
1099 0 : addSelectionListener(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
1100 : {
1101 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
1102 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Selection.addSelectionListener");
1103 : }
1104 : nsISelectionListener* arg0;
1105 0 : RefPtr<nsISelectionListener> arg0_holder;
1106 0 : if (args[0].isObject()) {
1107 0 : JS::Rooted<JSObject*> source(cx, &args[0].toObject());
1108 0 : if (NS_FAILED(UnwrapArg<nsISelectionListener>(cx, source, getter_AddRefs(arg0_holder)))) {
1109 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Selection.addSelectionListener", "nsISelectionListener");
1110 0 : return false;
1111 : }
1112 0 : MOZ_ASSERT(arg0_holder);
1113 0 : arg0 = arg0_holder;
1114 : } else {
1115 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Selection.addSelectionListener");
1116 0 : return false;
1117 : }
1118 0 : binding_detail::FastErrorResult rv;
1119 0 : self->AddSelectionListener(NonNullHelper(arg0), rv);
1120 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1121 0 : return false;
1122 : }
1123 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1124 0 : args.rval().setUndefined();
1125 0 : return true;
1126 : }
1127 :
1128 : static const JSJitInfo addSelectionListener_methodinfo = {
1129 : { (JSJitGetterOp)addSelectionListener },
1130 : { prototypes::id::Selection },
1131 : { PrototypeTraits<prototypes::id::Selection>::Depth },
1132 : JSJitInfo::Method,
1133 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1134 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1135 : false, /* isInfallible. False in setters. */
1136 : false, /* isMovable. Not relevant for setters. */
1137 : false, /* isEliminatable. Not relevant for setters. */
1138 : false, /* isAlwaysInSlot. Only relevant for getters. */
1139 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1140 : false, /* isTypedMethod. Only relevant for methods. */
1141 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1142 : };
1143 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1144 : static_assert(0 < 1, "There is no slot for us");
1145 :
1146 : static bool
1147 0 : removeSelectionListener(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
1148 : {
1149 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
1150 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Selection.removeSelectionListener");
1151 : }
1152 : nsISelectionListener* arg0;
1153 0 : RefPtr<nsISelectionListener> arg0_holder;
1154 0 : if (args[0].isObject()) {
1155 0 : JS::Rooted<JSObject*> source(cx, &args[0].toObject());
1156 0 : if (NS_FAILED(UnwrapArg<nsISelectionListener>(cx, source, getter_AddRefs(arg0_holder)))) {
1157 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Selection.removeSelectionListener", "nsISelectionListener");
1158 0 : return false;
1159 : }
1160 0 : MOZ_ASSERT(arg0_holder);
1161 0 : arg0 = arg0_holder;
1162 : } else {
1163 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Selection.removeSelectionListener");
1164 0 : return false;
1165 : }
1166 0 : binding_detail::FastErrorResult rv;
1167 0 : self->RemoveSelectionListener(NonNullHelper(arg0), rv);
1168 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1169 0 : return false;
1170 : }
1171 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1172 0 : args.rval().setUndefined();
1173 0 : return true;
1174 : }
1175 :
1176 : static const JSJitInfo removeSelectionListener_methodinfo = {
1177 : { (JSJitGetterOp)removeSelectionListener },
1178 : { prototypes::id::Selection },
1179 : { PrototypeTraits<prototypes::id::Selection>::Depth },
1180 : JSJitInfo::Method,
1181 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1182 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1183 : false, /* isInfallible. False in setters. */
1184 : false, /* isMovable. Not relevant for setters. */
1185 : false, /* isEliminatable. Not relevant for setters. */
1186 : false, /* isAlwaysInSlot. Only relevant for getters. */
1187 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1188 : false, /* isTypedMethod. Only relevant for methods. */
1189 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1190 : };
1191 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1192 : static_assert(0 < 1, "There is no slot for us");
1193 :
1194 : static bool
1195 0 : get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, JSJitGetterCallArgs args)
1196 : {
1197 0 : int16_t result(self->RawType());
1198 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1199 0 : args.rval().setInt32(int32_t(result));
1200 0 : return true;
1201 : }
1202 :
1203 : static const JSJitInfo type_getterinfo = {
1204 : { (JSJitGetterOp)get_type },
1205 : { prototypes::id::Selection },
1206 : { PrototypeTraits<prototypes::id::Selection>::Depth },
1207 : JSJitInfo::Getter,
1208 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1209 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
1210 : true, /* isInfallible. False in setters. */
1211 : false, /* isMovable. Not relevant for setters. */
1212 : false, /* isEliminatable. Not relevant for setters. */
1213 : false, /* isAlwaysInSlot. Only relevant for getters. */
1214 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1215 : false, /* isTypedMethod. Only relevant for methods. */
1216 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1217 : };
1218 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1219 : static_assert(0 < 1, "There is no slot for us");
1220 :
1221 : static bool
1222 0 : GetRangesForInterval(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
1223 : {
1224 0 : if (MOZ_UNLIKELY(args.length() < 5)) {
1225 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Selection.GetRangesForInterval");
1226 : }
1227 0 : NonNull<nsINode> arg0;
1228 0 : if (args[0].isObject()) {
1229 : {
1230 0 : nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0);
1231 0 : if (NS_FAILED(rv)) {
1232 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Selection.GetRangesForInterval", "Node");
1233 0 : return false;
1234 : }
1235 : }
1236 : } else {
1237 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Selection.GetRangesForInterval");
1238 0 : return false;
1239 : }
1240 : int32_t arg1;
1241 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) {
1242 0 : return false;
1243 : }
1244 0 : NonNull<nsINode> arg2;
1245 0 : if (args[2].isObject()) {
1246 : {
1247 0 : nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[2], arg2);
1248 0 : if (NS_FAILED(rv)) {
1249 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 3 of Selection.GetRangesForInterval", "Node");
1250 0 : return false;
1251 : }
1252 : }
1253 : } else {
1254 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 3 of Selection.GetRangesForInterval");
1255 0 : return false;
1256 : }
1257 : int32_t arg3;
1258 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[3], &arg3)) {
1259 0 : return false;
1260 : }
1261 : bool arg4;
1262 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[4], &arg4)) {
1263 0 : return false;
1264 : }
1265 0 : binding_detail::FastErrorResult rv;
1266 0 : nsTArray<StrongPtrForMember<nsRange>::Type> result;
1267 0 : self->GetRangesForInterval(NonNullHelper(arg0), arg1, NonNullHelper(arg2), arg3, arg4, result, rv);
1268 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1269 0 : return false;
1270 : }
1271 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1272 :
1273 0 : uint32_t length = result.Length();
1274 0 : JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
1275 0 : if (!returnArray) {
1276 0 : return false;
1277 : }
1278 : // Scope for 'tmp'
1279 : {
1280 0 : JS::Rooted<JS::Value> tmp(cx);
1281 0 : for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
1282 : // Control block to let us common up the JS_DefineElement calls when there
1283 : // are different ways to succeed at wrapping the object.
1284 : do {
1285 0 : if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) {
1286 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1287 0 : return false;
1288 : }
1289 0 : break;
1290 : } while (0);
1291 0 : if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
1292 : JSPROP_ENUMERATE)) {
1293 0 : return false;
1294 : }
1295 : }
1296 : }
1297 0 : args.rval().setObject(*returnArray);
1298 0 : return true;
1299 : }
1300 :
1301 : static const JSJitInfo GetRangesForInterval_methodinfo = {
1302 : { (JSJitGetterOp)GetRangesForInterval },
1303 : { prototypes::id::Selection },
1304 : { PrototypeTraits<prototypes::id::Selection>::Depth },
1305 : JSJitInfo::Method,
1306 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1307 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
1308 : false, /* isInfallible. False in setters. */
1309 : false, /* isMovable. Not relevant for setters. */
1310 : false, /* isEliminatable. Not relevant for setters. */
1311 : false, /* isAlwaysInSlot. Only relevant for getters. */
1312 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1313 : false, /* isTypedMethod. Only relevant for methods. */
1314 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1315 : };
1316 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1317 : static_assert(0 < 1, "There is no slot for us");
1318 :
1319 : static bool
1320 0 : scrollIntoView(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
1321 : {
1322 0 : if (MOZ_UNLIKELY(args.length() < 4)) {
1323 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Selection.scrollIntoView");
1324 : }
1325 : int16_t arg0;
1326 0 : if (!ValueToPrimitive<int16_t, eDefault>(cx, args[0], &arg0)) {
1327 0 : return false;
1328 : }
1329 : bool arg1;
1330 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
1331 0 : return false;
1332 : }
1333 : int16_t arg2;
1334 0 : if (!ValueToPrimitive<int16_t, eDefault>(cx, args[2], &arg2)) {
1335 0 : return false;
1336 : }
1337 : int16_t arg3;
1338 0 : if (!ValueToPrimitive<int16_t, eDefault>(cx, args[3], &arg3)) {
1339 0 : return false;
1340 : }
1341 0 : binding_detail::FastErrorResult rv;
1342 0 : self->ScrollIntoView(arg0, arg1, arg2, arg3, rv);
1343 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1344 0 : return false;
1345 : }
1346 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1347 0 : args.rval().setUndefined();
1348 0 : return true;
1349 : }
1350 :
1351 : static const JSJitInfo scrollIntoView_methodinfo = {
1352 : { (JSJitGetterOp)scrollIntoView },
1353 : { prototypes::id::Selection },
1354 : { PrototypeTraits<prototypes::id::Selection>::Depth },
1355 : JSJitInfo::Method,
1356 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1357 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1358 : false, /* isInfallible. False in setters. */
1359 : false, /* isMovable. Not relevant for setters. */
1360 : false, /* isEliminatable. Not relevant for setters. */
1361 : false, /* isAlwaysInSlot. Only relevant for getters. */
1362 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1363 : false, /* isTypedMethod. Only relevant for methods. */
1364 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1365 : };
1366 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1367 : static_assert(0 < 1, "There is no slot for us");
1368 :
1369 : static bool
1370 0 : setColors(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
1371 : {
1372 0 : if (MOZ_UNLIKELY(args.length() < 4)) {
1373 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Selection.setColors");
1374 : }
1375 0 : binding_detail::FakeString arg0;
1376 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1377 0 : return false;
1378 : }
1379 0 : binding_detail::FakeString arg1;
1380 0 : if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
1381 0 : return false;
1382 : }
1383 0 : binding_detail::FakeString arg2;
1384 0 : if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2)) {
1385 0 : return false;
1386 : }
1387 0 : binding_detail::FakeString arg3;
1388 0 : if (!ConvertJSValueToString(cx, args[3], eStringify, eStringify, arg3)) {
1389 0 : return false;
1390 : }
1391 0 : binding_detail::FastErrorResult rv;
1392 0 : self->SetColors(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), NonNullHelper(Constify(arg2)), NonNullHelper(Constify(arg3)), rv);
1393 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1394 0 : return false;
1395 : }
1396 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1397 0 : args.rval().setUndefined();
1398 0 : return true;
1399 : }
1400 :
1401 : static const JSJitInfo setColors_methodinfo = {
1402 : { (JSJitGetterOp)setColors },
1403 : { prototypes::id::Selection },
1404 : { PrototypeTraits<prototypes::id::Selection>::Depth },
1405 : JSJitInfo::Method,
1406 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1407 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1408 : false, /* isInfallible. False in setters. */
1409 : false, /* isMovable. Not relevant for setters. */
1410 : false, /* isEliminatable. Not relevant for setters. */
1411 : false, /* isAlwaysInSlot. Only relevant for getters. */
1412 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1413 : false, /* isTypedMethod. Only relevant for methods. */
1414 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1415 : };
1416 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1417 : static_assert(0 < 1, "There is no slot for us");
1418 :
1419 : static bool
1420 0 : resetColors(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Selection* self, const JSJitMethodCallArgs& args)
1421 : {
1422 0 : binding_detail::FastErrorResult rv;
1423 0 : self->ResetColors(rv);
1424 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1425 0 : return false;
1426 : }
1427 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1428 0 : args.rval().setUndefined();
1429 0 : return true;
1430 : }
1431 :
1432 : static const JSJitInfo resetColors_methodinfo = {
1433 : { (JSJitGetterOp)resetColors },
1434 : { prototypes::id::Selection },
1435 : { PrototypeTraits<prototypes::id::Selection>::Depth },
1436 : JSJitInfo::Method,
1437 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1438 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1439 : false, /* isInfallible. False in setters. */
1440 : false, /* isMovable. Not relevant for setters. */
1441 : false, /* isEliminatable. Not relevant for setters. */
1442 : false, /* isAlwaysInSlot. Only relevant for getters. */
1443 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1444 : false, /* isTypedMethod. Only relevant for methods. */
1445 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1446 : };
1447 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1448 : static_assert(0 < 1, "There is no slot for us");
1449 :
1450 : static bool
1451 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1452 : {
1453 0 : mozilla::dom::Selection* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Selection>(obj);
1454 : // We don't want to preserve if we don't have a wrapper, and we
1455 : // obviously can't preserve if we're not initialized.
1456 0 : if (self && self->GetWrapperPreserveColor()) {
1457 0 : PreserveWrapper(self);
1458 : }
1459 0 : return true;
1460 : }
1461 :
1462 : static void
1463 0 : _finalize(js::FreeOp* fop, JSObject* obj)
1464 : {
1465 0 : mozilla::dom::Selection* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Selection>(obj);
1466 0 : if (self) {
1467 0 : ClearWrapper(self, self, obj);
1468 0 : AddForDeferredFinalization<mozilla::dom::Selection>(self);
1469 : }
1470 0 : }
1471 :
1472 : static void
1473 0 : _objectMoved(JSObject* obj, const JSObject* old)
1474 : {
1475 0 : mozilla::dom::Selection* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Selection>(obj);
1476 0 : if (self) {
1477 0 : UpdateWrapper(self, self, obj, old);
1478 : }
1479 0 : }
1480 :
1481 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1482 : #if defined(__clang__)
1483 : #pragma clang diagnostic push
1484 : #pragma clang diagnostic ignored "-Wmissing-braces"
1485 : #endif
1486 : static const JSFunctionSpec sMethods_specs[] = {
1487 : JS_FNSPEC("getRangeAt", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getRangeAt_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1488 : JS_FNSPEC("addRange", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&addRange_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1489 : JS_FNSPEC("removeRange", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&removeRange_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1490 : JS_FNSPEC("removeAllRanges", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&removeAllRanges_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1491 : JS_FNSPEC("empty", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&empty_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1492 : JS_FNSPEC("collapse", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&collapse_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1493 : JS_FNSPEC("setPosition", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&setPosition_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1494 : JS_FNSPEC("collapseToStart", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&collapseToStart_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1495 : JS_FNSPEC("collapseToEnd", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&collapseToEnd_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1496 : JS_FNSPEC("extend", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&extend_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1497 : JS_FNSPEC("setBaseAndExtent", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&setBaseAndExtent_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
1498 : JS_FNSPEC("selectAllChildren", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&selectAllChildren_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1499 : JS_FNSPEC("deleteFromDocument", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&deleteFromDocument_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1500 : JS_FNSPEC("containsNode", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&containsNode_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1501 : JS_FNSPEC("modify", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&modify_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
1502 : JS_FS_END,
1503 : JS_FNSPEC("QueryInterface", QueryInterface, nullptr, 1, 0, nullptr),
1504 : JS_FS_END,
1505 : JS_FNSPEC("toString", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&__stringifier_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1506 : JS_FS_END
1507 : };
1508 : #if defined(__clang__)
1509 : #pragma clang diagnostic pop
1510 : #endif
1511 :
1512 : static PrefableDisablers sMethods_disablers16 = {
1513 : true, false, 0, &WantsQueryInterface<mozilla::dom::Selection>::Enabled
1514 : };
1515 :
1516 : // Can't be const because the pref-enabled boolean needs to be writable
1517 : static Prefable<const JSFunctionSpec> sMethods[] = {
1518 : { nullptr, &sMethods_specs[0] },
1519 : { &sMethods_disablers16, &sMethods_specs[16] },
1520 : { nullptr, &sMethods_specs[18] },
1521 : { nullptr, nullptr }
1522 : };
1523 :
1524 : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1525 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1526 : static_assert(15 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1527 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1528 :
1529 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1530 : #if defined(__clang__)
1531 : #pragma clang diagnostic push
1532 : #pragma clang diagnostic ignored "-Wmissing-braces"
1533 : #endif
1534 : static const JSFunctionSpec sChromeMethods_specs[] = {
1535 : JS_FNSPEC("toStringWithFormat", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&toStringWithFormat_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
1536 : JS_FNSPEC("addSelectionListener", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&addSelectionListener_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1537 : JS_FNSPEC("removeSelectionListener", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&removeSelectionListener_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1538 : JS_FS_END,
1539 : JS_FNSPEC("GetRangesForInterval", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&GetRangesForInterval_methodinfo), 5, JSPROP_ENUMERATE, nullptr),
1540 : JS_FS_END,
1541 : JS_FNSPEC("scrollIntoView", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&scrollIntoView_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
1542 : JS_FNSPEC("setColors", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&setColors_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
1543 : JS_FNSPEC("resetColors", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&resetColors_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1544 : JS_FS_END
1545 : };
1546 : #if defined(__clang__)
1547 : #pragma clang diagnostic pop
1548 : #endif
1549 :
1550 : static PrefableDisablers sChromeMethods_disablers4 = {
1551 : true, false, 0, nullptr
1552 : };
1553 :
1554 : // Can't be const because the pref-enabled boolean needs to be writable
1555 : static Prefable<const JSFunctionSpec> sChromeMethods[] = {
1556 : { nullptr, &sChromeMethods_specs[0] },
1557 : { &sChromeMethods_disablers4, &sChromeMethods_specs[4] },
1558 : { nullptr, &sChromeMethods_specs[6] },
1559 : { nullptr, nullptr }
1560 : };
1561 :
1562 : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1563 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1564 : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1565 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1566 :
1567 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1568 : #if defined(__clang__)
1569 : #pragma clang diagnostic push
1570 : #pragma clang diagnostic ignored "-Wmissing-braces"
1571 : #endif
1572 : static const JSPropertySpec sAttributes_specs[] = {
1573 : { "anchorNode", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &anchorNode_getterinfo, nullptr, nullptr },
1574 : { "anchorOffset", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &anchorOffset_getterinfo, nullptr, nullptr },
1575 : { "focusNode", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &focusNode_getterinfo, nullptr, nullptr },
1576 : { "focusOffset", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &focusOffset_getterinfo, nullptr, nullptr },
1577 : { "isCollapsed", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &isCollapsed_getterinfo, nullptr, nullptr },
1578 : { "rangeCount", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &rangeCount_getterinfo, nullptr, nullptr },
1579 : { "caretBidiLevel", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &caretBidiLevel_getterinfo, GenericBindingSetter, &caretBidiLevel_setterinfo },
1580 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1581 : };
1582 : #if defined(__clang__)
1583 : #pragma clang diagnostic pop
1584 : #endif
1585 :
1586 :
1587 : // Can't be const because the pref-enabled boolean needs to be writable
1588 : static Prefable<const JSPropertySpec> sAttributes[] = {
1589 : { nullptr, &sAttributes_specs[0] },
1590 : { nullptr, nullptr }
1591 : };
1592 :
1593 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1594 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1595 : static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1596 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1597 :
1598 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1599 : #if defined(__clang__)
1600 : #pragma clang diagnostic push
1601 : #pragma clang diagnostic ignored "-Wmissing-braces"
1602 : #endif
1603 : static const JSPropertySpec sChromeAttributes_specs[] = {
1604 : { "interlinePosition", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &interlinePosition_getterinfo, GenericBindingSetter, &interlinePosition_setterinfo },
1605 : { "type", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &type_getterinfo, nullptr, nullptr },
1606 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1607 : };
1608 : #if defined(__clang__)
1609 : #pragma clang diagnostic pop
1610 : #endif
1611 :
1612 :
1613 : // Can't be const because the pref-enabled boolean needs to be writable
1614 : static Prefable<const JSPropertySpec> sChromeAttributes[] = {
1615 : { nullptr, &sChromeAttributes_specs[0] },
1616 : { nullptr, nullptr }
1617 : };
1618 :
1619 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1620 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1621 : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1622 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1623 :
1624 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1625 : #if defined(__clang__)
1626 : #pragma clang diagnostic push
1627 : #pragma clang diagnostic ignored "-Wmissing-braces"
1628 : #endif
1629 : static const ConstantSpec sChromeConstants_specs[] = {
1630 : { "ENDOFPRECEDINGLINE", JS::Int32Value(0) },
1631 : { "STARTOFNEXTLINE", JS::Int32Value(1) },
1632 : { 0, JS::UndefinedValue() }
1633 : };
1634 : #if defined(__clang__)
1635 : #pragma clang diagnostic pop
1636 : #endif
1637 :
1638 :
1639 : // Can't be const because the pref-enabled boolean needs to be writable
1640 : static Prefable<const ConstantSpec> sChromeConstants[] = {
1641 : { nullptr, &sChromeConstants_specs[0] },
1642 : { nullptr, nullptr }
1643 : };
1644 :
1645 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1646 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1647 : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1648 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1649 :
1650 :
1651 : static uint16_t sNativeProperties_sortedPropertyIndices[24];
1652 : static PropertyInfo sNativeProperties_propertyInfos[24];
1653 :
1654 : static const NativePropertiesN<2> sNativeProperties = {
1655 : false, 0,
1656 : false, 0,
1657 : true, 0 /* sMethods */,
1658 : true, 1 /* sAttributes */,
1659 : false, 0,
1660 : false, 0,
1661 : false, 0,
1662 : -1,
1663 : 24,
1664 : sNativeProperties_sortedPropertyIndices,
1665 : {
1666 : { sMethods, &sNativeProperties_propertyInfos[0] },
1667 : { sAttributes, &sNativeProperties_propertyInfos[17] }
1668 : }
1669 : };
1670 : static_assert(24 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1671 : "We have a property info count that is oversized");
1672 :
1673 : static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[11];
1674 : static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[11];
1675 :
1676 : static const NativePropertiesN<3> sChromeOnlyNativeProperties = {
1677 : false, 0,
1678 : false, 0,
1679 : true, 0 /* sChromeMethods */,
1680 : true, 1 /* sChromeAttributes */,
1681 : false, 0,
1682 : false, 0,
1683 : true, 2 /* sChromeConstants */,
1684 : -1,
1685 : 11,
1686 : sChromeOnlyNativeProperties_sortedPropertyIndices,
1687 : {
1688 : { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] },
1689 : { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[7] },
1690 : { sChromeConstants, &sChromeOnlyNativeProperties_propertyInfos[9] }
1691 : }
1692 : };
1693 : static_assert(11 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
1694 : "We have a property info count that is oversized");
1695 :
1696 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1697 : {
1698 : "Function",
1699 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1700 : &sBoringInterfaceObjectClassClassOps,
1701 : JS_NULL_CLASS_SPEC,
1702 : JS_NULL_CLASS_EXT,
1703 : &sInterfaceObjectClassObjectOps
1704 : },
1705 : eInterface,
1706 : true,
1707 : prototypes::id::Selection,
1708 : PrototypeTraits<prototypes::id::Selection>::Depth,
1709 : sNativePropertyHooks,
1710 : "function Selection() {\n [native code]\n}",
1711 : JS::GetRealmFunctionPrototype
1712 : };
1713 :
1714 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1715 : {
1716 : "SelectionPrototype",
1717 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1718 : JS_NULL_CLASS_OPS,
1719 : JS_NULL_CLASS_SPEC,
1720 : JS_NULL_CLASS_EXT,
1721 : JS_NULL_OBJECT_OPS
1722 : },
1723 : eInterfacePrototype,
1724 : false,
1725 : prototypes::id::Selection,
1726 : PrototypeTraits<prototypes::id::Selection>::Depth,
1727 : sNativePropertyHooks,
1728 : "[object SelectionPrototype]",
1729 : JS::GetRealmObjectPrototype
1730 : };
1731 :
1732 : JSObject*
1733 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
1734 : {
1735 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
1736 : }
1737 :
1738 : static const js::ClassOps sClassOps = {
1739 : _addProperty, /* addProperty */
1740 : nullptr, /* delProperty */
1741 : nullptr, /* getProperty */
1742 : nullptr, /* setProperty */
1743 : nullptr, /* enumerate */
1744 : nullptr, /* newEnumerate */
1745 : nullptr, /* resolve */
1746 : nullptr, /* mayResolve */
1747 : _finalize, /* finalize */
1748 : nullptr, /* call */
1749 : nullptr, /* hasInstance */
1750 : nullptr, /* construct */
1751 : nullptr, /* trace */
1752 : };
1753 :
1754 : static const js::ClassExtension sClassExtension = {
1755 : nullptr, /* weakmapKeyDelegateOp */
1756 : _objectMoved /* objectMovedOp */
1757 : };
1758 :
1759 : static const DOMJSClass sClass = {
1760 : { "Selection",
1761 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1762 : &sClassOps,
1763 : JS_NULL_CLASS_SPEC,
1764 : &sClassExtension,
1765 : JS_NULL_OBJECT_OPS
1766 : },
1767 : { prototypes::id::Selection, 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 },
1768 : IsBaseOf<nsISupports, mozilla::dom::Selection >::value,
1769 : sNativePropertyHooks,
1770 : FindAssociatedGlobalForNative<mozilla::dom::Selection>::Get,
1771 : GetProtoObjectHandle,
1772 : GetCCParticipant<mozilla::dom::Selection>::Get()
1773 : };
1774 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1775 : "Must have the right minimal number of reserved slots.");
1776 : static_assert(1 >= 1,
1777 : "Must have enough reserved slots.");
1778 :
1779 : const JSClass*
1780 0 : GetJSClass()
1781 : {
1782 0 : return sClass.ToJSClass();
1783 : }
1784 :
1785 : bool
1786 4 : Wrap(JSContext* aCx, mozilla::dom::Selection* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1787 : {
1788 : MOZ_ASSERT(static_cast<mozilla::dom::Selection*>(aObject) ==
1789 : reinterpret_cast<mozilla::dom::Selection*>(aObject),
1790 : "Multiple inheritance for mozilla::dom::Selection is broken.");
1791 4 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1792 4 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1793 4 : MOZ_ASSERT(!aCache->GetWrapper(),
1794 : "You should probably not be using Wrap() directly; use "
1795 : "GetOrCreateDOMReflector instead");
1796 :
1797 4 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1798 : "nsISupports must be on our primary inheritance chain");
1799 :
1800 8 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1801 4 : if (!global) {
1802 0 : return false;
1803 : }
1804 4 : MOZ_ASSERT(JS_IsGlobalObject(global));
1805 4 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
1806 :
1807 : // That might have ended up wrapping us already, due to the wonders
1808 : // of XBL. Check for that, and bail out as needed.
1809 4 : aReflector.set(aCache->GetWrapper());
1810 4 : if (aReflector) {
1811 : #ifdef DEBUG
1812 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1813 : #endif // DEBUG
1814 0 : return true;
1815 : }
1816 :
1817 8 : JSAutoCompartment ac(aCx, global);
1818 4 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1819 4 : if (!canonicalProto) {
1820 0 : return false;
1821 : }
1822 8 : JS::Rooted<JSObject*> proto(aCx);
1823 4 : if (aGivenProto) {
1824 0 : proto = aGivenProto;
1825 : // Unfortunately, while aGivenProto was in the compartment of aCx
1826 : // coming in, we changed compartments to that of "parent" so may need
1827 : // to wrap the proto here.
1828 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1829 0 : if (!JS_WrapObject(aCx, &proto)) {
1830 0 : return false;
1831 : }
1832 : }
1833 : } else {
1834 4 : proto = canonicalProto;
1835 : }
1836 :
1837 8 : BindingJSObjectCreator<mozilla::dom::Selection> creator(aCx);
1838 4 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1839 4 : if (!aReflector) {
1840 0 : return false;
1841 : }
1842 :
1843 4 : aCache->SetWrapper(aReflector);
1844 4 : creator.InitializationSucceeded();
1845 :
1846 4 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1847 : aCache->GetWrapperPreserveColor() == aReflector);
1848 : // If proto != canonicalProto, we have to preserve our wrapper;
1849 : // otherwise we won't be able to properly recreate it later, since
1850 : // we won't know what proto to use. Note that we don't check
1851 : // aGivenProto here, since it's entirely possible (and even
1852 : // somewhat common) to have a non-null aGivenProto which is the
1853 : // same as canonicalProto.
1854 4 : if (proto != canonicalProto) {
1855 0 : PreserveWrapper(aObject);
1856 : }
1857 :
1858 4 : return true;
1859 : }
1860 :
1861 : const NativePropertyHooks sNativePropertyHooks[] = { {
1862 : nullptr,
1863 : nullptr,
1864 : nullptr,
1865 : { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
1866 : prototypes::id::Selection,
1867 : constructors::id::Selection,
1868 : nullptr,
1869 : &DefaultXrayExpandoObjectClass
1870 : } };
1871 :
1872 : void
1873 1 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1874 : {
1875 2 : JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
1876 1 : if (!parentProto) {
1877 0 : return;
1878 : }
1879 :
1880 2 : JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
1881 1 : if (!constructorProto) {
1882 0 : return;
1883 : }
1884 :
1885 : static bool sIdsInited = false;
1886 1 : if (!sIdsInited && NS_IsMainThread()) {
1887 1 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
1888 0 : return;
1889 : }
1890 1 : if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
1891 0 : return;
1892 : }
1893 1 : sIdsInited = true;
1894 : }
1895 :
1896 : static bool sPrefCachesInited = false;
1897 1 : if (!sPrefCachesInited && NS_IsMainThread()) {
1898 1 : sPrefCachesInited = true;
1899 1 : Preferences::AddBoolVarCache(&sChromeMethods[1].disablers->enabled, "dom.testing.selection.GetRangesForInterval");
1900 : }
1901 :
1902 1 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::Selection);
1903 1 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::Selection);
1904 3 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1905 : &sPrototypeClass.mBase, protoCache,
1906 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1907 : interfaceCache,
1908 : sNativeProperties.Upcast(),
1909 1 : nsContentUtils::ThreadsafeIsSystemCaller(aCx) ? sChromeOnlyNativeProperties.Upcast() : nullptr,
1910 : "Selection", aDefineOnGlobal,
1911 : nullptr,
1912 1 : false);
1913 : }
1914 :
1915 : JS::Handle<JSObject*>
1916 4 : GetProtoObjectHandle(JSContext* aCx)
1917 : {
1918 : /* Get the interface prototype object for this class. This will create the
1919 : object as needed. */
1920 4 : bool aDefineOnGlobal = true;
1921 :
1922 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1923 4 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1924 4 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1925 0 : return nullptr;
1926 : }
1927 :
1928 : /* Check to see whether the interface objects are already installed */
1929 4 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1930 4 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::Selection)) {
1931 2 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1932 1 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1933 : }
1934 :
1935 : /*
1936 : * The object might _still_ be null, but that's OK.
1937 : *
1938 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1939 : * traced by TraceProtoAndIfaceCache() and its contents are never
1940 : * changed after they have been set.
1941 : *
1942 : * Calling address() avoids the read read barrier that does gray
1943 : * unmarking, but it's not possible for the object to be gray here.
1944 : */
1945 :
1946 4 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::Selection);
1947 4 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1948 4 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1949 : }
1950 :
1951 : JS::Handle<JSObject*>
1952 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
1953 : {
1954 : /* Get the interface object for this class. This will create the object as
1955 : needed. */
1956 :
1957 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1958 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1959 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1960 0 : return nullptr;
1961 : }
1962 :
1963 : /* Check to see whether the interface objects are already installed */
1964 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1965 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::Selection)) {
1966 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1967 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1968 : }
1969 :
1970 : /*
1971 : * The object might _still_ be null, but that's OK.
1972 : *
1973 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1974 : * traced by TraceProtoAndIfaceCache() and its contents are never
1975 : * changed after they have been set.
1976 : *
1977 : * Calling address() avoids the read read barrier that does gray
1978 : * unmarking, but it's not possible for the object to be gray here.
1979 : */
1980 :
1981 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::Selection);
1982 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1983 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1984 : }
1985 :
1986 : JSObject*
1987 0 : GetConstructorObject(JSContext* aCx)
1988 : {
1989 0 : return GetConstructorObjectHandle(aCx);
1990 : }
1991 :
1992 : } // namespace SelectionBinding
1993 :
1994 :
1995 :
1996 : } // namespace dom
1997 : } // namespace mozilla
|