/work/obj-fuzz/dom/bindings/TreeWalkerBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM TreeWalker.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "NodeFilterBinding.h" |
4 | | #include "TreeWalkerBinding.h" |
5 | | #include "WrapperFactory.h" |
6 | | #include "mozilla/OwningNonNull.h" |
7 | | #include "mozilla/dom/BindingUtils.h" |
8 | | #include "mozilla/dom/DOMJSClass.h" |
9 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
10 | | #include "mozilla/dom/Nullable.h" |
11 | | #include "mozilla/dom/PrimitiveConversions.h" |
12 | | #include "mozilla/dom/TreeWalker.h" |
13 | | #include "mozilla/dom/XrayExpandoClass.h" |
14 | | #include "nsINode.h" |
15 | | |
16 | | namespace mozilla { |
17 | | namespace dom { |
18 | | |
19 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
20 | | using namespace mozilla::dom::binding_detail; |
21 | | |
22 | | |
23 | | namespace TreeWalker_Binding { |
24 | | |
25 | | MOZ_CAN_RUN_SCRIPT static bool |
26 | | get_root(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, JSJitGetterCallArgs args) |
27 | 0 | { |
28 | 0 | AUTO_PROFILER_LABEL_FAST("get TreeWalker.root", DOM, cx); |
29 | 0 |
|
30 | 0 | auto result(StrongOrRawPtr<nsINode>(self->Root())); |
31 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
32 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
33 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
34 | 0 | return false; |
35 | 0 | } |
36 | 0 | return true; |
37 | 0 | } |
38 | | |
39 | | static const JSJitInfo root_getterinfo = { |
40 | | { (JSJitGetterOp)get_root }, |
41 | | { prototypes::id::TreeWalker }, |
42 | | { PrototypeTraits<prototypes::id::TreeWalker>::Depth }, |
43 | | JSJitInfo::Getter, |
44 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
45 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
46 | | false, /* isInfallible. False in setters. */ |
47 | | true, /* isMovable. Not relevant for setters. */ |
48 | | true, /* isEliminatable. Not relevant for setters. */ |
49 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
50 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
51 | | false, /* isTypedMethod. Only relevant for methods. */ |
52 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
53 | | }; |
54 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
55 | | static_assert(0 < 1, "There is no slot for us"); |
56 | | |
57 | | MOZ_CAN_RUN_SCRIPT static bool |
58 | | get_whatToShow(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, JSJitGetterCallArgs args) |
59 | 0 | { |
60 | 0 | AUTO_PROFILER_LABEL_FAST("get TreeWalker.whatToShow", DOM, cx); |
61 | 0 |
|
62 | 0 | uint32_t result(self->WhatToShow()); |
63 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
64 | 0 | args.rval().setNumber(result); |
65 | 0 | return true; |
66 | 0 | } |
67 | | |
68 | | static const JSJitInfo whatToShow_getterinfo = { |
69 | | { (JSJitGetterOp)get_whatToShow }, |
70 | | { prototypes::id::TreeWalker }, |
71 | | { PrototypeTraits<prototypes::id::TreeWalker>::Depth }, |
72 | | JSJitInfo::Getter, |
73 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
74 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
75 | | true, /* isInfallible. False in setters. */ |
76 | | true, /* isMovable. Not relevant for setters. */ |
77 | | true, /* isEliminatable. Not relevant for setters. */ |
78 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
79 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
80 | | false, /* isTypedMethod. Only relevant for methods. */ |
81 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
82 | | }; |
83 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
84 | | static_assert(0 < 1, "There is no slot for us"); |
85 | | |
86 | | MOZ_CAN_RUN_SCRIPT static bool |
87 | | get_filter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, JSJitGetterCallArgs args) |
88 | 0 | { |
89 | 0 | AUTO_PROFILER_LABEL_FAST("get TreeWalker.filter", DOM, cx); |
90 | 0 |
|
91 | 0 | auto result(StrongOrRawPtr<mozilla::dom::NodeFilter>(self->GetFilter())); |
92 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
93 | 0 | if (result) { |
94 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
95 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
96 | 0 | return false; |
97 | 0 | } |
98 | 0 | return true; |
99 | 0 | } else { |
100 | 0 | args.rval().setNull(); |
101 | 0 | return true; |
102 | 0 | } |
103 | 0 | } |
104 | | |
105 | | static const JSJitInfo filter_getterinfo = { |
106 | | { (JSJitGetterOp)get_filter }, |
107 | | { prototypes::id::TreeWalker }, |
108 | | { PrototypeTraits<prototypes::id::TreeWalker>::Depth }, |
109 | | JSJitInfo::Getter, |
110 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
111 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
112 | | false, /* isInfallible. False in setters. */ |
113 | | true, /* isMovable. Not relevant for setters. */ |
114 | | true, /* isEliminatable. Not relevant for setters. */ |
115 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
116 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
117 | | false, /* isTypedMethod. Only relevant for methods. */ |
118 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
119 | | }; |
120 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
121 | | static_assert(0 < 1, "There is no slot for us"); |
122 | | |
123 | | MOZ_CAN_RUN_SCRIPT static bool |
124 | | get_currentNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, JSJitGetterCallArgs args) |
125 | 0 | { |
126 | 0 | AUTO_PROFILER_LABEL_FAST("get TreeWalker.currentNode", DOM, cx); |
127 | 0 |
|
128 | 0 | auto result(StrongOrRawPtr<nsINode>(self->CurrentNode())); |
129 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
130 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
131 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
132 | 0 | return false; |
133 | 0 | } |
134 | 0 | return true; |
135 | 0 | } |
136 | | |
137 | | MOZ_CAN_RUN_SCRIPT static bool |
138 | | set_currentNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, JSJitSetterCallArgs args) |
139 | 0 | { |
140 | 0 | AUTO_PROFILER_LABEL_FAST("set TreeWalker.currentNode", DOM, cx); |
141 | 0 |
|
142 | 0 | NonNull<nsINode> arg0; |
143 | 0 | if (args[0].isObject()) { |
144 | 0 | { |
145 | 0 | nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0); |
146 | 0 | if (NS_FAILED(rv)) { |
147 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Value being assigned to TreeWalker.currentNode", "Node"); |
148 | 0 | return false; |
149 | 0 | } |
150 | 0 | } |
151 | 0 | } else { |
152 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Value being assigned to TreeWalker.currentNode"); |
153 | 0 | return false; |
154 | 0 | } |
155 | 0 | FastErrorResult rv; |
156 | 0 | self->SetCurrentNode(MOZ_KnownLive(NonNullHelper(arg0)), rv); |
157 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
158 | 0 | return false; |
159 | 0 | } |
160 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
161 | 0 |
|
162 | 0 | return true; |
163 | 0 | } |
164 | | |
165 | | static const JSJitInfo currentNode_getterinfo = { |
166 | | { (JSJitGetterOp)get_currentNode }, |
167 | | { prototypes::id::TreeWalker }, |
168 | | { PrototypeTraits<prototypes::id::TreeWalker>::Depth }, |
169 | | JSJitInfo::Getter, |
170 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
171 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
172 | | false, /* isInfallible. False in setters. */ |
173 | | true, /* isMovable. Not relevant for setters. */ |
174 | | true, /* isEliminatable. Not relevant for setters. */ |
175 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
176 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
177 | | false, /* isTypedMethod. Only relevant for methods. */ |
178 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
179 | | }; |
180 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
181 | | static_assert(0 < 1, "There is no slot for us"); |
182 | | static const JSJitInfo currentNode_setterinfo = { |
183 | | { (JSJitGetterOp)set_currentNode }, |
184 | | { prototypes::id::TreeWalker }, |
185 | | { PrototypeTraits<prototypes::id::TreeWalker>::Depth }, |
186 | | JSJitInfo::Setter, |
187 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
188 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
189 | | false, /* isInfallible. False in setters. */ |
190 | | false, /* isMovable. Not relevant for setters. */ |
191 | | false, /* isEliminatable. Not relevant for setters. */ |
192 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
193 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
194 | | false, /* isTypedMethod. Only relevant for methods. */ |
195 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
196 | | }; |
197 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
198 | | static_assert(0 < 1, "There is no slot for us"); |
199 | | |
200 | | MOZ_CAN_RUN_SCRIPT static bool |
201 | | parentNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, const JSJitMethodCallArgs& args) |
202 | 0 | { |
203 | 0 | AUTO_PROFILER_LABEL_FAST("TreeWalker.parentNode", DOM, cx); |
204 | 0 |
|
205 | 0 | FastErrorResult rv; |
206 | 0 | auto result(StrongOrRawPtr<nsINode>(self->ParentNode(rv))); |
207 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
208 | 0 | return false; |
209 | 0 | } |
210 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
211 | 0 | if (!result) { |
212 | 0 | args.rval().setNull(); |
213 | 0 | return true; |
214 | 0 | } |
215 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
216 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
217 | 0 | return false; |
218 | 0 | } |
219 | 0 | return true; |
220 | 0 | } |
221 | | |
222 | | static const JSJitInfo parentNode_methodinfo = { |
223 | | { (JSJitGetterOp)parentNode }, |
224 | | { prototypes::id::TreeWalker }, |
225 | | { PrototypeTraits<prototypes::id::TreeWalker>::Depth }, |
226 | | JSJitInfo::Method, |
227 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
228 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
229 | | false, /* isInfallible. False in setters. */ |
230 | | false, /* isMovable. Not relevant for setters. */ |
231 | | false, /* isEliminatable. Not relevant for setters. */ |
232 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
233 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
234 | | false, /* isTypedMethod. Only relevant for methods. */ |
235 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
236 | | }; |
237 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
238 | | static_assert(0 < 1, "There is no slot for us"); |
239 | | |
240 | | MOZ_CAN_RUN_SCRIPT static bool |
241 | | firstChild(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, const JSJitMethodCallArgs& args) |
242 | 0 | { |
243 | 0 | AUTO_PROFILER_LABEL_FAST("TreeWalker.firstChild", DOM, cx); |
244 | 0 |
|
245 | 0 | FastErrorResult rv; |
246 | 0 | auto result(StrongOrRawPtr<nsINode>(self->FirstChild(rv))); |
247 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
248 | 0 | return false; |
249 | 0 | } |
250 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
251 | 0 | if (!result) { |
252 | 0 | args.rval().setNull(); |
253 | 0 | return true; |
254 | 0 | } |
255 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
256 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
257 | 0 | return false; |
258 | 0 | } |
259 | 0 | return true; |
260 | 0 | } |
261 | | |
262 | | static const JSJitInfo firstChild_methodinfo = { |
263 | | { (JSJitGetterOp)firstChild }, |
264 | | { prototypes::id::TreeWalker }, |
265 | | { PrototypeTraits<prototypes::id::TreeWalker>::Depth }, |
266 | | JSJitInfo::Method, |
267 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
268 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
269 | | false, /* isInfallible. False in setters. */ |
270 | | false, /* isMovable. Not relevant for setters. */ |
271 | | false, /* isEliminatable. Not relevant for setters. */ |
272 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
273 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
274 | | false, /* isTypedMethod. Only relevant for methods. */ |
275 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
276 | | }; |
277 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
278 | | static_assert(0 < 1, "There is no slot for us"); |
279 | | |
280 | | MOZ_CAN_RUN_SCRIPT static bool |
281 | | lastChild(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, const JSJitMethodCallArgs& args) |
282 | 0 | { |
283 | 0 | AUTO_PROFILER_LABEL_FAST("TreeWalker.lastChild", DOM, cx); |
284 | 0 |
|
285 | 0 | FastErrorResult rv; |
286 | 0 | auto result(StrongOrRawPtr<nsINode>(self->LastChild(rv))); |
287 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
288 | 0 | return false; |
289 | 0 | } |
290 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
291 | 0 | if (!result) { |
292 | 0 | args.rval().setNull(); |
293 | 0 | return true; |
294 | 0 | } |
295 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
296 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
297 | 0 | return false; |
298 | 0 | } |
299 | 0 | return true; |
300 | 0 | } |
301 | | |
302 | | static const JSJitInfo lastChild_methodinfo = { |
303 | | { (JSJitGetterOp)lastChild }, |
304 | | { prototypes::id::TreeWalker }, |
305 | | { PrototypeTraits<prototypes::id::TreeWalker>::Depth }, |
306 | | JSJitInfo::Method, |
307 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
308 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
309 | | false, /* isInfallible. False in setters. */ |
310 | | false, /* isMovable. Not relevant for setters. */ |
311 | | false, /* isEliminatable. Not relevant for setters. */ |
312 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
313 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
314 | | false, /* isTypedMethod. Only relevant for methods. */ |
315 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
316 | | }; |
317 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
318 | | static_assert(0 < 1, "There is no slot for us"); |
319 | | |
320 | | MOZ_CAN_RUN_SCRIPT static bool |
321 | | previousSibling(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, const JSJitMethodCallArgs& args) |
322 | 0 | { |
323 | 0 | AUTO_PROFILER_LABEL_FAST("TreeWalker.previousSibling", DOM, cx); |
324 | 0 |
|
325 | 0 | FastErrorResult rv; |
326 | 0 | auto result(StrongOrRawPtr<nsINode>(self->PreviousSibling(rv))); |
327 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
328 | 0 | return false; |
329 | 0 | } |
330 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
331 | 0 | if (!result) { |
332 | 0 | args.rval().setNull(); |
333 | 0 | return true; |
334 | 0 | } |
335 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
336 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
337 | 0 | return false; |
338 | 0 | } |
339 | 0 | return true; |
340 | 0 | } |
341 | | |
342 | | static const JSJitInfo previousSibling_methodinfo = { |
343 | | { (JSJitGetterOp)previousSibling }, |
344 | | { prototypes::id::TreeWalker }, |
345 | | { PrototypeTraits<prototypes::id::TreeWalker>::Depth }, |
346 | | JSJitInfo::Method, |
347 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
348 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
349 | | false, /* isInfallible. False in setters. */ |
350 | | false, /* isMovable. Not relevant for setters. */ |
351 | | false, /* isEliminatable. Not relevant for setters. */ |
352 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
353 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
354 | | false, /* isTypedMethod. Only relevant for methods. */ |
355 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
356 | | }; |
357 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
358 | | static_assert(0 < 1, "There is no slot for us"); |
359 | | |
360 | | MOZ_CAN_RUN_SCRIPT static bool |
361 | | nextSibling(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, const JSJitMethodCallArgs& args) |
362 | 0 | { |
363 | 0 | AUTO_PROFILER_LABEL_FAST("TreeWalker.nextSibling", DOM, cx); |
364 | 0 |
|
365 | 0 | FastErrorResult rv; |
366 | 0 | auto result(StrongOrRawPtr<nsINode>(self->NextSibling(rv))); |
367 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
368 | 0 | return false; |
369 | 0 | } |
370 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
371 | 0 | if (!result) { |
372 | 0 | args.rval().setNull(); |
373 | 0 | return true; |
374 | 0 | } |
375 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
376 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
377 | 0 | return false; |
378 | 0 | } |
379 | 0 | return true; |
380 | 0 | } |
381 | | |
382 | | static const JSJitInfo nextSibling_methodinfo = { |
383 | | { (JSJitGetterOp)nextSibling }, |
384 | | { prototypes::id::TreeWalker }, |
385 | | { PrototypeTraits<prototypes::id::TreeWalker>::Depth }, |
386 | | JSJitInfo::Method, |
387 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
388 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
389 | | false, /* isInfallible. False in setters. */ |
390 | | false, /* isMovable. Not relevant for setters. */ |
391 | | false, /* isEliminatable. Not relevant for setters. */ |
392 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
393 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
394 | | false, /* isTypedMethod. Only relevant for methods. */ |
395 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
396 | | }; |
397 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
398 | | static_assert(0 < 1, "There is no slot for us"); |
399 | | |
400 | | MOZ_CAN_RUN_SCRIPT static bool |
401 | | previousNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, const JSJitMethodCallArgs& args) |
402 | 0 | { |
403 | 0 | AUTO_PROFILER_LABEL_FAST("TreeWalker.previousNode", DOM, cx); |
404 | 0 |
|
405 | 0 | FastErrorResult rv; |
406 | 0 | auto result(StrongOrRawPtr<nsINode>(self->PreviousNode(rv))); |
407 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
408 | 0 | return false; |
409 | 0 | } |
410 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
411 | 0 | if (!result) { |
412 | 0 | args.rval().setNull(); |
413 | 0 | return true; |
414 | 0 | } |
415 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
416 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
417 | 0 | return false; |
418 | 0 | } |
419 | 0 | return true; |
420 | 0 | } |
421 | | |
422 | | static const JSJitInfo previousNode_methodinfo = { |
423 | | { (JSJitGetterOp)previousNode }, |
424 | | { prototypes::id::TreeWalker }, |
425 | | { PrototypeTraits<prototypes::id::TreeWalker>::Depth }, |
426 | | JSJitInfo::Method, |
427 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
428 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
429 | | false, /* isInfallible. False in setters. */ |
430 | | false, /* isMovable. Not relevant for setters. */ |
431 | | false, /* isEliminatable. Not relevant for setters. */ |
432 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
433 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
434 | | false, /* isTypedMethod. Only relevant for methods. */ |
435 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
436 | | }; |
437 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
438 | | static_assert(0 < 1, "There is no slot for us"); |
439 | | |
440 | | MOZ_CAN_RUN_SCRIPT static bool |
441 | | nextNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TreeWalker* self, const JSJitMethodCallArgs& args) |
442 | 0 | { |
443 | 0 | AUTO_PROFILER_LABEL_FAST("TreeWalker.nextNode", DOM, cx); |
444 | 0 |
|
445 | 0 | FastErrorResult rv; |
446 | 0 | auto result(StrongOrRawPtr<nsINode>(self->NextNode(rv))); |
447 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
448 | 0 | return false; |
449 | 0 | } |
450 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
451 | 0 | if (!result) { |
452 | 0 | args.rval().setNull(); |
453 | 0 | return true; |
454 | 0 | } |
455 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
456 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
457 | 0 | return false; |
458 | 0 | } |
459 | 0 | return true; |
460 | 0 | } |
461 | | |
462 | | static const JSJitInfo nextNode_methodinfo = { |
463 | | { (JSJitGetterOp)nextNode }, |
464 | | { prototypes::id::TreeWalker }, |
465 | | { PrototypeTraits<prototypes::id::TreeWalker>::Depth }, |
466 | | JSJitInfo::Method, |
467 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
468 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
469 | | false, /* isInfallible. False in setters. */ |
470 | | false, /* isMovable. Not relevant for setters. */ |
471 | | false, /* isEliminatable. Not relevant for setters. */ |
472 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
473 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
474 | | false, /* isTypedMethod. Only relevant for methods. */ |
475 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
476 | | }; |
477 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
478 | | static_assert(0 < 1, "There is no slot for us"); |
479 | | |
480 | | static void |
481 | | _finalize(js::FreeOp* fop, JSObject* obj) |
482 | 0 | { |
483 | 0 | mozilla::dom::TreeWalker* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::TreeWalker>(obj); |
484 | 0 | if (self) { |
485 | 0 | AddForDeferredFinalization<mozilla::dom::TreeWalker>(self); |
486 | 0 | } |
487 | 0 | } |
488 | | |
489 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
490 | | #if defined(__clang__) |
491 | | #pragma clang diagnostic push |
492 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
493 | | #endif |
494 | | static const JSFunctionSpec sMethods_specs[] = { |
495 | | JS_FNSPEC("parentNode", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&parentNode_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
496 | | JS_FNSPEC("firstChild", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&firstChild_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
497 | | JS_FNSPEC("lastChild", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&lastChild_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
498 | | JS_FNSPEC("previousSibling", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&previousSibling_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
499 | | JS_FNSPEC("nextSibling", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&nextSibling_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
500 | | JS_FNSPEC("previousNode", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&previousNode_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
501 | | JS_FNSPEC("nextNode", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&nextNode_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
502 | | JS_FS_END |
503 | | }; |
504 | | #if defined(__clang__) |
505 | | #pragma clang diagnostic pop |
506 | | #endif |
507 | | |
508 | | |
509 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
510 | | { nullptr, &sMethods_specs[0] }, |
511 | | { nullptr, nullptr } |
512 | | }; |
513 | | |
514 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
515 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
516 | | static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
517 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
518 | | |
519 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
520 | | #if defined(__clang__) |
521 | | #pragma clang diagnostic push |
522 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
523 | | #endif |
524 | | static const JSPropertySpec sAttributes_specs[] = { |
525 | | { "root", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &root_getterinfo, nullptr, nullptr }, |
526 | | { "whatToShow", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &whatToShow_getterinfo, nullptr, nullptr }, |
527 | | { "filter", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &filter_getterinfo, nullptr, nullptr }, |
528 | | { "currentNode", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, ¤tNode_getterinfo, GenericSetter<NormalThisPolicy>, ¤tNode_setterinfo }, |
529 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
530 | | }; |
531 | | #if defined(__clang__) |
532 | | #pragma clang diagnostic pop |
533 | | #endif |
534 | | |
535 | | |
536 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
537 | | { nullptr, &sAttributes_specs[0] }, |
538 | | { nullptr, nullptr } |
539 | | }; |
540 | | |
541 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
542 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
543 | | static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
544 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
545 | | |
546 | | |
547 | | static uint16_t sNativeProperties_sortedPropertyIndices[11]; |
548 | | static PropertyInfo sNativeProperties_propertyInfos[11]; |
549 | | |
550 | | static const NativePropertiesN<2> sNativeProperties = { |
551 | | false, 0, |
552 | | false, 0, |
553 | | true, 0 /* sMethods */, |
554 | | true, 1 /* sAttributes */, |
555 | | false, 0, |
556 | | false, 0, |
557 | | false, 0, |
558 | | -1, |
559 | | 11, |
560 | | sNativeProperties_sortedPropertyIndices, |
561 | | { |
562 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
563 | | { sAttributes, &sNativeProperties_propertyInfos[7] } |
564 | | } |
565 | | }; |
566 | | static_assert(11 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
567 | | "We have a property info count that is oversized"); |
568 | | |
569 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
570 | | { |
571 | | "Function", |
572 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
573 | | &sBoringInterfaceObjectClassClassOps, |
574 | | JS_NULL_CLASS_SPEC, |
575 | | JS_NULL_CLASS_EXT, |
576 | | &sInterfaceObjectClassObjectOps |
577 | | }, |
578 | | eInterface, |
579 | | true, |
580 | | prototypes::id::TreeWalker, |
581 | | PrototypeTraits<prototypes::id::TreeWalker>::Depth, |
582 | | sNativePropertyHooks, |
583 | | "function TreeWalker() {\n [native code]\n}", |
584 | | JS::GetRealmFunctionPrototype |
585 | | }; |
586 | | |
587 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
588 | | { |
589 | | "TreeWalkerPrototype", |
590 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
591 | | JS_NULL_CLASS_OPS, |
592 | | JS_NULL_CLASS_SPEC, |
593 | | JS_NULL_CLASS_EXT, |
594 | | JS_NULL_OBJECT_OPS |
595 | | }, |
596 | | eInterfacePrototype, |
597 | | false, |
598 | | prototypes::id::TreeWalker, |
599 | | PrototypeTraits<prototypes::id::TreeWalker>::Depth, |
600 | | sNativePropertyHooks, |
601 | | "[object TreeWalkerPrototype]", |
602 | | JS::GetRealmObjectPrototype |
603 | | }; |
604 | | |
605 | | static const js::ClassOps sClassOps = { |
606 | | nullptr, /* addProperty */ |
607 | | nullptr, /* delProperty */ |
608 | | nullptr, /* enumerate */ |
609 | | nullptr, /* newEnumerate */ |
610 | | nullptr, /* resolve */ |
611 | | nullptr, /* mayResolve */ |
612 | | _finalize, /* finalize */ |
613 | | nullptr, /* call */ |
614 | | nullptr, /* hasInstance */ |
615 | | nullptr, /* construct */ |
616 | | nullptr, /* trace */ |
617 | | }; |
618 | | |
619 | | static const js::ClassExtension sClassExtension = { |
620 | | nullptr, /* weakmapKeyDelegateOp */ |
621 | | nullptr /* objectMovedOp */ |
622 | | }; |
623 | | |
624 | | static const DOMJSClass sClass = { |
625 | | { "TreeWalker", |
626 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
627 | | &sClassOps, |
628 | | JS_NULL_CLASS_SPEC, |
629 | | &sClassExtension, |
630 | | JS_NULL_OBJECT_OPS |
631 | | }, |
632 | | { prototypes::id::TreeWalker, 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 }, |
633 | | IsBaseOf<nsISupports, mozilla::dom::TreeWalker >::value, |
634 | | sNativePropertyHooks, |
635 | | FindAssociatedGlobalForNative<mozilla::dom::TreeWalker>::Get, |
636 | | GetProtoObjectHandle, |
637 | | GetCCParticipant<mozilla::dom::TreeWalker>::Get() |
638 | | }; |
639 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
640 | | "Must have the right minimal number of reserved slots."); |
641 | | static_assert(1 >= 1, |
642 | | "Must have enough reserved slots."); |
643 | | |
644 | | const JSClass* |
645 | | GetJSClass() |
646 | 0 | { |
647 | 0 | return sClass.ToJSClass(); |
648 | 0 | } |
649 | | |
650 | | bool |
651 | | Wrap(JSContext* aCx, mozilla::dom::TreeWalker* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
652 | 0 | { |
653 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::TreeWalker*>(aObject) == |
654 | 0 | reinterpret_cast<mozilla::dom::TreeWalker*>(aObject), |
655 | 0 | "Multiple inheritance for mozilla::dom::TreeWalker is broken."); |
656 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
657 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
658 | 0 |
|
659 | 0 | JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx)); |
660 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
661 | 0 | if (!canonicalProto) { |
662 | 0 | return false; |
663 | 0 | } |
664 | 0 | JS::Rooted<JSObject*> proto(aCx); |
665 | 0 | if (aGivenProto) { |
666 | 0 | proto = aGivenProto; |
667 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
668 | 0 | // coming in, we changed compartments to that of "parent" so may need |
669 | 0 | // to wrap the proto here. |
670 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
671 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
672 | 0 | return false; |
673 | 0 | } |
674 | 0 | } |
675 | 0 | } else { |
676 | 0 | proto = canonicalProto; |
677 | 0 | } |
678 | 0 |
|
679 | 0 | BindingJSObjectCreator<mozilla::dom::TreeWalker> creator(aCx); |
680 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
681 | 0 | if (!aReflector) { |
682 | 0 | return false; |
683 | 0 | } |
684 | 0 | |
685 | 0 | |
686 | 0 | |
687 | 0 | creator.InitializationSucceeded(); |
688 | 0 | return true; |
689 | 0 | } |
690 | | |
691 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
692 | | nullptr, |
693 | | nullptr, |
694 | | nullptr, |
695 | | { sNativeProperties.Upcast(), nullptr }, |
696 | | prototypes::id::TreeWalker, |
697 | | constructors::id::TreeWalker, |
698 | | nullptr, |
699 | | &DefaultXrayExpandoObjectClass |
700 | | } }; |
701 | | |
702 | | void |
703 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
704 | 0 | { |
705 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
706 | 0 | if (!parentProto) { |
707 | 0 | return; |
708 | 0 | } |
709 | 0 | |
710 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
711 | 0 | if (!constructorProto) { |
712 | 0 | return; |
713 | 0 | } |
714 | 0 | |
715 | 0 | static bool sIdsInited = false; |
716 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
717 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
718 | 0 | return; |
719 | 0 | } |
720 | 0 | sIdsInited = true; |
721 | 0 | } |
722 | 0 |
|
723 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::TreeWalker); |
724 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::TreeWalker); |
725 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
726 | 0 | &sPrototypeClass.mBase, protoCache, |
727 | 0 | nullptr, |
728 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
729 | 0 | interfaceCache, |
730 | 0 | sNativeProperties.Upcast(), |
731 | 0 | nullptr, |
732 | 0 | "TreeWalker", aDefineOnGlobal, |
733 | 0 | nullptr, |
734 | 0 | false); |
735 | 0 | } |
736 | | |
737 | | JSObject* |
738 | | GetConstructorObject(JSContext* aCx) |
739 | 0 | { |
740 | 0 | return GetConstructorObjectHandle(aCx); |
741 | 0 | } |
742 | | |
743 | | } // namespace TreeWalker_Binding |
744 | | |
745 | | |
746 | | |
747 | | } // namespace dom |
748 | | } // namespace mozilla |