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