/work/obj-fuzz/dom/bindings/NodeBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM Node.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AtomList.h" |
4 | | #include "EventTargetBinding.h" |
5 | | #include "L10nUtilsBinding.h" |
6 | | #include "NodeBinding.h" |
7 | | #include "WrapperFactory.h" |
8 | | #include "mozilla/OwningNonNull.h" |
9 | | #include "mozilla/dom/AccessibleNode.h" |
10 | | #include "mozilla/dom/BindingUtils.h" |
11 | | #include "mozilla/dom/CustomElementRegistry.h" |
12 | | #include "mozilla/dom/DOMJSClass.h" |
13 | | #include "mozilla/dom/DocGroup.h" |
14 | | #include "mozilla/dom/Element.h" |
15 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
16 | | #include "mozilla/dom/Nullable.h" |
17 | | #include "mozilla/dom/PrimitiveConversions.h" |
18 | | #include "mozilla/dom/Promise.h" |
19 | | #include "mozilla/dom/ScriptSettings.h" |
20 | | #include "mozilla/dom/SimpleGlobalObject.h" |
21 | | #include "mozilla/dom/ToJSValue.h" |
22 | | #include "mozilla/dom/XrayExpandoClass.h" |
23 | | #include "nsContentUtils.h" |
24 | | #include "nsIDocument.h" |
25 | | #include "nsINode.h" |
26 | | #include "nsINodeList.h" |
27 | | #include "nsIPrincipal.h" |
28 | | #include "nsIURI.h" |
29 | | |
30 | | namespace mozilla { |
31 | | namespace dom { |
32 | | |
33 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
34 | | using namespace mozilla::dom::binding_detail; |
35 | | |
36 | | |
37 | | |
38 | | GetRootNodeOptions::GetRootNodeOptions() |
39 | 0 | { |
40 | 0 | // Safe to pass a null context if we pass a null value |
41 | 0 | Init(nullptr, JS::NullHandleValue); |
42 | 0 | } |
43 | | |
44 | | |
45 | | |
46 | | bool |
47 | | GetRootNodeOptions::InitIds(JSContext* cx, GetRootNodeOptionsAtoms* atomsCache) |
48 | 0 | { |
49 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
50 | 0 |
|
51 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
52 | 0 | // uninitialized. |
53 | 0 | if (!atomsCache->composed_id.init(cx, "composed")) { |
54 | 0 | return false; |
55 | 0 | } |
56 | 0 | return true; |
57 | 0 | } |
58 | | |
59 | | bool |
60 | | GetRootNodeOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
61 | 0 | { |
62 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
63 | 0 | // Since in that case we will not have to do any property gets |
64 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
65 | 0 | // checkers by static analysis tools |
66 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
67 | 0 | GetRootNodeOptionsAtoms* atomsCache = nullptr; |
68 | 0 | if (cx) { |
69 | 0 | atomsCache = GetAtomCache<GetRootNodeOptionsAtoms>(cx); |
70 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
71 | 0 | return false; |
72 | 0 | } |
73 | 0 | } |
74 | 0 | |
75 | 0 | if (!IsConvertibleToDictionary(val)) { |
76 | 0 | return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription); |
77 | 0 | } |
78 | 0 | |
79 | 0 | bool isNull = val.isNullOrUndefined(); |
80 | 0 | // We only need these if !isNull, in which case we have |cx|. |
81 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
82 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
83 | 0 | if (!isNull) { |
84 | 0 | MOZ_ASSERT(cx); |
85 | 0 | object.emplace(cx, &val.toObject()); |
86 | 0 | temp.emplace(cx); |
87 | 0 | } |
88 | 0 | if (!isNull) { |
89 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->composed_id, temp.ptr())) { |
90 | 0 | return false; |
91 | 0 | } |
92 | 0 | } |
93 | 0 | if (!isNull && !temp->isUndefined()) { |
94 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mComposed)) { |
95 | 0 | return false; |
96 | 0 | } |
97 | 0 | } else { |
98 | 0 | mComposed = false; |
99 | 0 | } |
100 | 0 | mIsAnyMemberPresent = true; |
101 | 0 | return true; |
102 | 0 | } |
103 | | |
104 | | bool |
105 | | GetRootNodeOptions::Init(const nsAString& aJSON) |
106 | 0 | { |
107 | 0 | AutoJSAPI jsapi; |
108 | 0 | JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail); |
109 | 0 | if (!cleanGlobal) { |
110 | 0 | return false; |
111 | 0 | } |
112 | 0 | if (!jsapi.Init(cleanGlobal)) { |
113 | 0 | return false; |
114 | 0 | } |
115 | 0 | JSContext* cx = jsapi.cx(); |
116 | 0 | JS::Rooted<JS::Value> json(cx); |
117 | 0 | bool ok = ParseJSON(cx, aJSON, &json); |
118 | 0 | NS_ENSURE_TRUE(ok, false); |
119 | 0 | return Init(cx, json); |
120 | 0 | } |
121 | | |
122 | | bool |
123 | | GetRootNodeOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
124 | 0 | { |
125 | 0 | GetRootNodeOptionsAtoms* atomsCache = GetAtomCache<GetRootNodeOptionsAtoms>(cx); |
126 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
127 | 0 | return false; |
128 | 0 | } |
129 | 0 | |
130 | 0 | JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx)); |
131 | 0 | if (!obj) { |
132 | 0 | return false; |
133 | 0 | } |
134 | 0 | rval.set(JS::ObjectValue(*obj)); |
135 | 0 |
|
136 | 0 | do { |
137 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
138 | 0 | JS::Rooted<JS::Value> temp(cx); |
139 | 0 | bool const & currentValue = mComposed; |
140 | 0 | temp.setBoolean(currentValue); |
141 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->composed_id, temp, JSPROP_ENUMERATE)) { |
142 | 0 | return false; |
143 | 0 | } |
144 | 0 | break; |
145 | 0 | } while(false); |
146 | 0 |
|
147 | 0 | return true; |
148 | 0 | } |
149 | | |
150 | | bool |
151 | | GetRootNodeOptions::ToJSON(nsAString& aJSON) const |
152 | 0 | { |
153 | 0 | AutoJSAPI jsapi; |
154 | 0 | jsapi.Init(); |
155 | 0 | JSContext *cx = jsapi.cx(); |
156 | 0 | // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here |
157 | 0 | // because we'll only be creating objects, in ways that have no |
158 | 0 | // side-effects, followed by a call to JS::ToJSONMaybeSafely, |
159 | 0 | // which likewise guarantees no side-effects for the sorts of |
160 | 0 | // things we will pass it. |
161 | 0 | JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal()); |
162 | 0 | JS::Rooted<JS::Value> val(cx); |
163 | 0 | if (!ToObjectInternal(cx, &val)) { |
164 | 0 | return false; |
165 | 0 | } |
166 | 0 | JS::Rooted<JSObject*> obj(cx, &val.toObject()); |
167 | 0 | return StringifyToJSON(cx, obj, aJSON); |
168 | 0 | } |
169 | | |
170 | | void |
171 | | GetRootNodeOptions::TraceDictionary(JSTracer* trc) |
172 | 0 | { |
173 | 0 | } |
174 | | |
175 | | GetRootNodeOptions& |
176 | | GetRootNodeOptions::operator=(const GetRootNodeOptions& aOther) |
177 | 0 | { |
178 | 0 | DictionaryBase::operator=(aOther); |
179 | 0 | mComposed = aOther.mComposed; |
180 | 0 | return *this; |
181 | 0 | } |
182 | | |
183 | | namespace binding_detail { |
184 | | } // namespace binding_detail |
185 | | |
186 | | |
187 | | namespace Node_Binding { |
188 | | |
189 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTarget_Binding::NativeType>::value, |
190 | | "Can't inherit from an interface with a different ownership model."); |
191 | | |
192 | | MOZ_CAN_RUN_SCRIPT static bool |
193 | | get_nodeType(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitGetterCallArgs args) |
194 | 0 | { |
195 | 0 | AUTO_PROFILER_LABEL_FAST("get Node.nodeType", DOM, cx); |
196 | 0 |
|
197 | 0 | uint16_t result(self->NodeType()); |
198 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
199 | 0 | args.rval().setInt32(int32_t(result)); |
200 | 0 | return true; |
201 | 0 | } |
202 | | |
203 | | static const JSJitInfo nodeType_getterinfo = { |
204 | | { (JSJitGetterOp)get_nodeType }, |
205 | | { prototypes::id::Node }, |
206 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
207 | | JSJitInfo::Getter, |
208 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
209 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
210 | | true, /* isInfallible. False in setters. */ |
211 | | true, /* isMovable. Not relevant for setters. */ |
212 | | true, /* isEliminatable. Not relevant for setters. */ |
213 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
214 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
215 | | false, /* isTypedMethod. Only relevant for methods. */ |
216 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
217 | | }; |
218 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
219 | | static_assert(0 < 1, "There is no slot for us"); |
220 | | |
221 | | MOZ_CAN_RUN_SCRIPT static bool |
222 | | get_nodeName(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitGetterCallArgs args) |
223 | 0 | { |
224 | 0 | AUTO_PROFILER_LABEL_FAST("get Node.nodeName", DOM, cx); |
225 | 0 |
|
226 | 0 | DOMString result; |
227 | 0 | self->GetNodeName(result); |
228 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
229 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
230 | 0 | return false; |
231 | 0 | } |
232 | 0 | return true; |
233 | 0 | } |
234 | | |
235 | | static const JSJitInfo nodeName_getterinfo = { |
236 | | { (JSJitGetterOp)get_nodeName }, |
237 | | { prototypes::id::Node }, |
238 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
239 | | JSJitInfo::Getter, |
240 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
241 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
242 | | false, /* isInfallible. False in setters. */ |
243 | | true, /* isMovable. Not relevant for setters. */ |
244 | | true, /* isEliminatable. Not relevant for setters. */ |
245 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
246 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
247 | | false, /* isTypedMethod. Only relevant for methods. */ |
248 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
249 | | }; |
250 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
251 | | static_assert(0 < 1, "There is no slot for us"); |
252 | | |
253 | | MOZ_CAN_RUN_SCRIPT static bool |
254 | | get_baseURI(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitGetterCallArgs args) |
255 | 0 | { |
256 | 0 | AUTO_PROFILER_LABEL_FAST("get Node.baseURI", DOM, cx); |
257 | 0 |
|
258 | 0 | FastErrorResult rv; |
259 | 0 | DOMString result; |
260 | 0 | self->GetBaseURIFromJS(result, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv); |
261 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
262 | 0 | return false; |
263 | 0 | } |
264 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
265 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
266 | 0 | return false; |
267 | 0 | } |
268 | 0 | return true; |
269 | 0 | } |
270 | | |
271 | | static const JSJitInfo baseURI_getterinfo = { |
272 | | { (JSJitGetterOp)get_baseURI }, |
273 | | { prototypes::id::Node }, |
274 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
275 | | JSJitInfo::Getter, |
276 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
277 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
278 | | false, /* isInfallible. False in setters. */ |
279 | | false, /* isMovable. Not relevant for setters. */ |
280 | | false, /* isEliminatable. Not relevant for setters. */ |
281 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
282 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
283 | | false, /* isTypedMethod. Only relevant for methods. */ |
284 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
285 | | }; |
286 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
287 | | static_assert(0 < 1, "There is no slot for us"); |
288 | | |
289 | | MOZ_CAN_RUN_SCRIPT static bool |
290 | | get_isConnected(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitGetterCallArgs args) |
291 | 0 | { |
292 | 0 | AUTO_PROFILER_LABEL_FAST("get Node.isConnected", DOM, cx); |
293 | 0 |
|
294 | 0 | bool result(self->IsInComposedDoc()); |
295 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
296 | 0 | args.rval().setBoolean(result); |
297 | 0 | return true; |
298 | 0 | } |
299 | | |
300 | | static const JSJitInfo isConnected_getterinfo = { |
301 | | { (JSJitGetterOp)get_isConnected }, |
302 | | { prototypes::id::Node }, |
303 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
304 | | JSJitInfo::Getter, |
305 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
306 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
307 | | true, /* isInfallible. False in setters. */ |
308 | | true, /* isMovable. Not relevant for setters. */ |
309 | | true, /* isEliminatable. Not relevant for setters. */ |
310 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
311 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
312 | | false, /* isTypedMethod. Only relevant for methods. */ |
313 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
314 | | }; |
315 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
316 | | static_assert(0 < 1, "There is no slot for us"); |
317 | | |
318 | | MOZ_CAN_RUN_SCRIPT static bool |
319 | | get_ownerDocument(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitGetterCallArgs args) |
320 | 0 | { |
321 | 0 | AUTO_PROFILER_LABEL_FAST("get Node.ownerDocument", DOM, cx); |
322 | 0 |
|
323 | 0 | auto result(StrongOrRawPtr<nsIDocument>(self->GetOwnerDocument())); |
324 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
325 | 0 | if (!result) { |
326 | 0 | args.rval().setNull(); |
327 | 0 | return true; |
328 | 0 | } |
329 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
330 | 0 | MOZ_CRASH("Looks like bug 1488480/1405521, with getting the reflector failing"); |
331 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
332 | 0 | return false; |
333 | 0 | } |
334 | 0 | return true; |
335 | 0 | } |
336 | | |
337 | | static const JSJitInfo ownerDocument_getterinfo = { |
338 | | { (JSJitGetterOp)get_ownerDocument }, |
339 | | { prototypes::id::Node }, |
340 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
341 | | JSJitInfo::Getter, |
342 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
343 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
344 | | false, /* isInfallible. False in setters. */ |
345 | | true, /* isMovable. Not relevant for setters. */ |
346 | | true, /* isEliminatable. Not relevant for setters. */ |
347 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
348 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
349 | | false, /* isTypedMethod. Only relevant for methods. */ |
350 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
351 | | }; |
352 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
353 | | static_assert(0 < 1, "There is no slot for us"); |
354 | | |
355 | | MOZ_CAN_RUN_SCRIPT static bool |
356 | | getRootNode(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, const JSJitMethodCallArgs& args) |
357 | 0 | { |
358 | 0 | AUTO_PROFILER_LABEL_FAST("Node.getRootNode", DOM, cx); |
359 | 0 |
|
360 | 0 | binding_detail::FastGetRootNodeOptions arg0; |
361 | 0 | if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1 of Node.getRootNode", false)) { |
362 | 0 | return false; |
363 | 0 | } |
364 | 0 | auto result(StrongOrRawPtr<nsINode>(self->GetRootNode(Constify(arg0)))); |
365 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
366 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
367 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
368 | 0 | return false; |
369 | 0 | } |
370 | 0 | return true; |
371 | 0 | } |
372 | | |
373 | | static const JSJitInfo::ArgType getRootNode_methodinfo_argTypes[] = { JSJitInfo::Object, JSJitInfo::ArgTypeListEnd }; |
374 | | static const JSTypedMethodJitInfo getRootNode_methodinfo = { |
375 | | { |
376 | | { (JSJitGetterOp)getRootNode }, |
377 | | { prototypes::id::Node }, |
378 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
379 | | JSJitInfo::Method, |
380 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
381 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
382 | | false, /* isInfallible. False in setters. */ |
383 | | true, /* isMovable. Not relevant for setters. */ |
384 | | true, /* isEliminatable. Not relevant for setters. */ |
385 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
386 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
387 | | true, /* isTypedMethod. Only relevant for methods. */ |
388 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
389 | | }, |
390 | | getRootNode_methodinfo_argTypes |
391 | | }; |
392 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
393 | | static_assert(0 < 1, "There is no slot for us"); |
394 | | |
395 | | MOZ_CAN_RUN_SCRIPT static bool |
396 | | get_parentNode(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitGetterCallArgs args) |
397 | 0 | { |
398 | 0 | AUTO_PROFILER_LABEL_FAST("get Node.parentNode", DOM, cx); |
399 | 0 |
|
400 | 0 | auto result(StrongOrRawPtr<nsINode>(self->GetParentNode())); |
401 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
402 | 0 | if (!result) { |
403 | 0 | args.rval().setNull(); |
404 | 0 | return true; |
405 | 0 | } |
406 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
407 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
408 | 0 | return false; |
409 | 0 | } |
410 | 0 | return true; |
411 | 0 | } |
412 | | |
413 | | static const JSJitInfo parentNode_getterinfo = { |
414 | | { (JSJitGetterOp)get_parentNode }, |
415 | | { prototypes::id::Node }, |
416 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
417 | | JSJitInfo::Getter, |
418 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
419 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
420 | | false, /* isInfallible. False in setters. */ |
421 | | true, /* isMovable. Not relevant for setters. */ |
422 | | true, /* isEliminatable. Not relevant for setters. */ |
423 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
424 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
425 | | false, /* isTypedMethod. Only relevant for methods. */ |
426 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
427 | | }; |
428 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
429 | | static_assert(0 < 1, "There is no slot for us"); |
430 | | |
431 | | MOZ_CAN_RUN_SCRIPT static bool |
432 | | get_parentElement(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitGetterCallArgs args) |
433 | 0 | { |
434 | 0 | AUTO_PROFILER_LABEL_FAST("get Node.parentElement", DOM, cx); |
435 | 0 |
|
436 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Element>(self->GetParentElement())); |
437 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
438 | 0 | if (!result) { |
439 | 0 | args.rval().setNull(); |
440 | 0 | return true; |
441 | 0 | } |
442 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
443 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
444 | 0 | return false; |
445 | 0 | } |
446 | 0 | return true; |
447 | 0 | } |
448 | | |
449 | | static const JSJitInfo parentElement_getterinfo = { |
450 | | { (JSJitGetterOp)get_parentElement }, |
451 | | { prototypes::id::Node }, |
452 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
453 | | JSJitInfo::Getter, |
454 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
455 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
456 | | false, /* isInfallible. False in setters. */ |
457 | | true, /* isMovable. Not relevant for setters. */ |
458 | | true, /* isEliminatable. Not relevant for setters. */ |
459 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
460 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
461 | | false, /* isTypedMethod. Only relevant for methods. */ |
462 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
463 | | }; |
464 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
465 | | static_assert(0 < 1, "There is no slot for us"); |
466 | | |
467 | | MOZ_CAN_RUN_SCRIPT static bool |
468 | | hasChildNodes(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, const JSJitMethodCallArgs& args) |
469 | 0 | { |
470 | 0 | AUTO_PROFILER_LABEL_FAST("Node.hasChildNodes", DOM, cx); |
471 | 0 |
|
472 | 0 | bool result(self->HasChildNodes()); |
473 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
474 | 0 | args.rval().setBoolean(result); |
475 | 0 | return true; |
476 | 0 | } |
477 | | |
478 | | static const JSJitInfo::ArgType hasChildNodes_methodinfo_argTypes[] = { JSJitInfo::ArgTypeListEnd }; |
479 | | static const JSTypedMethodJitInfo hasChildNodes_methodinfo = { |
480 | | { |
481 | | { (JSJitGetterOp)hasChildNodes }, |
482 | | { prototypes::id::Node }, |
483 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
484 | | JSJitInfo::Method, |
485 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
486 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
487 | | true, /* isInfallible. False in setters. */ |
488 | | true, /* isMovable. Not relevant for setters. */ |
489 | | true, /* isEliminatable. Not relevant for setters. */ |
490 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
491 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
492 | | true, /* isTypedMethod. Only relevant for methods. */ |
493 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
494 | | }, |
495 | | hasChildNodes_methodinfo_argTypes |
496 | | }; |
497 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
498 | | static_assert(0 < 1, "There is no slot for us"); |
499 | | |
500 | | MOZ_CAN_RUN_SCRIPT static bool |
501 | | get_childNodes(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitGetterCallArgs args) |
502 | 0 | { |
503 | 0 | AUTO_PROFILER_LABEL_FAST("get Node.childNodes", DOM, cx); |
504 | 0 |
|
505 | 0 | auto result(StrongOrRawPtr<nsINodeList>(self->ChildNodes())); |
506 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
507 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
508 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
509 | 0 | return false; |
510 | 0 | } |
511 | 0 | return true; |
512 | 0 | } |
513 | | |
514 | | static const JSJitInfo childNodes_getterinfo = { |
515 | | { (JSJitGetterOp)get_childNodes }, |
516 | | { prototypes::id::Node }, |
517 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
518 | | JSJitInfo::Getter, |
519 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
520 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
521 | | false, /* isInfallible. False in setters. */ |
522 | | true, /* isMovable. Not relevant for setters. */ |
523 | | true, /* isEliminatable. Not relevant for setters. */ |
524 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
525 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
526 | | false, /* isTypedMethod. Only relevant for methods. */ |
527 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
528 | | }; |
529 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
530 | | static_assert(0 < 1, "There is no slot for us"); |
531 | | |
532 | | MOZ_CAN_RUN_SCRIPT static bool |
533 | | get_firstChild(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitGetterCallArgs args) |
534 | 0 | { |
535 | 0 | AUTO_PROFILER_LABEL_FAST("get Node.firstChild", DOM, cx); |
536 | 0 |
|
537 | 0 | auto result(StrongOrRawPtr<nsINode>(self->GetFirstChild())); |
538 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
539 | 0 | if (!result) { |
540 | 0 | args.rval().setNull(); |
541 | 0 | return true; |
542 | 0 | } |
543 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
544 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
545 | 0 | return false; |
546 | 0 | } |
547 | 0 | return true; |
548 | 0 | } |
549 | | |
550 | | static const JSJitInfo firstChild_getterinfo = { |
551 | | { (JSJitGetterOp)get_firstChild }, |
552 | | { prototypes::id::Node }, |
553 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
554 | | JSJitInfo::Getter, |
555 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
556 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
557 | | false, /* isInfallible. False in setters. */ |
558 | | true, /* isMovable. Not relevant for setters. */ |
559 | | true, /* isEliminatable. Not relevant for setters. */ |
560 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
561 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
562 | | false, /* isTypedMethod. Only relevant for methods. */ |
563 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
564 | | }; |
565 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
566 | | static_assert(0 < 1, "There is no slot for us"); |
567 | | |
568 | | MOZ_CAN_RUN_SCRIPT static bool |
569 | | get_lastChild(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitGetterCallArgs args) |
570 | 0 | { |
571 | 0 | AUTO_PROFILER_LABEL_FAST("get Node.lastChild", DOM, cx); |
572 | 0 |
|
573 | 0 | auto result(StrongOrRawPtr<nsINode>(self->GetLastChild())); |
574 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
575 | 0 | if (!result) { |
576 | 0 | args.rval().setNull(); |
577 | 0 | return true; |
578 | 0 | } |
579 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
580 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
581 | 0 | return false; |
582 | 0 | } |
583 | 0 | return true; |
584 | 0 | } |
585 | | |
586 | | static const JSJitInfo lastChild_getterinfo = { |
587 | | { (JSJitGetterOp)get_lastChild }, |
588 | | { prototypes::id::Node }, |
589 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
590 | | JSJitInfo::Getter, |
591 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
592 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
593 | | false, /* isInfallible. False in setters. */ |
594 | | true, /* isMovable. Not relevant for setters. */ |
595 | | true, /* 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 | | get_previousSibling(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitGetterCallArgs args) |
606 | 0 | { |
607 | 0 | AUTO_PROFILER_LABEL_FAST("get Node.previousSibling", DOM, cx); |
608 | 0 |
|
609 | 0 | auto result(StrongOrRawPtr<nsINode>(self->GetPreviousSibling())); |
610 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
611 | 0 | if (!result) { |
612 | 0 | args.rval().setNull(); |
613 | 0 | return true; |
614 | 0 | } |
615 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
616 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
617 | 0 | return false; |
618 | 0 | } |
619 | 0 | return true; |
620 | 0 | } |
621 | | |
622 | | static const JSJitInfo previousSibling_getterinfo = { |
623 | | { (JSJitGetterOp)get_previousSibling }, |
624 | | { prototypes::id::Node }, |
625 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
626 | | JSJitInfo::Getter, |
627 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
628 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
629 | | false, /* isInfallible. False in setters. */ |
630 | | true, /* isMovable. Not relevant for setters. */ |
631 | | true, /* isEliminatable. Not relevant for setters. */ |
632 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
633 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
634 | | false, /* isTypedMethod. Only relevant for methods. */ |
635 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
636 | | }; |
637 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
638 | | static_assert(0 < 1, "There is no slot for us"); |
639 | | |
640 | | MOZ_CAN_RUN_SCRIPT static bool |
641 | | get_nextSibling(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitGetterCallArgs args) |
642 | 0 | { |
643 | 0 | AUTO_PROFILER_LABEL_FAST("get Node.nextSibling", DOM, cx); |
644 | 0 |
|
645 | 0 | auto result(StrongOrRawPtr<nsINode>(self->GetNextSibling())); |
646 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
647 | 0 | if (!result) { |
648 | 0 | args.rval().setNull(); |
649 | 0 | return true; |
650 | 0 | } |
651 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
652 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
653 | 0 | return false; |
654 | 0 | } |
655 | 0 | return true; |
656 | 0 | } |
657 | | |
658 | | static const JSJitInfo nextSibling_getterinfo = { |
659 | | { (JSJitGetterOp)get_nextSibling }, |
660 | | { prototypes::id::Node }, |
661 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
662 | | JSJitInfo::Getter, |
663 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
664 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
665 | | false, /* isInfallible. False in setters. */ |
666 | | true, /* isMovable. Not relevant for setters. */ |
667 | | true, /* isEliminatable. Not relevant for setters. */ |
668 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
669 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
670 | | false, /* isTypedMethod. Only relevant for methods. */ |
671 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
672 | | }; |
673 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
674 | | static_assert(0 < 1, "There is no slot for us"); |
675 | | |
676 | | MOZ_CAN_RUN_SCRIPT static bool |
677 | | get_nodeValue(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitGetterCallArgs args) |
678 | 0 | { |
679 | 0 | AUTO_PROFILER_LABEL_FAST("get Node.nodeValue", DOM, cx); |
680 | 0 |
|
681 | 0 | DOMString result; |
682 | 0 | self->GetNodeValue(result); |
683 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
684 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
685 | 0 | return false; |
686 | 0 | } |
687 | 0 | return true; |
688 | 0 | } |
689 | | |
690 | | MOZ_CAN_RUN_SCRIPT static bool |
691 | | set_nodeValue(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitSetterCallArgs args) |
692 | 0 | { |
693 | 0 | AUTO_PROFILER_LABEL_FAST("set Node.nodeValue", DOM, cx); |
694 | 0 |
|
695 | 0 | binding_detail::FakeString arg0; |
696 | 0 | if (!ConvertJSValueToString(cx, args[0], eNull, eNull, arg0)) { |
697 | 0 | return false; |
698 | 0 | } |
699 | 0 | Maybe<AutoCEReaction> ceReaction; |
700 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
701 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
702 | 0 | if (docGroup) { |
703 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
704 | 0 | } |
705 | 0 | } |
706 | 0 | FastErrorResult rv; |
707 | 0 | self->SetNodeValue(NonNullHelper(Constify(arg0)), rv); |
708 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
709 | 0 | return false; |
710 | 0 | } |
711 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
712 | 0 |
|
713 | 0 | return true; |
714 | 0 | } |
715 | | |
716 | | static const JSJitInfo nodeValue_getterinfo = { |
717 | | { (JSJitGetterOp)get_nodeValue }, |
718 | | { prototypes::id::Node }, |
719 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
720 | | JSJitInfo::Getter, |
721 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
722 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
723 | | false, /* isInfallible. False in setters. */ |
724 | | true, /* isMovable. Not relevant for setters. */ |
725 | | true, /* isEliminatable. Not relevant for setters. */ |
726 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
727 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
728 | | false, /* isTypedMethod. Only relevant for methods. */ |
729 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
730 | | }; |
731 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
732 | | static_assert(0 < 1, "There is no slot for us"); |
733 | | static const JSJitInfo nodeValue_setterinfo = { |
734 | | { (JSJitGetterOp)set_nodeValue }, |
735 | | { prototypes::id::Node }, |
736 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
737 | | JSJitInfo::Setter, |
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 | | get_textContent(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitGetterCallArgs args) |
753 | 0 | { |
754 | 0 | AUTO_PROFILER_LABEL_FAST("get Node.textContent", DOM, cx); |
755 | 0 |
|
756 | 0 | binding_danger::OOMReporterInstantiator rv; |
757 | 0 | DOMString result; |
758 | 0 | self->GetTextContent(result, rv); |
759 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
760 | 0 | return false; |
761 | 0 | } |
762 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
763 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
764 | 0 | return false; |
765 | 0 | } |
766 | 0 | return true; |
767 | 0 | } |
768 | | |
769 | | MOZ_CAN_RUN_SCRIPT static bool |
770 | | set_textContent(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitSetterCallArgs args) |
771 | 0 | { |
772 | 0 | AUTO_PROFILER_LABEL_FAST("set Node.textContent", DOM, cx); |
773 | 0 |
|
774 | 0 | binding_detail::FakeString arg0; |
775 | 0 | if (!ConvertJSValueToString(cx, args[0], eNull, eNull, arg0)) { |
776 | 0 | return false; |
777 | 0 | } |
778 | 0 | Maybe<AutoCEReaction> ceReaction; |
779 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
780 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
781 | 0 | if (docGroup) { |
782 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
783 | 0 | } |
784 | 0 | } |
785 | 0 | FastErrorResult rv; |
786 | 0 | nsIPrincipal* subjectPrincipal; |
787 | 0 | { |
788 | 0 | JS::Realm* realm = js::GetContextRealm(cx); |
789 | 0 | MOZ_ASSERT(realm); |
790 | 0 | JSPrincipals* principals = JS::GetRealmPrincipals(realm); |
791 | 0 | nsIPrincipal* principal = nsJSPrincipals::get(principals); |
792 | 0 | if (nsContentUtils::IsSystemPrincipal(principal)) { |
793 | 0 | principal = nullptr; |
794 | 0 | } |
795 | 0 |
|
796 | 0 | subjectPrincipal = principal; |
797 | 0 | } |
798 | 0 | self->SetTextContent(NonNullHelper(Constify(arg0)), subjectPrincipal, rv); |
799 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
800 | 0 | return false; |
801 | 0 | } |
802 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
803 | 0 |
|
804 | 0 | return true; |
805 | 0 | } |
806 | | |
807 | | static const JSJitInfo textContent_getterinfo = { |
808 | | { (JSJitGetterOp)get_textContent }, |
809 | | { prototypes::id::Node }, |
810 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
811 | | JSJitInfo::Getter, |
812 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
813 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
814 | | false, /* isInfallible. False in setters. */ |
815 | | true, /* isMovable. Not relevant for setters. */ |
816 | | true, /* isEliminatable. Not relevant for setters. */ |
817 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
818 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
819 | | false, /* isTypedMethod. Only relevant for methods. */ |
820 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
821 | | }; |
822 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
823 | | static_assert(0 < 1, "There is no slot for us"); |
824 | | static const JSJitInfo textContent_setterinfo = { |
825 | | { (JSJitGetterOp)set_textContent }, |
826 | | { prototypes::id::Node }, |
827 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
828 | | JSJitInfo::Setter, |
829 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
830 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
831 | | false, /* isInfallible. False in setters. */ |
832 | | false, /* isMovable. Not relevant for setters. */ |
833 | | false, /* isEliminatable. Not relevant for setters. */ |
834 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
835 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
836 | | false, /* isTypedMethod. Only relevant for methods. */ |
837 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
838 | | }; |
839 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
840 | | static_assert(0 < 1, "There is no slot for us"); |
841 | | |
842 | | MOZ_CAN_RUN_SCRIPT static bool |
843 | | insertBefore(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, const JSJitMethodCallArgs& args) |
844 | 0 | { |
845 | 0 | AUTO_PROFILER_LABEL_FAST("Node.insertBefore", DOM, cx); |
846 | 0 |
|
847 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
848 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Node.insertBefore"); |
849 | 0 | } |
850 | 0 | NonNull<nsINode> arg0; |
851 | 0 | if (args[0].isObject()) { |
852 | 0 | { |
853 | 0 | nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0); |
854 | 0 | if (NS_FAILED(rv)) { |
855 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Node.insertBefore", "Node"); |
856 | 0 | return false; |
857 | 0 | } |
858 | 0 | } |
859 | 0 | } else { |
860 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Node.insertBefore"); |
861 | 0 | return false; |
862 | 0 | } |
863 | 0 | nsINode* arg1; |
864 | 0 | if (args[1].isObject()) { |
865 | 0 | { |
866 | 0 | nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[1], arg1); |
867 | 0 | if (NS_FAILED(rv)) { |
868 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of Node.insertBefore", "Node"); |
869 | 0 | return false; |
870 | 0 | } |
871 | 0 | } |
872 | 0 | } else if (args[1].isNullOrUndefined()) { |
873 | 0 | arg1 = nullptr; |
874 | 0 | } else { |
875 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of Node.insertBefore"); |
876 | 0 | return false; |
877 | 0 | } |
878 | 0 | Maybe<AutoCEReaction> ceReaction; |
879 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
880 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
881 | 0 | if (docGroup) { |
882 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
883 | 0 | } |
884 | 0 | } |
885 | 0 | FastErrorResult rv; |
886 | 0 | auto result(StrongOrRawPtr<nsINode>(self->InsertBefore(MOZ_KnownLive(NonNullHelper(arg0)), MOZ_KnownLive(Constify(arg1)), rv))); |
887 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
888 | 0 | return false; |
889 | 0 | } |
890 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
891 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
892 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
893 | 0 | return false; |
894 | 0 | } |
895 | 0 | return true; |
896 | 0 | } |
897 | | |
898 | | static const JSJitInfo insertBefore_methodinfo = { |
899 | | { (JSJitGetterOp)insertBefore }, |
900 | | { prototypes::id::Node }, |
901 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
902 | | JSJitInfo::Method, |
903 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
904 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
905 | | false, /* isInfallible. False in setters. */ |
906 | | false, /* isMovable. Not relevant for setters. */ |
907 | | false, /* isEliminatable. Not relevant for setters. */ |
908 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
909 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
910 | | false, /* isTypedMethod. Only relevant for methods. */ |
911 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
912 | | }; |
913 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
914 | | static_assert(0 < 1, "There is no slot for us"); |
915 | | |
916 | | MOZ_CAN_RUN_SCRIPT static bool |
917 | | appendChild(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, const JSJitMethodCallArgs& args) |
918 | 0 | { |
919 | 0 | AUTO_PROFILER_LABEL_FAST("Node.appendChild", DOM, cx); |
920 | 0 |
|
921 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
922 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Node.appendChild"); |
923 | 0 | } |
924 | 0 | NonNull<nsINode> arg0; |
925 | 0 | if (args[0].isObject()) { |
926 | 0 | { |
927 | 0 | nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0); |
928 | 0 | if (NS_FAILED(rv)) { |
929 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Node.appendChild", "Node"); |
930 | 0 | return false; |
931 | 0 | } |
932 | 0 | } |
933 | 0 | } else { |
934 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Node.appendChild"); |
935 | 0 | return false; |
936 | 0 | } |
937 | 0 | Maybe<AutoCEReaction> ceReaction; |
938 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
939 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
940 | 0 | if (docGroup) { |
941 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
942 | 0 | } |
943 | 0 | } |
944 | 0 | FastErrorResult rv; |
945 | 0 | auto result(StrongOrRawPtr<nsINode>(self->AppendChild(MOZ_KnownLive(NonNullHelper(arg0)), rv))); |
946 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
947 | 0 | return false; |
948 | 0 | } |
949 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
950 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
951 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
952 | 0 | return false; |
953 | 0 | } |
954 | 0 | return true; |
955 | 0 | } |
956 | | |
957 | | static const JSJitInfo appendChild_methodinfo = { |
958 | | { (JSJitGetterOp)appendChild }, |
959 | | { prototypes::id::Node }, |
960 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
961 | | JSJitInfo::Method, |
962 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
963 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
964 | | false, /* isInfallible. False in setters. */ |
965 | | false, /* isMovable. Not relevant for setters. */ |
966 | | false, /* isEliminatable. Not relevant for setters. */ |
967 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
968 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
969 | | false, /* isTypedMethod. Only relevant for methods. */ |
970 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
971 | | }; |
972 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
973 | | static_assert(0 < 1, "There is no slot for us"); |
974 | | |
975 | | MOZ_CAN_RUN_SCRIPT static bool |
976 | | replaceChild(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, const JSJitMethodCallArgs& args) |
977 | 0 | { |
978 | 0 | AUTO_PROFILER_LABEL_FAST("Node.replaceChild", DOM, cx); |
979 | 0 |
|
980 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
981 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Node.replaceChild"); |
982 | 0 | } |
983 | 0 | NonNull<nsINode> arg0; |
984 | 0 | if (args[0].isObject()) { |
985 | 0 | { |
986 | 0 | nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0); |
987 | 0 | if (NS_FAILED(rv)) { |
988 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Node.replaceChild", "Node"); |
989 | 0 | return false; |
990 | 0 | } |
991 | 0 | } |
992 | 0 | } else { |
993 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Node.replaceChild"); |
994 | 0 | return false; |
995 | 0 | } |
996 | 0 | NonNull<nsINode> arg1; |
997 | 0 | if (args[1].isObject()) { |
998 | 0 | { |
999 | 0 | nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[1], arg1); |
1000 | 0 | if (NS_FAILED(rv)) { |
1001 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of Node.replaceChild", "Node"); |
1002 | 0 | return false; |
1003 | 0 | } |
1004 | 0 | } |
1005 | 0 | } else { |
1006 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of Node.replaceChild"); |
1007 | 0 | return false; |
1008 | 0 | } |
1009 | 0 | Maybe<AutoCEReaction> ceReaction; |
1010 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
1011 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
1012 | 0 | if (docGroup) { |
1013 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
1014 | 0 | } |
1015 | 0 | } |
1016 | 0 | FastErrorResult rv; |
1017 | 0 | auto result(StrongOrRawPtr<nsINode>(self->ReplaceChild(MOZ_KnownLive(NonNullHelper(arg0)), MOZ_KnownLive(NonNullHelper(arg1)), rv))); |
1018 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1019 | 0 | return false; |
1020 | 0 | } |
1021 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1022 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
1023 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1024 | 0 | return false; |
1025 | 0 | } |
1026 | 0 | return true; |
1027 | 0 | } |
1028 | | |
1029 | | static const JSJitInfo replaceChild_methodinfo = { |
1030 | | { (JSJitGetterOp)replaceChild }, |
1031 | | { prototypes::id::Node }, |
1032 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
1033 | | JSJitInfo::Method, |
1034 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1035 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1036 | | false, /* isInfallible. False in setters. */ |
1037 | | false, /* isMovable. Not relevant for setters. */ |
1038 | | false, /* isEliminatable. Not relevant for setters. */ |
1039 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1040 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1041 | | false, /* isTypedMethod. Only relevant for methods. */ |
1042 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1043 | | }; |
1044 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1045 | | static_assert(0 < 1, "There is no slot for us"); |
1046 | | |
1047 | | MOZ_CAN_RUN_SCRIPT static bool |
1048 | | removeChild(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, const JSJitMethodCallArgs& args) |
1049 | 0 | { |
1050 | 0 | AUTO_PROFILER_LABEL_FAST("Node.removeChild", DOM, cx); |
1051 | 0 |
|
1052 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1053 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Node.removeChild"); |
1054 | 0 | } |
1055 | 0 | NonNull<nsINode> arg0; |
1056 | 0 | if (args[0].isObject()) { |
1057 | 0 | { |
1058 | 0 | nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0); |
1059 | 0 | if (NS_FAILED(rv)) { |
1060 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Node.removeChild", "Node"); |
1061 | 0 | return false; |
1062 | 0 | } |
1063 | 0 | } |
1064 | 0 | } else { |
1065 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Node.removeChild"); |
1066 | 0 | return false; |
1067 | 0 | } |
1068 | 0 | Maybe<AutoCEReaction> ceReaction; |
1069 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
1070 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
1071 | 0 | if (docGroup) { |
1072 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
1073 | 0 | } |
1074 | 0 | } |
1075 | 0 | FastErrorResult rv; |
1076 | 0 | auto result(StrongOrRawPtr<nsINode>(self->RemoveChild(MOZ_KnownLive(NonNullHelper(arg0)), rv))); |
1077 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1078 | 0 | return false; |
1079 | 0 | } |
1080 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1081 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
1082 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1083 | 0 | return false; |
1084 | 0 | } |
1085 | 0 | return true; |
1086 | 0 | } |
1087 | | |
1088 | | static const JSJitInfo removeChild_methodinfo = { |
1089 | | { (JSJitGetterOp)removeChild }, |
1090 | | { prototypes::id::Node }, |
1091 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
1092 | | JSJitInfo::Method, |
1093 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1094 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1095 | | false, /* isInfallible. False in setters. */ |
1096 | | false, /* isMovable. Not relevant for setters. */ |
1097 | | false, /* isEliminatable. Not relevant for setters. */ |
1098 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1099 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1100 | | false, /* isTypedMethod. Only relevant for methods. */ |
1101 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1102 | | }; |
1103 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1104 | | static_assert(0 < 1, "There is no slot for us"); |
1105 | | |
1106 | | MOZ_CAN_RUN_SCRIPT static bool |
1107 | | normalize(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, const JSJitMethodCallArgs& args) |
1108 | 0 | { |
1109 | 0 | AUTO_PROFILER_LABEL_FAST("Node.normalize", DOM, cx); |
1110 | 0 |
|
1111 | 0 | Maybe<AutoCEReaction> ceReaction; |
1112 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
1113 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
1114 | 0 | if (docGroup) { |
1115 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
1116 | 0 | } |
1117 | 0 | } |
1118 | 0 | self->Normalize(); |
1119 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1120 | 0 | args.rval().setUndefined(); |
1121 | 0 | return true; |
1122 | 0 | } |
1123 | | |
1124 | | static const JSJitInfo normalize_methodinfo = { |
1125 | | { (JSJitGetterOp)normalize }, |
1126 | | { prototypes::id::Node }, |
1127 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
1128 | | JSJitInfo::Method, |
1129 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1130 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1131 | | true, /* isInfallible. False in setters. */ |
1132 | | false, /* isMovable. Not relevant for setters. */ |
1133 | | false, /* isEliminatable. Not relevant for setters. */ |
1134 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1135 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1136 | | false, /* isTypedMethod. Only relevant for methods. */ |
1137 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1138 | | }; |
1139 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1140 | | static_assert(0 < 1, "There is no slot for us"); |
1141 | | |
1142 | | MOZ_CAN_RUN_SCRIPT static bool |
1143 | | cloneNode(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, const JSJitMethodCallArgs& args) |
1144 | 0 | { |
1145 | 0 | AUTO_PROFILER_LABEL_FAST("Node.cloneNode", DOM, cx); |
1146 | 0 |
|
1147 | 0 | bool arg0; |
1148 | 0 | if (args.hasDefined(0)) { |
1149 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) { |
1150 | 0 | return false; |
1151 | 0 | } |
1152 | 0 | } else { |
1153 | 0 | arg0 = false; |
1154 | 0 | } |
1155 | 0 | Maybe<AutoCEReaction> ceReaction; |
1156 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
1157 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
1158 | 0 | if (docGroup) { |
1159 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
1160 | 0 | } |
1161 | 0 | } |
1162 | 0 | FastErrorResult rv; |
1163 | 0 | auto result(StrongOrRawPtr<nsINode>(self->CloneNode(arg0, rv))); |
1164 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1165 | 0 | return false; |
1166 | 0 | } |
1167 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1168 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
1169 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1170 | 0 | return false; |
1171 | 0 | } |
1172 | 0 | return true; |
1173 | 0 | } |
1174 | | |
1175 | | static const JSJitInfo cloneNode_methodinfo = { |
1176 | | { (JSJitGetterOp)cloneNode }, |
1177 | | { prototypes::id::Node }, |
1178 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
1179 | | JSJitInfo::Method, |
1180 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1181 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1182 | | false, /* isInfallible. False in setters. */ |
1183 | | false, /* isMovable. Not relevant for setters. */ |
1184 | | false, /* isEliminatable. Not relevant for setters. */ |
1185 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1186 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1187 | | false, /* isTypedMethod. Only relevant for methods. */ |
1188 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1189 | | }; |
1190 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1191 | | static_assert(0 < 1, "There is no slot for us"); |
1192 | | |
1193 | | MOZ_CAN_RUN_SCRIPT static bool |
1194 | | isSameNode(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, const JSJitMethodCallArgs& args) |
1195 | 0 | { |
1196 | 0 | AUTO_PROFILER_LABEL_FAST("Node.isSameNode", DOM, cx); |
1197 | 0 |
|
1198 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1199 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Node.isSameNode"); |
1200 | 0 | } |
1201 | 0 | nsINode* arg0; |
1202 | 0 | if (args[0].isObject()) { |
1203 | 0 | { |
1204 | 0 | nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0); |
1205 | 0 | if (NS_FAILED(rv)) { |
1206 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Node.isSameNode", "Node"); |
1207 | 0 | return false; |
1208 | 0 | } |
1209 | 0 | } |
1210 | 0 | } else if (args[0].isNullOrUndefined()) { |
1211 | 0 | arg0 = nullptr; |
1212 | 0 | } else { |
1213 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Node.isSameNode"); |
1214 | 0 | return false; |
1215 | 0 | } |
1216 | 0 | bool result(self->IsSameNode(MOZ_KnownLive(Constify(arg0)))); |
1217 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1218 | 0 | args.rval().setBoolean(result); |
1219 | 0 | return true; |
1220 | 0 | } |
1221 | | |
1222 | | static const JSJitInfo::ArgType isSameNode_methodinfo_argTypes[] = { JSJitInfo::ArgType(JSJitInfo::Null | JSJitInfo::Object), JSJitInfo::ArgTypeListEnd }; |
1223 | | static const JSTypedMethodJitInfo isSameNode_methodinfo = { |
1224 | | { |
1225 | | { (JSJitGetterOp)isSameNode }, |
1226 | | { prototypes::id::Node }, |
1227 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
1228 | | JSJitInfo::Method, |
1229 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1230 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
1231 | | false, /* isInfallible. False in setters. */ |
1232 | | true, /* isMovable. Not relevant for setters. */ |
1233 | | true, /* isEliminatable. Not relevant for setters. */ |
1234 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1235 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1236 | | true, /* isTypedMethod. Only relevant for methods. */ |
1237 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1238 | | }, |
1239 | | isSameNode_methodinfo_argTypes |
1240 | | }; |
1241 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1242 | | static_assert(0 < 1, "There is no slot for us"); |
1243 | | |
1244 | | MOZ_CAN_RUN_SCRIPT static bool |
1245 | | isEqualNode(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, const JSJitMethodCallArgs& args) |
1246 | 0 | { |
1247 | 0 | AUTO_PROFILER_LABEL_FAST("Node.isEqualNode", DOM, cx); |
1248 | 0 |
|
1249 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1250 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Node.isEqualNode"); |
1251 | 0 | } |
1252 | 0 | nsINode* arg0; |
1253 | 0 | if (args[0].isObject()) { |
1254 | 0 | { |
1255 | 0 | nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0); |
1256 | 0 | if (NS_FAILED(rv)) { |
1257 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Node.isEqualNode", "Node"); |
1258 | 0 | return false; |
1259 | 0 | } |
1260 | 0 | } |
1261 | 0 | } else if (args[0].isNullOrUndefined()) { |
1262 | 0 | arg0 = nullptr; |
1263 | 0 | } else { |
1264 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Node.isEqualNode"); |
1265 | 0 | return false; |
1266 | 0 | } |
1267 | 0 | bool result(self->IsEqualNode(MOZ_KnownLive(Constify(arg0)))); |
1268 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1269 | 0 | args.rval().setBoolean(result); |
1270 | 0 | return true; |
1271 | 0 | } |
1272 | | |
1273 | | static const JSJitInfo::ArgType isEqualNode_methodinfo_argTypes[] = { JSJitInfo::ArgType(JSJitInfo::Null | JSJitInfo::Object), JSJitInfo::ArgTypeListEnd }; |
1274 | | static const JSTypedMethodJitInfo isEqualNode_methodinfo = { |
1275 | | { |
1276 | | { (JSJitGetterOp)isEqualNode }, |
1277 | | { prototypes::id::Node }, |
1278 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
1279 | | JSJitInfo::Method, |
1280 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1281 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
1282 | | false, /* isInfallible. False in setters. */ |
1283 | | true, /* isMovable. Not relevant for setters. */ |
1284 | | true, /* isEliminatable. Not relevant for setters. */ |
1285 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1286 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1287 | | true, /* isTypedMethod. Only relevant for methods. */ |
1288 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1289 | | }, |
1290 | | isEqualNode_methodinfo_argTypes |
1291 | | }; |
1292 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1293 | | static_assert(0 < 1, "There is no slot for us"); |
1294 | | |
1295 | | MOZ_CAN_RUN_SCRIPT static bool |
1296 | | compareDocumentPosition(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, const JSJitMethodCallArgs& args) |
1297 | 0 | { |
1298 | 0 | AUTO_PROFILER_LABEL_FAST("Node.compareDocumentPosition", DOM, cx); |
1299 | 0 |
|
1300 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1301 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Node.compareDocumentPosition"); |
1302 | 0 | } |
1303 | 0 | NonNull<nsINode> arg0; |
1304 | 0 | if (args[0].isObject()) { |
1305 | 0 | { |
1306 | 0 | nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0); |
1307 | 0 | if (NS_FAILED(rv)) { |
1308 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Node.compareDocumentPosition", "Node"); |
1309 | 0 | return false; |
1310 | 0 | } |
1311 | 0 | } |
1312 | 0 | } else { |
1313 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Node.compareDocumentPosition"); |
1314 | 0 | return false; |
1315 | 0 | } |
1316 | 0 | uint16_t result(self->CompareDocumentPosition(MOZ_KnownLive(NonNullHelper(arg0)))); |
1317 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1318 | 0 | args.rval().setInt32(int32_t(result)); |
1319 | 0 | return true; |
1320 | 0 | } |
1321 | | |
1322 | | static const JSJitInfo::ArgType compareDocumentPosition_methodinfo_argTypes[] = { JSJitInfo::Object, JSJitInfo::ArgTypeListEnd }; |
1323 | | static const JSTypedMethodJitInfo compareDocumentPosition_methodinfo = { |
1324 | | { |
1325 | | { (JSJitGetterOp)compareDocumentPosition }, |
1326 | | { prototypes::id::Node }, |
1327 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
1328 | | JSJitInfo::Method, |
1329 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1330 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
1331 | | false, /* isInfallible. False in setters. */ |
1332 | | true, /* isMovable. Not relevant for setters. */ |
1333 | | true, /* isEliminatable. Not relevant for setters. */ |
1334 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1335 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1336 | | true, /* isTypedMethod. Only relevant for methods. */ |
1337 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1338 | | }, |
1339 | | compareDocumentPosition_methodinfo_argTypes |
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 | | contains(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, const JSJitMethodCallArgs& args) |
1346 | 0 | { |
1347 | 0 | AUTO_PROFILER_LABEL_FAST("Node.contains", DOM, cx); |
1348 | 0 |
|
1349 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1350 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Node.contains"); |
1351 | 0 | } |
1352 | 0 | 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 Node.contains", "Node"); |
1358 | 0 | return false; |
1359 | 0 | } |
1360 | 0 | } |
1361 | 0 | } else if (args[0].isNullOrUndefined()) { |
1362 | 0 | arg0 = nullptr; |
1363 | 0 | } else { |
1364 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Node.contains"); |
1365 | 0 | return false; |
1366 | 0 | } |
1367 | 0 | bool result(self->Contains(MOZ_KnownLive(Constify(arg0)))); |
1368 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1369 | 0 | args.rval().setBoolean(result); |
1370 | 0 | return true; |
1371 | 0 | } |
1372 | | |
1373 | | static const JSJitInfo::ArgType contains_methodinfo_argTypes[] = { JSJitInfo::ArgType(JSJitInfo::Null | JSJitInfo::Object), JSJitInfo::ArgTypeListEnd }; |
1374 | | static const JSTypedMethodJitInfo contains_methodinfo = { |
1375 | | { |
1376 | | { (JSJitGetterOp)contains }, |
1377 | | { prototypes::id::Node }, |
1378 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
1379 | | JSJitInfo::Method, |
1380 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1381 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
1382 | | false, /* isInfallible. False in setters. */ |
1383 | | true, /* isMovable. Not relevant for setters. */ |
1384 | | true, /* isEliminatable. Not relevant for setters. */ |
1385 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1386 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1387 | | true, /* isTypedMethod. Only relevant for methods. */ |
1388 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1389 | | }, |
1390 | | contains_methodinfo_argTypes |
1391 | | }; |
1392 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1393 | | static_assert(0 < 1, "There is no slot for us"); |
1394 | | |
1395 | | MOZ_CAN_RUN_SCRIPT static bool |
1396 | | lookupPrefix(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, const JSJitMethodCallArgs& args) |
1397 | 0 | { |
1398 | 0 | AUTO_PROFILER_LABEL_FAST("Node.lookupPrefix", DOM, cx); |
1399 | 0 |
|
1400 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1401 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Node.lookupPrefix"); |
1402 | 0 | } |
1403 | 0 | binding_detail::FakeString arg0; |
1404 | 0 | if (!ConvertJSValueToString(cx, args[0], eNull, eNull, arg0)) { |
1405 | 0 | return false; |
1406 | 0 | } |
1407 | 0 | DOMString result; |
1408 | 0 | self->LookupPrefix(NonNullHelper(Constify(arg0)), result); |
1409 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1410 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
1411 | 0 | return false; |
1412 | 0 | } |
1413 | 0 | return true; |
1414 | 0 | } |
1415 | | |
1416 | | static const JSJitInfo::ArgType lookupPrefix_methodinfo_argTypes[] = { JSJitInfo::ArgType(JSJitInfo::Null | JSJitInfo::String), JSJitInfo::ArgTypeListEnd }; |
1417 | | static const JSTypedMethodJitInfo lookupPrefix_methodinfo = { |
1418 | | { |
1419 | | { (JSJitGetterOp)lookupPrefix }, |
1420 | | { prototypes::id::Node }, |
1421 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
1422 | | JSJitInfo::Method, |
1423 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1424 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
1425 | | false, /* isInfallible. False in setters. */ |
1426 | | true, /* isMovable. Not relevant for setters. */ |
1427 | | true, /* isEliminatable. Not relevant for setters. */ |
1428 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1429 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1430 | | true, /* isTypedMethod. Only relevant for methods. */ |
1431 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1432 | | }, |
1433 | | lookupPrefix_methodinfo_argTypes |
1434 | | }; |
1435 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1436 | | static_assert(0 < 1, "There is no slot for us"); |
1437 | | |
1438 | | MOZ_CAN_RUN_SCRIPT static bool |
1439 | | lookupNamespaceURI(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, const JSJitMethodCallArgs& args) |
1440 | 0 | { |
1441 | 0 | AUTO_PROFILER_LABEL_FAST("Node.lookupNamespaceURI", DOM, cx); |
1442 | 0 |
|
1443 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1444 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Node.lookupNamespaceURI"); |
1445 | 0 | } |
1446 | 0 | binding_detail::FakeString arg0; |
1447 | 0 | if (!ConvertJSValueToString(cx, args[0], eNull, eNull, arg0)) { |
1448 | 0 | return false; |
1449 | 0 | } |
1450 | 0 | DOMString result; |
1451 | 0 | self->LookupNamespaceURI(NonNullHelper(Constify(arg0)), result); |
1452 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1453 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
1454 | 0 | return false; |
1455 | 0 | } |
1456 | 0 | return true; |
1457 | 0 | } |
1458 | | |
1459 | | static const JSJitInfo::ArgType lookupNamespaceURI_methodinfo_argTypes[] = { JSJitInfo::ArgType(JSJitInfo::Null | JSJitInfo::String), JSJitInfo::ArgTypeListEnd }; |
1460 | | static const JSTypedMethodJitInfo lookupNamespaceURI_methodinfo = { |
1461 | | { |
1462 | | { (JSJitGetterOp)lookupNamespaceURI }, |
1463 | | { prototypes::id::Node }, |
1464 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
1465 | | JSJitInfo::Method, |
1466 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1467 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
1468 | | false, /* isInfallible. False in setters. */ |
1469 | | true, /* isMovable. Not relevant for setters. */ |
1470 | | true, /* isEliminatable. Not relevant for setters. */ |
1471 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1472 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1473 | | true, /* isTypedMethod. Only relevant for methods. */ |
1474 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1475 | | }, |
1476 | | lookupNamespaceURI_methodinfo_argTypes |
1477 | | }; |
1478 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1479 | | static_assert(0 < 1, "There is no slot for us"); |
1480 | | |
1481 | | MOZ_CAN_RUN_SCRIPT static bool |
1482 | | isDefaultNamespace(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, const JSJitMethodCallArgs& args) |
1483 | 0 | { |
1484 | 0 | AUTO_PROFILER_LABEL_FAST("Node.isDefaultNamespace", DOM, cx); |
1485 | 0 |
|
1486 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1487 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Node.isDefaultNamespace"); |
1488 | 0 | } |
1489 | 0 | binding_detail::FakeString arg0; |
1490 | 0 | if (!ConvertJSValueToString(cx, args[0], eNull, eNull, arg0)) { |
1491 | 0 | return false; |
1492 | 0 | } |
1493 | 0 | bool result(self->IsDefaultNamespace(NonNullHelper(Constify(arg0)))); |
1494 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1495 | 0 | args.rval().setBoolean(result); |
1496 | 0 | return true; |
1497 | 0 | } |
1498 | | |
1499 | | static const JSJitInfo::ArgType isDefaultNamespace_methodinfo_argTypes[] = { JSJitInfo::ArgType(JSJitInfo::Null | JSJitInfo::String), JSJitInfo::ArgTypeListEnd }; |
1500 | | static const JSTypedMethodJitInfo isDefaultNamespace_methodinfo = { |
1501 | | { |
1502 | | { (JSJitGetterOp)isDefaultNamespace }, |
1503 | | { prototypes::id::Node }, |
1504 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
1505 | | JSJitInfo::Method, |
1506 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1507 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
1508 | | false, /* isInfallible. False in setters. */ |
1509 | | true, /* isMovable. Not relevant for setters. */ |
1510 | | true, /* isEliminatable. Not relevant for setters. */ |
1511 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1512 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1513 | | true, /* isTypedMethod. Only relevant for methods. */ |
1514 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1515 | | }, |
1516 | | isDefaultNamespace_methodinfo_argTypes |
1517 | | }; |
1518 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1519 | | static_assert(0 < 1, "There is no slot for us"); |
1520 | | |
1521 | | MOZ_CAN_RUN_SCRIPT static bool |
1522 | | get_nodePrincipal(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitGetterCallArgs args) |
1523 | 0 | { |
1524 | 0 | AUTO_PROFILER_LABEL_FAST("get Node.nodePrincipal", DOM, cx); |
1525 | 0 |
|
1526 | 0 | auto result(StrongOrRawPtr<nsIPrincipal>(self->NodePrincipal())); |
1527 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1528 | 0 | if (!WrapObject(cx, result, &NS_GET_IID(nsIPrincipal), args.rval())) { |
1529 | 0 | return false; |
1530 | 0 | } |
1531 | 0 | return true; |
1532 | 0 | } |
1533 | | |
1534 | | static const JSJitInfo nodePrincipal_getterinfo = { |
1535 | | { (JSJitGetterOp)get_nodePrincipal }, |
1536 | | { prototypes::id::Node }, |
1537 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
1538 | | JSJitInfo::Getter, |
1539 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1540 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1541 | | false, /* isInfallible. False in setters. */ |
1542 | | false, /* isMovable. Not relevant for setters. */ |
1543 | | false, /* isEliminatable. Not relevant for setters. */ |
1544 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1545 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1546 | | false, /* isTypedMethod. Only relevant for methods. */ |
1547 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1548 | | }; |
1549 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1550 | | static_assert(0 < 1, "There is no slot for us"); |
1551 | | |
1552 | | MOZ_CAN_RUN_SCRIPT static bool |
1553 | | get_baseURIObject(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitGetterCallArgs args) |
1554 | 0 | { |
1555 | 0 | AUTO_PROFILER_LABEL_FAST("get Node.baseURIObject", DOM, cx); |
1556 | 0 |
|
1557 | 0 | auto result(StrongOrRawPtr<nsIURI>(self->GetBaseURIObject())); |
1558 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1559 | 0 | if (!result) { |
1560 | 0 | args.rval().setNull(); |
1561 | 0 | return true; |
1562 | 0 | } |
1563 | 0 | if (!WrapObject(cx, result, &NS_GET_IID(nsIURI), args.rval())) { |
1564 | 0 | return false; |
1565 | 0 | } |
1566 | 0 | return true; |
1567 | 0 | } |
1568 | | |
1569 | | static const JSJitInfo baseURIObject_getterinfo = { |
1570 | | { (JSJitGetterOp)get_baseURIObject }, |
1571 | | { prototypes::id::Node }, |
1572 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
1573 | | JSJitInfo::Getter, |
1574 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1575 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
1576 | | false, /* isInfallible. False in setters. */ |
1577 | | false, /* isMovable. Not relevant for setters. */ |
1578 | | false, /* isEliminatable. Not relevant for setters. */ |
1579 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1580 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1581 | | false, /* isTypedMethod. Only relevant for methods. */ |
1582 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1583 | | }; |
1584 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1585 | | static_assert(0 < 1, "There is no slot for us"); |
1586 | | |
1587 | | MOZ_CAN_RUN_SCRIPT static bool |
1588 | | generateXPath(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, const JSJitMethodCallArgs& args) |
1589 | 0 | { |
1590 | 0 | AUTO_PROFILER_LABEL_FAST("Node.generateXPath", DOM, cx); |
1591 | 0 |
|
1592 | 0 | DOMString result; |
1593 | 0 | self->GenerateXPath(result); |
1594 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1595 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
1596 | 0 | return false; |
1597 | 0 | } |
1598 | 0 | return true; |
1599 | 0 | } |
1600 | | |
1601 | | static const JSJitInfo generateXPath_methodinfo = { |
1602 | | { (JSJitGetterOp)generateXPath }, |
1603 | | { prototypes::id::Node }, |
1604 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
1605 | | JSJitInfo::Method, |
1606 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1607 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
1608 | | false, /* isInfallible. False in setters. */ |
1609 | | false, /* isMovable. Not relevant for setters. */ |
1610 | | false, /* isEliminatable. Not relevant for setters. */ |
1611 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1612 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1613 | | false, /* isTypedMethod. Only relevant for methods. */ |
1614 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1615 | | }; |
1616 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1617 | | static_assert(0 < 1, "There is no slot for us"); |
1618 | | |
1619 | | MOZ_CAN_RUN_SCRIPT static bool |
1620 | | get_flattenedTreeParentNode(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitGetterCallArgs args) |
1621 | 0 | { |
1622 | 0 | AUTO_PROFILER_LABEL_FAST("get Node.flattenedTreeParentNode", DOM, cx); |
1623 | 0 |
|
1624 | 0 | auto result(StrongOrRawPtr<nsINode>(self->GetFlattenedTreeParentNodeNonInline())); |
1625 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1626 | 0 | if (!result) { |
1627 | 0 | args.rval().setNull(); |
1628 | 0 | return true; |
1629 | 0 | } |
1630 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
1631 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1632 | 0 | return false; |
1633 | 0 | } |
1634 | 0 | return true; |
1635 | 0 | } |
1636 | | |
1637 | | static const JSJitInfo flattenedTreeParentNode_getterinfo = { |
1638 | | { (JSJitGetterOp)get_flattenedTreeParentNode }, |
1639 | | { prototypes::id::Node }, |
1640 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
1641 | | JSJitInfo::Getter, |
1642 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1643 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
1644 | | false, /* isInfallible. False in setters. */ |
1645 | | true, /* isMovable. Not relevant for setters. */ |
1646 | | true, /* isEliminatable. Not relevant for setters. */ |
1647 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1648 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1649 | | false, /* isTypedMethod. Only relevant for methods. */ |
1650 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1651 | | }; |
1652 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1653 | | static_assert(0 < 1, "There is no slot for us"); |
1654 | | |
1655 | | MOZ_CAN_RUN_SCRIPT static bool |
1656 | | localize(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, const JSJitMethodCallArgs& args) |
1657 | 0 | { |
1658 | 0 | AUTO_PROFILER_LABEL_FAST("Node.localize", DOM, cx); |
1659 | 0 |
|
1660 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1661 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Node.localize"); |
1662 | 0 | } |
1663 | 0 | RootedCallback<OwningNonNull<binding_detail::FastL10nCallback>> arg0(cx); |
1664 | 0 | if (args[0].isObject()) { |
1665 | 0 | if (JS::IsCallable(&args[0].toObject())) { |
1666 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
1667 | 0 | arg0 = new binding_detail::FastL10nCallback(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
1668 | 0 | } |
1669 | 0 | } else { |
1670 | 0 | ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 1 of Node.localize"); |
1671 | 0 | return false; |
1672 | 0 | } |
1673 | 0 | } else { |
1674 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Node.localize"); |
1675 | 0 | return false; |
1676 | 0 | } |
1677 | 0 | FastErrorResult rv; |
1678 | 0 | auto result(StrongOrRawPtr<Promise>(self->Localize(cx, NonNullHelper(arg0), rv))); |
1679 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1680 | 0 | return false; |
1681 | 0 | } |
1682 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1683 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
1684 | 0 | return false; |
1685 | 0 | } |
1686 | 0 | return true; |
1687 | 0 | } |
1688 | | |
1689 | | MOZ_CAN_RUN_SCRIPT static bool |
1690 | | localize_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, const JSJitMethodCallArgs& args) |
1691 | 0 | { |
1692 | 0 | bool ok = localize(cx, obj, self, args); |
1693 | 0 | if (ok) { |
1694 | 0 | return true; |
1695 | 0 | } |
1696 | 0 | return ConvertExceptionToPromise(cx, args.rval()); |
1697 | 0 | } |
1698 | | |
1699 | | static const JSJitInfo localize_methodinfo = { |
1700 | | { (JSJitGetterOp)localize_promiseWrapper }, |
1701 | | { prototypes::id::Node }, |
1702 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
1703 | | JSJitInfo::Method, |
1704 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1705 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1706 | | false, /* isInfallible. False in setters. */ |
1707 | | false, /* isMovable. Not relevant for setters. */ |
1708 | | false, /* isEliminatable. Not relevant for setters. */ |
1709 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1710 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1711 | | false, /* isTypedMethod. Only relevant for methods. */ |
1712 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1713 | | }; |
1714 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1715 | | static_assert(0 < 1, "There is no slot for us"); |
1716 | | |
1717 | | MOZ_CAN_RUN_SCRIPT static bool |
1718 | | get_accessibleNode(JSContext* cx, JS::Handle<JSObject*> obj, nsINode* self, JSJitGetterCallArgs args) |
1719 | 0 | { |
1720 | 0 | AUTO_PROFILER_LABEL_FAST("get Node.accessibleNode", DOM, cx); |
1721 | 0 |
|
1722 | 0 | auto result(StrongOrRawPtr<mozilla::dom::AccessibleNode>(self->GetAccessibleNode())); |
1723 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1724 | 0 | if (!result) { |
1725 | 0 | args.rval().setNull(); |
1726 | 0 | return true; |
1727 | 0 | } |
1728 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
1729 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1730 | 0 | return false; |
1731 | 0 | } |
1732 | 0 | return true; |
1733 | 0 | } |
1734 | | |
1735 | | static const JSJitInfo accessibleNode_getterinfo = { |
1736 | | { (JSJitGetterOp)get_accessibleNode }, |
1737 | | { prototypes::id::Node }, |
1738 | | { PrototypeTraits<prototypes::id::Node>::Depth }, |
1739 | | JSJitInfo::Getter, |
1740 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
1741 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
1742 | | false, /* isInfallible. False in setters. */ |
1743 | | true, /* isMovable. Not relevant for setters. */ |
1744 | | true, /* isEliminatable. Not relevant for setters. */ |
1745 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1746 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1747 | | false, /* isTypedMethod. Only relevant for methods. */ |
1748 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1749 | | }; |
1750 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1751 | | static_assert(0 < 1, "There is no slot for us"); |
1752 | | |
1753 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1754 | | #if defined(__clang__) |
1755 | | #pragma clang diagnostic push |
1756 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1757 | | #endif |
1758 | | static const JSFunctionSpec sMethods_specs[] = { |
1759 | | JS_FNSPEC("getRootNode", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getRootNode_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1760 | | JS_FNSPEC("hasChildNodes", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&hasChildNodes_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1761 | | JS_FS_END, |
1762 | | JS_FNSPEC("insertBefore", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&insertBefore_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
1763 | | JS_FNSPEC("appendChild", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&appendChild_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1764 | | JS_FNSPEC("replaceChild", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&replaceChild_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
1765 | | JS_FS_END, |
1766 | | JS_FNSPEC("removeChild", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&removeChild_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1767 | | JS_FNSPEC("normalize", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&normalize_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1768 | | JS_FS_END, |
1769 | | JS_FNSPEC("cloneNode", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&cloneNode_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1770 | | JS_FS_END, |
1771 | | JS_FNSPEC("isSameNode", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&isSameNode_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1772 | | JS_FNSPEC("isEqualNode", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&isEqualNode_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1773 | | JS_FNSPEC("compareDocumentPosition", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&compareDocumentPosition_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1774 | | JS_FNSPEC("contains", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&contains_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1775 | | JS_FNSPEC("lookupPrefix", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&lookupPrefix_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1776 | | JS_FNSPEC("lookupNamespaceURI", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&lookupNamespaceURI_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1777 | | JS_FNSPEC("isDefaultNamespace", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&isDefaultNamespace_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1778 | | JS_FS_END |
1779 | | }; |
1780 | | #if defined(__clang__) |
1781 | | #pragma clang diagnostic pop |
1782 | | #endif |
1783 | | |
1784 | | // Can't be const because the pref-enabled boolean needs to be writable |
1785 | | static PrefableDisablers sMethods_disablers3 = { |
1786 | | true, false, 0, &IsNotUAWidget |
1787 | | }; |
1788 | | |
1789 | | // Can't be const because the pref-enabled boolean needs to be writable |
1790 | | static PrefableDisablers sMethods_disablers10 = { |
1791 | | true, false, 0, &IsNotUAWidget |
1792 | | }; |
1793 | | |
1794 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
1795 | | { nullptr, &sMethods_specs[0] }, |
1796 | | { &sMethods_disablers3, &sMethods_specs[3] }, |
1797 | | { nullptr, &sMethods_specs[7] }, |
1798 | | { &sMethods_disablers10, &sMethods_specs[10] }, |
1799 | | { nullptr, &sMethods_specs[12] }, |
1800 | | { nullptr, nullptr } |
1801 | | }; |
1802 | | |
1803 | | static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1804 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1805 | | static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1806 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1807 | | |
1808 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1809 | | #if defined(__clang__) |
1810 | | #pragma clang diagnostic push |
1811 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1812 | | #endif |
1813 | | static const JSFunctionSpec sChromeMethods_specs[] = { |
1814 | | JS_FNSPEC("generateXPath", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&generateXPath_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1815 | | JS_FNSPEC("localize", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&localize_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1816 | | JS_FS_END |
1817 | | }; |
1818 | | #if defined(__clang__) |
1819 | | #pragma clang diagnostic pop |
1820 | | #endif |
1821 | | |
1822 | | |
1823 | | static const Prefable<const JSFunctionSpec> sChromeMethods[] = { |
1824 | | { nullptr, &sChromeMethods_specs[0] }, |
1825 | | { nullptr, nullptr } |
1826 | | }; |
1827 | | |
1828 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1829 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1830 | | static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1831 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1832 | | |
1833 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1834 | | #if defined(__clang__) |
1835 | | #pragma clang diagnostic push |
1836 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1837 | | #endif |
1838 | | static const JSPropertySpec sAttributes_specs[] = { |
1839 | | { "nodeType", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &nodeType_getterinfo, nullptr, nullptr }, |
1840 | | { "nodeName", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &nodeName_getterinfo, nullptr, nullptr }, |
1841 | | { "baseURI", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &baseURI_getterinfo, nullptr, nullptr }, |
1842 | | { "isConnected", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isConnected_getterinfo, nullptr, nullptr }, |
1843 | | { "ownerDocument", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &ownerDocument_getterinfo, nullptr, nullptr }, |
1844 | | { "parentNode", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &parentNode_getterinfo, nullptr, nullptr }, |
1845 | | { "parentElement", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &parentElement_getterinfo, nullptr, nullptr }, |
1846 | | { "childNodes", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &childNodes_getterinfo, nullptr, nullptr }, |
1847 | | { "firstChild", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &firstChild_getterinfo, nullptr, nullptr }, |
1848 | | { "lastChild", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &lastChild_getterinfo, nullptr, nullptr }, |
1849 | | { "previousSibling", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &previousSibling_getterinfo, nullptr, nullptr }, |
1850 | | { "nextSibling", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &nextSibling_getterinfo, nullptr, nullptr }, |
1851 | | { "nodeValue", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &nodeValue_getterinfo, GenericSetter<NormalThisPolicy>, &nodeValue_setterinfo }, |
1852 | | { "textContent", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &textContent_getterinfo, GenericSetter<NormalThisPolicy>, &textContent_setterinfo }, |
1853 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr }, |
1854 | | { "accessibleNode", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &accessibleNode_getterinfo, nullptr, nullptr }, |
1855 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
1856 | | }; |
1857 | | #if defined(__clang__) |
1858 | | #pragma clang diagnostic pop |
1859 | | #endif |
1860 | | |
1861 | | // Can't be const because the pref-enabled boolean needs to be writable |
1862 | | static PrefableDisablers sAttributes_disablers15 = { |
1863 | | true, false, 0, &mozilla::dom::AccessibleNode::IsAOMEnabled |
1864 | | }; |
1865 | | |
1866 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
1867 | | { nullptr, &sAttributes_specs[0] }, |
1868 | | { &sAttributes_disablers15, &sAttributes_specs[15] }, |
1869 | | { nullptr, nullptr } |
1870 | | }; |
1871 | | |
1872 | | static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1873 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1874 | | static_assert(14 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1875 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1876 | | |
1877 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1878 | | #if defined(__clang__) |
1879 | | #pragma clang diagnostic push |
1880 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1881 | | #endif |
1882 | | static const JSPropertySpec sChromeAttributes_specs[] = { |
1883 | | { "nodePrincipal", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &nodePrincipal_getterinfo, nullptr, nullptr }, |
1884 | | { "baseURIObject", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &baseURIObject_getterinfo, nullptr, nullptr }, |
1885 | | { "flattenedTreeParentNode", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &flattenedTreeParentNode_getterinfo, nullptr, nullptr }, |
1886 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
1887 | | }; |
1888 | | #if defined(__clang__) |
1889 | | #pragma clang diagnostic pop |
1890 | | #endif |
1891 | | |
1892 | | |
1893 | | static const Prefable<const JSPropertySpec> sChromeAttributes[] = { |
1894 | | { nullptr, &sChromeAttributes_specs[0] }, |
1895 | | { nullptr, nullptr } |
1896 | | }; |
1897 | | |
1898 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1899 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1900 | | static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1901 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1902 | | |
1903 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1904 | | #if defined(__clang__) |
1905 | | #pragma clang diagnostic push |
1906 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1907 | | #endif |
1908 | | static const ConstantSpec sConstants_specs[] = { |
1909 | | { "ELEMENT_NODE", JS::Int32Value(1) }, |
1910 | | { "ATTRIBUTE_NODE", JS::Int32Value(2) }, |
1911 | | { "TEXT_NODE", JS::Int32Value(3) }, |
1912 | | { "CDATA_SECTION_NODE", JS::Int32Value(4) }, |
1913 | | { "ENTITY_REFERENCE_NODE", JS::Int32Value(5) }, |
1914 | | { "ENTITY_NODE", JS::Int32Value(6) }, |
1915 | | { "PROCESSING_INSTRUCTION_NODE", JS::Int32Value(7) }, |
1916 | | { "COMMENT_NODE", JS::Int32Value(8) }, |
1917 | | { "DOCUMENT_NODE", JS::Int32Value(9) }, |
1918 | | { "DOCUMENT_TYPE_NODE", JS::Int32Value(10) }, |
1919 | | { "DOCUMENT_FRAGMENT_NODE", JS::Int32Value(11) }, |
1920 | | { "NOTATION_NODE", JS::Int32Value(12) }, |
1921 | | { "DOCUMENT_POSITION_DISCONNECTED", JS::Int32Value(1) }, |
1922 | | { "DOCUMENT_POSITION_PRECEDING", JS::Int32Value(2) }, |
1923 | | { "DOCUMENT_POSITION_FOLLOWING", JS::Int32Value(4) }, |
1924 | | { "DOCUMENT_POSITION_CONTAINS", JS::Int32Value(8) }, |
1925 | | { "DOCUMENT_POSITION_CONTAINED_BY", JS::Int32Value(16) }, |
1926 | | { "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC", JS::Int32Value(32) }, |
1927 | | { 0, JS::UndefinedValue() } |
1928 | | }; |
1929 | | #if defined(__clang__) |
1930 | | #pragma clang diagnostic pop |
1931 | | #endif |
1932 | | |
1933 | | |
1934 | | static const Prefable<const ConstantSpec> sConstants[] = { |
1935 | | { nullptr, &sConstants_specs[0] }, |
1936 | | { nullptr, nullptr } |
1937 | | }; |
1938 | | |
1939 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1940 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1941 | | static_assert(18 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1942 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1943 | | |
1944 | | |
1945 | | static uint16_t sNativeProperties_sortedPropertyIndices[48]; |
1946 | | static PropertyInfo sNativeProperties_propertyInfos[48]; |
1947 | | |
1948 | | static const NativePropertiesN<3> sNativeProperties = { |
1949 | | false, 0, |
1950 | | false, 0, |
1951 | | true, 0 /* sMethods */, |
1952 | | true, 1 /* sAttributes */, |
1953 | | false, 0, |
1954 | | false, 0, |
1955 | | true, 2 /* sConstants */, |
1956 | | -1, |
1957 | | 48, |
1958 | | sNativeProperties_sortedPropertyIndices, |
1959 | | { |
1960 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
1961 | | { sAttributes, &sNativeProperties_propertyInfos[15] }, |
1962 | | { sConstants, &sNativeProperties_propertyInfos[30] } |
1963 | | } |
1964 | | }; |
1965 | | static_assert(48 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
1966 | | "We have a property info count that is oversized"); |
1967 | | |
1968 | | static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[5]; |
1969 | | static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[5]; |
1970 | | |
1971 | | static const NativePropertiesN<2> sChromeOnlyNativeProperties = { |
1972 | | false, 0, |
1973 | | false, 0, |
1974 | | true, 0 /* sChromeMethods */, |
1975 | | true, 1 /* sChromeAttributes */, |
1976 | | false, 0, |
1977 | | false, 0, |
1978 | | false, 0, |
1979 | | -1, |
1980 | | 5, |
1981 | | sChromeOnlyNativeProperties_sortedPropertyIndices, |
1982 | | { |
1983 | | { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }, |
1984 | | { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[2] } |
1985 | | } |
1986 | | }; |
1987 | | static_assert(5 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount), |
1988 | | "We have a property info count that is oversized"); |
1989 | | |
1990 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
1991 | | { |
1992 | | "Function", |
1993 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
1994 | | &sBoringInterfaceObjectClassClassOps, |
1995 | | JS_NULL_CLASS_SPEC, |
1996 | | JS_NULL_CLASS_EXT, |
1997 | | &sInterfaceObjectClassObjectOps |
1998 | | }, |
1999 | | eInterface, |
2000 | | true, |
2001 | | prototypes::id::Node, |
2002 | | PrototypeTraits<prototypes::id::Node>::Depth, |
2003 | | sNativePropertyHooks, |
2004 | | "function Node() {\n [native code]\n}", |
2005 | | EventTarget_Binding::GetConstructorObject |
2006 | | }; |
2007 | | |
2008 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
2009 | | { |
2010 | | "NodePrototype", |
2011 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
2012 | | JS_NULL_CLASS_OPS, |
2013 | | JS_NULL_CLASS_SPEC, |
2014 | | JS_NULL_CLASS_EXT, |
2015 | | JS_NULL_OBJECT_OPS |
2016 | | }, |
2017 | | eInterfacePrototype, |
2018 | | false, |
2019 | | prototypes::id::Node, |
2020 | | PrototypeTraits<prototypes::id::Node>::Depth, |
2021 | | sNativePropertyHooks, |
2022 | | "[object NodePrototype]", |
2023 | | EventTarget_Binding::GetProtoObject |
2024 | | }; |
2025 | | |
2026 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
2027 | | nullptr, |
2028 | | nullptr, |
2029 | | nullptr, |
2030 | | { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() }, |
2031 | | prototypes::id::Node, |
2032 | | constructors::id::Node, |
2033 | | EventTarget_Binding::sNativePropertyHooks, |
2034 | | &DefaultXrayExpandoObjectClass |
2035 | | } }; |
2036 | | |
2037 | | void |
2038 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
2039 | 0 | { |
2040 | 0 | JS::Handle<JSObject*> parentProto(EventTarget_Binding::GetProtoObjectHandle(aCx)); |
2041 | 0 | if (!parentProto) { |
2042 | 0 | return; |
2043 | 0 | } |
2044 | 0 | |
2045 | 0 | JS::Handle<JSObject*> constructorProto(EventTarget_Binding::GetConstructorObjectHandle(aCx)); |
2046 | 0 | if (!constructorProto) { |
2047 | 0 | return; |
2048 | 0 | } |
2049 | 0 | |
2050 | 0 | static bool sIdsInited = false; |
2051 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
2052 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
2053 | 0 | return; |
2054 | 0 | } |
2055 | 0 | if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) { |
2056 | 0 | return; |
2057 | 0 | } |
2058 | 0 | sIdsInited = true; |
2059 | 0 | } |
2060 | 0 |
|
2061 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::Node); |
2062 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::Node); |
2063 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
2064 | 0 | &sPrototypeClass.mBase, protoCache, |
2065 | 0 | nullptr, |
2066 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
2067 | 0 | interfaceCache, |
2068 | 0 | sNativeProperties.Upcast(), |
2069 | 0 | sChromeOnlyNativeProperties.Upcast(), |
2070 | 0 | "Node", aDefineOnGlobal, |
2071 | 0 | nullptr, |
2072 | 0 | false); |
2073 | 0 | } |
2074 | | |
2075 | | JSObject* |
2076 | | GetProtoObject(JSContext* aCx) |
2077 | 0 | { |
2078 | 0 | return GetProtoObjectHandle(aCx); |
2079 | 0 | } |
2080 | | |
2081 | | JSObject* |
2082 | | GetConstructorObject(JSContext* aCx) |
2083 | 0 | { |
2084 | 0 | return GetConstructorObjectHandle(aCx); |
2085 | 0 | } |
2086 | | |
2087 | | } // namespace Node_Binding |
2088 | | |
2089 | | |
2090 | | |
2091 | | } // namespace dom |
2092 | | } // namespace mozilla |