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