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