/work/obj-fuzz/dom/bindings/ElementBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM Element.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AnimatableBinding.h" |
4 | | #include "AtomList.h" |
5 | | #include "DOMPointBinding.h" |
6 | | #include "ElementBinding.h" |
7 | | #include "EventHandlerBinding.h" |
8 | | #include "GeometryUtilsBinding.h" |
9 | | #include "KeyframeAnimationOptionsBinding.h" |
10 | | #include "NodeBinding.h" |
11 | | #include "WindowBinding.h" |
12 | | #include "WrapperFactory.h" |
13 | | #include "jsapi.h" |
14 | | #include "mozilla/FloatingPoint.h" |
15 | | #include "mozilla/OwningNonNull.h" |
16 | | #include "mozilla/Preferences.h" |
17 | | #include "mozilla/dom/Animation.h" |
18 | | #include "mozilla/dom/Attr.h" |
19 | | #include "mozilla/dom/BindingUtils.h" |
20 | | #include "mozilla/dom/CustomElementRegistry.h" |
21 | | #include "mozilla/dom/DOMJSClass.h" |
22 | | #include "mozilla/dom/DOMMatrix.h" |
23 | | #include "mozilla/dom/DOMPoint.h" |
24 | | #include "mozilla/dom/DOMQuad.h" |
25 | | #include "mozilla/dom/DOMRect.h" |
26 | | #include "mozilla/dom/DocGroup.h" |
27 | | #include "mozilla/dom/Element.h" |
28 | | #include "mozilla/dom/Flex.h" |
29 | | #include "mozilla/dom/Grid.h" |
30 | | #include "mozilla/dom/HTMLSlotElement.h" |
31 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
32 | | #include "mozilla/dom/Nullable.h" |
33 | | #include "mozilla/dom/PrimitiveConversions.h" |
34 | | #include "mozilla/dom/Promise.h" |
35 | | #include "mozilla/dom/ScriptSettings.h" |
36 | | #include "mozilla/dom/ShadowRoot.h" |
37 | | #include "mozilla/dom/SimpleGlobalObject.h" |
38 | | #include "mozilla/dom/ToJSValue.h" |
39 | | #include "mozilla/dom/UnionConversions.h" |
40 | | #include "mozilla/dom/UnionTypes.h" |
41 | | #include "mozilla/dom/XrayExpandoClass.h" |
42 | | #include "nsContentList.h" |
43 | | #include "nsContentUtils.h" |
44 | | #include "nsDOMAttributeMap.h" |
45 | | #include "nsDOMTokenList.h" |
46 | | #include "nsDocument.h" |
47 | | #include "nsINode.h" |
48 | | #include "nsINodeList.h" |
49 | | #include "nsISupports.h" |
50 | | #include "xpcjsid.h" |
51 | | |
52 | | namespace mozilla { |
53 | | namespace dom { |
54 | | |
55 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
56 | | using namespace mozilla::dom::binding_detail; |
57 | | |
58 | | |
59 | | namespace ScrollLogicalPositionValues { |
60 | | extern const EnumEntry strings[5] = { |
61 | | {"start", 5}, |
62 | | {"center", 6}, |
63 | | {"end", 3}, |
64 | | {"nearest", 7}, |
65 | | { nullptr, 0 } |
66 | | }; |
67 | | } // namespace ScrollLogicalPositionValues |
68 | | |
69 | | bool |
70 | | ToJSValue(JSContext* aCx, ScrollLogicalPosition aArgument, JS::MutableHandle<JS::Value> aValue) |
71 | 0 | { |
72 | 0 | MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(ScrollLogicalPositionValues::strings)); |
73 | 0 | JSString* resultStr = |
74 | 0 | JS_NewStringCopyN(aCx, ScrollLogicalPositionValues::strings[uint32_t(aArgument)].value, |
75 | 0 | ScrollLogicalPositionValues::strings[uint32_t(aArgument)].length); |
76 | 0 | if (!resultStr) { |
77 | 0 | return false; |
78 | 0 | } |
79 | 0 | aValue.setString(resultStr); |
80 | 0 | return true; |
81 | 0 | } |
82 | | |
83 | | |
84 | | |
85 | | ScrollIntoViewOptions::ScrollIntoViewOptions() |
86 | | : ScrollOptions(FastDictionaryInitializer()) |
87 | 0 | { |
88 | 0 | // Safe to pass a null context if we pass a null value |
89 | 0 | Init(nullptr, JS::NullHandleValue); |
90 | 0 | } |
91 | | |
92 | | |
93 | | |
94 | | bool |
95 | | ScrollIntoViewOptions::InitIds(JSContext* cx, ScrollIntoViewOptionsAtoms* atomsCache) |
96 | 0 | { |
97 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
98 | 0 |
|
99 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
100 | 0 | // uninitialized. |
101 | 0 | if (!atomsCache->inline_id.init(cx, "inline") || |
102 | 0 | !atomsCache->block_id.init(cx, "block")) { |
103 | 0 | return false; |
104 | 0 | } |
105 | 0 | return true; |
106 | 0 | } |
107 | | |
108 | | bool |
109 | | ScrollIntoViewOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
110 | 0 | { |
111 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
112 | 0 | // Since in that case we will not have to do any property gets |
113 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
114 | 0 | // checkers by static analysis tools |
115 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
116 | 0 | ScrollIntoViewOptionsAtoms* atomsCache = nullptr; |
117 | 0 | if (cx) { |
118 | 0 | atomsCache = GetAtomCache<ScrollIntoViewOptionsAtoms>(cx); |
119 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
120 | 0 | return false; |
121 | 0 | } |
122 | 0 | } |
123 | 0 | |
124 | 0 | // Per spec, we init the parent's members first |
125 | 0 | if (!ScrollOptions::Init(cx, val)) { |
126 | 0 | return false; |
127 | 0 | } |
128 | 0 | |
129 | 0 | bool isNull = val.isNullOrUndefined(); |
130 | 0 | // We only need these if !isNull, in which case we have |cx|. |
131 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
132 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
133 | 0 | if (!isNull) { |
134 | 0 | MOZ_ASSERT(cx); |
135 | 0 | object.emplace(cx, &val.toObject()); |
136 | 0 | temp.emplace(cx); |
137 | 0 | } |
138 | 0 | if (!isNull) { |
139 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->block_id, temp.ptr())) { |
140 | 0 | return false; |
141 | 0 | } |
142 | 0 | } |
143 | 0 | if (!isNull && !temp->isUndefined()) { |
144 | 0 | { |
145 | 0 | int index; |
146 | 0 | if (!FindEnumStringIndex<true>(cx, temp.ref(), ScrollLogicalPositionValues::strings, "ScrollLogicalPosition", "'block' member of ScrollIntoViewOptions", &index)) { |
147 | 0 | return false; |
148 | 0 | } |
149 | 0 | MOZ_ASSERT(index >= 0); |
150 | 0 | mBlock = static_cast<ScrollLogicalPosition>(index); |
151 | 0 | } |
152 | 0 | } else { |
153 | 0 | mBlock = ScrollLogicalPosition::Start; |
154 | 0 | } |
155 | 0 | mIsAnyMemberPresent = true; |
156 | 0 |
|
157 | 0 | if (!isNull) { |
158 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->inline_id, temp.ptr())) { |
159 | 0 | return false; |
160 | 0 | } |
161 | 0 | } |
162 | 0 | if (!isNull && !temp->isUndefined()) { |
163 | 0 | { |
164 | 0 | int index; |
165 | 0 | if (!FindEnumStringIndex<true>(cx, temp.ref(), ScrollLogicalPositionValues::strings, "ScrollLogicalPosition", "'inline' member of ScrollIntoViewOptions", &index)) { |
166 | 0 | return false; |
167 | 0 | } |
168 | 0 | MOZ_ASSERT(index >= 0); |
169 | 0 | mInline = static_cast<ScrollLogicalPosition>(index); |
170 | 0 | } |
171 | 0 | } else { |
172 | 0 | mInline = ScrollLogicalPosition::Nearest; |
173 | 0 | } |
174 | 0 | mIsAnyMemberPresent = true; |
175 | 0 | return true; |
176 | 0 | } |
177 | | |
178 | | bool |
179 | | ScrollIntoViewOptions::Init(const nsAString& aJSON) |
180 | 0 | { |
181 | 0 | AutoJSAPI jsapi; |
182 | 0 | JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail); |
183 | 0 | if (!cleanGlobal) { |
184 | 0 | return false; |
185 | 0 | } |
186 | 0 | if (!jsapi.Init(cleanGlobal)) { |
187 | 0 | return false; |
188 | 0 | } |
189 | 0 | JSContext* cx = jsapi.cx(); |
190 | 0 | JS::Rooted<JS::Value> json(cx); |
191 | 0 | bool ok = ParseJSON(cx, aJSON, &json); |
192 | 0 | NS_ENSURE_TRUE(ok, false); |
193 | 0 | return Init(cx, json); |
194 | 0 | } |
195 | | |
196 | | bool |
197 | | ScrollIntoViewOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
198 | 0 | { |
199 | 0 | ScrollIntoViewOptionsAtoms* atomsCache = GetAtomCache<ScrollIntoViewOptionsAtoms>(cx); |
200 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
201 | 0 | return false; |
202 | 0 | } |
203 | 0 | |
204 | 0 | // Per spec, we define the parent's members first |
205 | 0 | if (!ScrollOptions::ToObjectInternal(cx, rval)) { |
206 | 0 | return false; |
207 | 0 | } |
208 | 0 | JS::Rooted<JSObject*> obj(cx, &rval.toObject()); |
209 | 0 |
|
210 | 0 | do { |
211 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
212 | 0 | JS::Rooted<JS::Value> temp(cx); |
213 | 0 | ScrollLogicalPosition const & currentValue = mBlock; |
214 | 0 | if (!ToJSValue(cx, currentValue, &temp)) { |
215 | 0 | return false; |
216 | 0 | } |
217 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->block_id, temp, JSPROP_ENUMERATE)) { |
218 | 0 | return false; |
219 | 0 | } |
220 | 0 | break; |
221 | 0 | } while(false); |
222 | 0 |
|
223 | 0 | do { |
224 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
225 | 0 | JS::Rooted<JS::Value> temp(cx); |
226 | 0 | ScrollLogicalPosition const & currentValue = mInline; |
227 | 0 | if (!ToJSValue(cx, currentValue, &temp)) { |
228 | 0 | return false; |
229 | 0 | } |
230 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->inline_id, temp, JSPROP_ENUMERATE)) { |
231 | 0 | return false; |
232 | 0 | } |
233 | 0 | break; |
234 | 0 | } while(false); |
235 | 0 |
|
236 | 0 | return true; |
237 | 0 | } |
238 | | |
239 | | bool |
240 | | ScrollIntoViewOptions::ToJSON(nsAString& aJSON) const |
241 | 0 | { |
242 | 0 | AutoJSAPI jsapi; |
243 | 0 | jsapi.Init(); |
244 | 0 | JSContext *cx = jsapi.cx(); |
245 | 0 | // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here |
246 | 0 | // because we'll only be creating objects, in ways that have no |
247 | 0 | // side-effects, followed by a call to JS::ToJSONMaybeSafely, |
248 | 0 | // which likewise guarantees no side-effects for the sorts of |
249 | 0 | // things we will pass it. |
250 | 0 | JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal()); |
251 | 0 | JS::Rooted<JS::Value> val(cx); |
252 | 0 | if (!ToObjectInternal(cx, &val)) { |
253 | 0 | return false; |
254 | 0 | } |
255 | 0 | JS::Rooted<JSObject*> obj(cx, &val.toObject()); |
256 | 0 | return StringifyToJSON(cx, obj, aJSON); |
257 | 0 | } |
258 | | |
259 | | void |
260 | | ScrollIntoViewOptions::TraceDictionary(JSTracer* trc) |
261 | 0 | { |
262 | 0 | ScrollOptions::TraceDictionary(trc); |
263 | 0 | } |
264 | | |
265 | | ScrollIntoViewOptions& |
266 | | ScrollIntoViewOptions::operator=(const ScrollIntoViewOptions& aOther) |
267 | 0 | { |
268 | 0 | ScrollOptions::operator=(aOther); |
269 | 0 | mBlock = aOther.mBlock; |
270 | 0 | mInline = aOther.mInline; |
271 | 0 | return *this; |
272 | 0 | } |
273 | | |
274 | | namespace binding_detail { |
275 | | } // namespace binding_detail |
276 | | |
277 | | |
278 | | |
279 | | ShadowRootInit::ShadowRootInit() |
280 | 0 | { |
281 | 0 | // Safe to pass a null context if we pass a null value |
282 | 0 | Init(nullptr, JS::NullHandleValue); |
283 | 0 | } |
284 | | |
285 | | |
286 | | |
287 | | bool |
288 | | ShadowRootInit::InitIds(JSContext* cx, ShadowRootInitAtoms* atomsCache) |
289 | 0 | { |
290 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
291 | 0 |
|
292 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
293 | 0 | // uninitialized. |
294 | 0 | if (!atomsCache->mode_id.init(cx, "mode")) { |
295 | 0 | return false; |
296 | 0 | } |
297 | 0 | return true; |
298 | 0 | } |
299 | | |
300 | | bool |
301 | | ShadowRootInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
302 | 0 | { |
303 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
304 | 0 | // Since in that case we will not have to do any property gets |
305 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
306 | 0 | // checkers by static analysis tools |
307 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
308 | 0 | ShadowRootInitAtoms* atomsCache = nullptr; |
309 | 0 | if (cx) { |
310 | 0 | atomsCache = GetAtomCache<ShadowRootInitAtoms>(cx); |
311 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
312 | 0 | return false; |
313 | 0 | } |
314 | 0 | } |
315 | 0 | |
316 | 0 | if (!IsConvertibleToDictionary(val)) { |
317 | 0 | return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription); |
318 | 0 | } |
319 | 0 | |
320 | 0 | bool isNull = val.isNullOrUndefined(); |
321 | 0 | // We only need these if !isNull, in which case we have |cx|. |
322 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
323 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
324 | 0 | if (!isNull) { |
325 | 0 | MOZ_ASSERT(cx); |
326 | 0 | object.emplace(cx, &val.toObject()); |
327 | 0 | temp.emplace(cx); |
328 | 0 | } |
329 | 0 | if (!isNull) { |
330 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->mode_id, temp.ptr())) { |
331 | 0 | return false; |
332 | 0 | } |
333 | 0 | } |
334 | 0 | if (!isNull && !temp->isUndefined()) { |
335 | 0 | { |
336 | 0 | int index; |
337 | 0 | if (!FindEnumStringIndex<true>(cx, temp.ref(), ShadowRootModeValues::strings, "ShadowRootMode", "'mode' member of ShadowRootInit", &index)) { |
338 | 0 | return false; |
339 | 0 | } |
340 | 0 | MOZ_ASSERT(index >= 0); |
341 | 0 | mMode = static_cast<ShadowRootMode>(index); |
342 | 0 | } |
343 | 0 | mIsAnyMemberPresent = true; |
344 | 0 | } else if (cx) { |
345 | 0 | // Don't error out if we have no cx. In that |
346 | 0 | // situation the caller is default-constructing us and we'll |
347 | 0 | // just assume they know what they're doing. |
348 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER, |
349 | 0 | "'mode' member of ShadowRootInit"); |
350 | 0 | } |
351 | 0 | return true; |
352 | 0 | } |
353 | | |
354 | | bool |
355 | | ShadowRootInit::Init(const nsAString& aJSON) |
356 | 0 | { |
357 | 0 | AutoJSAPI jsapi; |
358 | 0 | JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail); |
359 | 0 | if (!cleanGlobal) { |
360 | 0 | return false; |
361 | 0 | } |
362 | 0 | if (!jsapi.Init(cleanGlobal)) { |
363 | 0 | return false; |
364 | 0 | } |
365 | 0 | JSContext* cx = jsapi.cx(); |
366 | 0 | JS::Rooted<JS::Value> json(cx); |
367 | 0 | bool ok = ParseJSON(cx, aJSON, &json); |
368 | 0 | NS_ENSURE_TRUE(ok, false); |
369 | 0 | return Init(cx, json); |
370 | 0 | } |
371 | | |
372 | | bool |
373 | | ShadowRootInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
374 | 0 | { |
375 | 0 | ShadowRootInitAtoms* atomsCache = GetAtomCache<ShadowRootInitAtoms>(cx); |
376 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
377 | 0 | return false; |
378 | 0 | } |
379 | 0 | |
380 | 0 | JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx)); |
381 | 0 | if (!obj) { |
382 | 0 | return false; |
383 | 0 | } |
384 | 0 | rval.set(JS::ObjectValue(*obj)); |
385 | 0 |
|
386 | 0 | do { |
387 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
388 | 0 | JS::Rooted<JS::Value> temp(cx); |
389 | 0 | ShadowRootMode const & currentValue = mMode; |
390 | 0 | if (!ToJSValue(cx, currentValue, &temp)) { |
391 | 0 | return false; |
392 | 0 | } |
393 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->mode_id, temp, JSPROP_ENUMERATE)) { |
394 | 0 | return false; |
395 | 0 | } |
396 | 0 | break; |
397 | 0 | } while(false); |
398 | 0 |
|
399 | 0 | return true; |
400 | 0 | } |
401 | | |
402 | | bool |
403 | | ShadowRootInit::ToJSON(nsAString& aJSON) const |
404 | 0 | { |
405 | 0 | AutoJSAPI jsapi; |
406 | 0 | jsapi.Init(); |
407 | 0 | JSContext *cx = jsapi.cx(); |
408 | 0 | // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here |
409 | 0 | // because we'll only be creating objects, in ways that have no |
410 | 0 | // side-effects, followed by a call to JS::ToJSONMaybeSafely, |
411 | 0 | // which likewise guarantees no side-effects for the sorts of |
412 | 0 | // things we will pass it. |
413 | 0 | JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal()); |
414 | 0 | JS::Rooted<JS::Value> val(cx); |
415 | 0 | if (!ToObjectInternal(cx, &val)) { |
416 | 0 | return false; |
417 | 0 | } |
418 | 0 | JS::Rooted<JSObject*> obj(cx, &val.toObject()); |
419 | 0 | return StringifyToJSON(cx, obj, aJSON); |
420 | 0 | } |
421 | | |
422 | | void |
423 | | ShadowRootInit::TraceDictionary(JSTracer* trc) |
424 | 0 | { |
425 | 0 | } |
426 | | |
427 | | ShadowRootInit& |
428 | | ShadowRootInit::operator=(const ShadowRootInit& aOther) |
429 | 0 | { |
430 | 0 | DictionaryBase::operator=(aOther); |
431 | 0 | mMode = aOther.mMode; |
432 | 0 | return *this; |
433 | 0 | } |
434 | | |
435 | | namespace binding_detail { |
436 | | } // namespace binding_detail |
437 | | |
438 | | |
439 | | bool |
440 | | BooleanOrScrollIntoViewOptions::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const |
441 | 0 | { |
442 | 0 | switch (mType) { |
443 | 0 | case eUninitialized: { |
444 | 0 | return false; |
445 | 0 | break; |
446 | 0 | } |
447 | 0 | case eBoolean: { |
448 | 0 | rval.setBoolean(mValue.mBoolean.Value()); |
449 | 0 | return true; |
450 | 0 | break; |
451 | 0 | } |
452 | 0 | case eScrollIntoViewOptions: { |
453 | 0 | if (!mValue.mScrollIntoViewOptions.Value().ToObjectInternal(cx, rval)) { |
454 | 0 | return false; |
455 | 0 | } |
456 | 0 | return true; |
457 | 0 | break; |
458 | 0 | } |
459 | 0 | default: { |
460 | 0 | return false; |
461 | 0 | break; |
462 | 0 | } |
463 | 0 | } |
464 | 0 | |
465 | 0 | return false; |
466 | 0 | } |
467 | | |
468 | | |
469 | | bool& |
470 | | OwningBooleanOrScrollIntoViewOptions::RawSetAsBoolean() |
471 | 0 | { |
472 | 0 | if (mType == eBoolean) { |
473 | 0 | return mValue.mBoolean.Value(); |
474 | 0 | } |
475 | 0 | MOZ_ASSERT(mType == eUninitialized); |
476 | 0 | mType = eBoolean; |
477 | 0 | return mValue.mBoolean.SetValue(); |
478 | 0 | } |
479 | | |
480 | | bool& |
481 | | OwningBooleanOrScrollIntoViewOptions::SetAsBoolean() |
482 | 0 | { |
483 | 0 | if (mType == eBoolean) { |
484 | 0 | return mValue.mBoolean.Value(); |
485 | 0 | } |
486 | 0 | Uninit(); |
487 | 0 | mType = eBoolean; |
488 | 0 | return mValue.mBoolean.SetValue(); |
489 | 0 | } |
490 | | |
491 | | bool |
492 | | OwningBooleanOrScrollIntoViewOptions::TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl) |
493 | 0 | { |
494 | 0 | tryNext = false; |
495 | 0 | { // scope for memberSlot |
496 | 0 | bool& memberSlot = RawSetAsBoolean(); |
497 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, value, &memberSlot)) { |
498 | 0 | return false; |
499 | 0 | } |
500 | 0 | } |
501 | 0 | return true; |
502 | 0 | } |
503 | | |
504 | | void |
505 | | OwningBooleanOrScrollIntoViewOptions::DestroyBoolean() |
506 | 0 | { |
507 | 0 | MOZ_ASSERT(IsBoolean(), "Wrong type!"); |
508 | 0 | mValue.mBoolean.Destroy(); |
509 | 0 | mType = eUninitialized; |
510 | 0 | } |
511 | | |
512 | | |
513 | | |
514 | | |
515 | | ScrollIntoViewOptions& |
516 | | OwningBooleanOrScrollIntoViewOptions::RawSetAsScrollIntoViewOptions() |
517 | 0 | { |
518 | 0 | if (mType == eScrollIntoViewOptions) { |
519 | 0 | return mValue.mScrollIntoViewOptions.Value(); |
520 | 0 | } |
521 | 0 | MOZ_ASSERT(mType == eUninitialized); |
522 | 0 | mType = eScrollIntoViewOptions; |
523 | 0 | return mValue.mScrollIntoViewOptions.SetValue(); |
524 | 0 | } |
525 | | |
526 | | ScrollIntoViewOptions& |
527 | | OwningBooleanOrScrollIntoViewOptions::SetAsScrollIntoViewOptions() |
528 | 0 | { |
529 | 0 | if (mType == eScrollIntoViewOptions) { |
530 | 0 | return mValue.mScrollIntoViewOptions.Value(); |
531 | 0 | } |
532 | 0 | Uninit(); |
533 | 0 | mType = eScrollIntoViewOptions; |
534 | 0 | return mValue.mScrollIntoViewOptions.SetValue(); |
535 | 0 | } |
536 | | |
537 | | bool |
538 | | OwningBooleanOrScrollIntoViewOptions::TrySetToScrollIntoViewOptions(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl) |
539 | 0 | { |
540 | 0 | tryNext = false; |
541 | 0 | { // scope for memberSlot |
542 | 0 | ScrollIntoViewOptions& memberSlot = RawSetAsScrollIntoViewOptions(); |
543 | 0 | if (!IsConvertibleToDictionary(value)) { |
544 | 0 | DestroyScrollIntoViewOptions(); |
545 | 0 | tryNext = true; |
546 | 0 | return true; |
547 | 0 | } |
548 | 0 | if (!memberSlot.Init(cx, value, "Member of BooleanOrScrollIntoViewOptions", passedToJSImpl)) { |
549 | 0 | return false; |
550 | 0 | } |
551 | 0 | } |
552 | 0 | return true; |
553 | 0 | } |
554 | | |
555 | | void |
556 | | OwningBooleanOrScrollIntoViewOptions::DestroyScrollIntoViewOptions() |
557 | 0 | { |
558 | 0 | MOZ_ASSERT(IsScrollIntoViewOptions(), "Wrong type!"); |
559 | 0 | mValue.mScrollIntoViewOptions.Destroy(); |
560 | 0 | mType = eUninitialized; |
561 | 0 | } |
562 | | |
563 | | |
564 | | |
565 | | |
566 | | void |
567 | | OwningBooleanOrScrollIntoViewOptions::Uninit() |
568 | | { |
569 | | switch (mType) { |
570 | | case eUninitialized: { |
571 | | break; |
572 | | } |
573 | | case eBoolean: { |
574 | | DestroyBoolean(); |
575 | | break; |
576 | | } |
577 | | case eScrollIntoViewOptions: { |
578 | | DestroyScrollIntoViewOptions(); |
579 | | break; |
580 | | } |
581 | | } |
582 | | } |
583 | | |
584 | | bool |
585 | | OwningBooleanOrScrollIntoViewOptions::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const |
586 | 0 | { |
587 | 0 | switch (mType) { |
588 | 0 | case eUninitialized: { |
589 | 0 | return false; |
590 | 0 | break; |
591 | 0 | } |
592 | 0 | case eBoolean: { |
593 | 0 | rval.setBoolean(mValue.mBoolean.Value()); |
594 | 0 | return true; |
595 | 0 | break; |
596 | 0 | } |
597 | 0 | case eScrollIntoViewOptions: { |
598 | 0 | if (!mValue.mScrollIntoViewOptions.Value().ToObjectInternal(cx, rval)) { |
599 | 0 | return false; |
600 | 0 | } |
601 | 0 | return true; |
602 | 0 | break; |
603 | 0 | } |
604 | 0 | default: { |
605 | 0 | return false; |
606 | 0 | break; |
607 | 0 | } |
608 | 0 | } |
609 | 0 | |
610 | 0 | return false; |
611 | 0 | } |
612 | | |
613 | | void |
614 | | OwningBooleanOrScrollIntoViewOptions::TraceUnion(JSTracer* trc) |
615 | 0 | { |
616 | 0 | } |
617 | | |
618 | | OwningBooleanOrScrollIntoViewOptions& |
619 | | OwningBooleanOrScrollIntoViewOptions::operator=(const OwningBooleanOrScrollIntoViewOptions& aOther) |
620 | 0 | { |
621 | 0 | switch (aOther.mType) { |
622 | 0 | case eUninitialized: { |
623 | 0 | MOZ_ASSERT(mType == eUninitialized, |
624 | 0 | "We need to destroy ourselves?"); |
625 | 0 | break; |
626 | 0 | } |
627 | 0 | case eBoolean: { |
628 | 0 | SetAsBoolean() = aOther.GetAsBoolean(); |
629 | 0 | break; |
630 | 0 | } |
631 | 0 | case eScrollIntoViewOptions: { |
632 | 0 | SetAsScrollIntoViewOptions() = aOther.GetAsScrollIntoViewOptions(); |
633 | 0 | break; |
634 | 0 | } |
635 | 0 | } |
636 | 0 | return *this; |
637 | 0 | } |
638 | | |
639 | | |
640 | | namespace Element_Binding { |
641 | | |
642 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<Node_Binding::NativeType>::value, |
643 | | "Can't inherit from an interface with a different ownership model."); |
644 | | |
645 | | MOZ_CAN_RUN_SCRIPT static bool |
646 | | get_namespaceURI(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
647 | 0 | { |
648 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.namespaceURI", DOM, cx); |
649 | 0 |
|
650 | 0 | DOMString result; |
651 | 0 | self->GetNamespaceURI(result); |
652 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
653 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
654 | 0 | return false; |
655 | 0 | } |
656 | 0 | return true; |
657 | 0 | } |
658 | | |
659 | | static const JSJitInfo namespaceURI_getterinfo = { |
660 | | { (JSJitGetterOp)get_namespaceURI }, |
661 | | { prototypes::id::Element }, |
662 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
663 | | JSJitInfo::Getter, |
664 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
665 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
666 | | false, /* isInfallible. False in setters. */ |
667 | | true, /* isMovable. Not relevant for setters. */ |
668 | | true, /* isEliminatable. Not relevant for setters. */ |
669 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
670 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
671 | | false, /* isTypedMethod. Only relevant for methods. */ |
672 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
673 | | }; |
674 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
675 | | static_assert(0 < 1, "There is no slot for us"); |
676 | | |
677 | | MOZ_CAN_RUN_SCRIPT static bool |
678 | | get_prefix(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
679 | 0 | { |
680 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.prefix", DOM, cx); |
681 | 0 |
|
682 | 0 | DOMString result; |
683 | 0 | self->GetPrefix(result); |
684 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
685 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
686 | 0 | return false; |
687 | 0 | } |
688 | 0 | return true; |
689 | 0 | } |
690 | | |
691 | | static const JSJitInfo prefix_getterinfo = { |
692 | | { (JSJitGetterOp)get_prefix }, |
693 | | { prototypes::id::Element }, |
694 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
695 | | JSJitInfo::Getter, |
696 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
697 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
698 | | false, /* isInfallible. False in setters. */ |
699 | | true, /* isMovable. Not relevant for setters. */ |
700 | | true, /* isEliminatable. Not relevant for setters. */ |
701 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
702 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
703 | | false, /* isTypedMethod. Only relevant for methods. */ |
704 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
705 | | }; |
706 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
707 | | static_assert(0 < 1, "There is no slot for us"); |
708 | | |
709 | | MOZ_CAN_RUN_SCRIPT static bool |
710 | | get_localName(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
711 | 0 | { |
712 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.localName", DOM, cx); |
713 | 0 |
|
714 | 0 | DOMString result; |
715 | 0 | self->GetLocalName(result); |
716 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
717 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
718 | 0 | return false; |
719 | 0 | } |
720 | 0 | return true; |
721 | 0 | } |
722 | | |
723 | | static const JSJitInfo localName_getterinfo = { |
724 | | { (JSJitGetterOp)get_localName }, |
725 | | { prototypes::id::Element }, |
726 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
727 | | JSJitInfo::Getter, |
728 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
729 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
730 | | false, /* isInfallible. False in setters. */ |
731 | | true, /* isMovable. Not relevant for setters. */ |
732 | | true, /* isEliminatable. Not relevant for setters. */ |
733 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
734 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
735 | | false, /* isTypedMethod. Only relevant for methods. */ |
736 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
737 | | }; |
738 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
739 | | static_assert(0 < 1, "There is no slot for us"); |
740 | | |
741 | | MOZ_CAN_RUN_SCRIPT static bool |
742 | | get_tagName(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
743 | 0 | { |
744 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.tagName", DOM, cx); |
745 | 0 |
|
746 | 0 | DOMString result; |
747 | 0 | self->GetTagName(result); |
748 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
749 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
750 | 0 | return false; |
751 | 0 | } |
752 | 0 | return true; |
753 | 0 | } |
754 | | |
755 | | static const JSJitInfo tagName_getterinfo = { |
756 | | { (JSJitGetterOp)get_tagName }, |
757 | | { prototypes::id::Element }, |
758 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
759 | | JSJitInfo::Getter, |
760 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
761 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
762 | | false, /* isInfallible. False in setters. */ |
763 | | true, /* isMovable. Not relevant for setters. */ |
764 | | true, /* isEliminatable. Not relevant for setters. */ |
765 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
766 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
767 | | false, /* isTypedMethod. Only relevant for methods. */ |
768 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
769 | | }; |
770 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
771 | | static_assert(0 < 1, "There is no slot for us"); |
772 | | |
773 | | MOZ_CAN_RUN_SCRIPT static bool |
774 | | get_id(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
775 | 0 | { |
776 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.id", DOM, cx); |
777 | 0 |
|
778 | 0 | DOMString result; |
779 | 0 | self->GetId(result); |
780 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
781 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
782 | 0 | return false; |
783 | 0 | } |
784 | 0 | return true; |
785 | 0 | } |
786 | | |
787 | | MOZ_CAN_RUN_SCRIPT static bool |
788 | | set_id(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitSetterCallArgs args) |
789 | 0 | { |
790 | 0 | AUTO_PROFILER_LABEL_FAST("set Element.id", DOM, cx); |
791 | 0 |
|
792 | 0 | binding_detail::FakeString arg0; |
793 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
794 | 0 | return false; |
795 | 0 | } |
796 | 0 | Maybe<AutoCEReaction> ceReaction; |
797 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
798 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
799 | 0 | if (docGroup) { |
800 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
801 | 0 | } |
802 | 0 | } |
803 | 0 | self->SetId(NonNullHelper(Constify(arg0))); |
804 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
805 | 0 |
|
806 | 0 | return true; |
807 | 0 | } |
808 | | |
809 | | static const JSJitInfo id_getterinfo = { |
810 | | { (JSJitGetterOp)get_id }, |
811 | | { prototypes::id::Element }, |
812 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
813 | | JSJitInfo::Getter, |
814 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
815 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
816 | | false, /* isInfallible. False in setters. */ |
817 | | true, /* isMovable. Not relevant for setters. */ |
818 | | true, /* isEliminatable. Not relevant for setters. */ |
819 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
820 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
821 | | false, /* isTypedMethod. Only relevant for methods. */ |
822 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
823 | | }; |
824 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
825 | | static_assert(0 < 1, "There is no slot for us"); |
826 | | static const JSJitInfo id_setterinfo = { |
827 | | { (JSJitGetterOp)set_id }, |
828 | | { prototypes::id::Element }, |
829 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
830 | | JSJitInfo::Setter, |
831 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
832 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
833 | | false, /* isInfallible. False in setters. */ |
834 | | false, /* isMovable. Not relevant for setters. */ |
835 | | false, /* isEliminatable. Not relevant for setters. */ |
836 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
837 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
838 | | false, /* isTypedMethod. Only relevant for methods. */ |
839 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
840 | | }; |
841 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
842 | | static_assert(0 < 1, "There is no slot for us"); |
843 | | |
844 | | MOZ_CAN_RUN_SCRIPT static bool |
845 | | get_className(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
846 | 0 | { |
847 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.className", DOM, cx); |
848 | 0 |
|
849 | 0 | DOMString result; |
850 | 0 | self->GetClassName(result); |
851 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
852 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
853 | 0 | return false; |
854 | 0 | } |
855 | 0 | return true; |
856 | 0 | } |
857 | | |
858 | | MOZ_CAN_RUN_SCRIPT static bool |
859 | | set_className(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitSetterCallArgs args) |
860 | 0 | { |
861 | 0 | AUTO_PROFILER_LABEL_FAST("set Element.className", DOM, cx); |
862 | 0 |
|
863 | 0 | binding_detail::FakeString arg0; |
864 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
865 | 0 | return false; |
866 | 0 | } |
867 | 0 | Maybe<AutoCEReaction> ceReaction; |
868 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
869 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
870 | 0 | if (docGroup) { |
871 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
872 | 0 | } |
873 | 0 | } |
874 | 0 | self->SetClassName(NonNullHelper(Constify(arg0))); |
875 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
876 | 0 |
|
877 | 0 | return true; |
878 | 0 | } |
879 | | |
880 | | static const JSJitInfo className_getterinfo = { |
881 | | { (JSJitGetterOp)get_className }, |
882 | | { prototypes::id::Element }, |
883 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
884 | | JSJitInfo::Getter, |
885 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
886 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
887 | | false, /* isInfallible. False in setters. */ |
888 | | true, /* isMovable. Not relevant for setters. */ |
889 | | true, /* isEliminatable. Not relevant for setters. */ |
890 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
891 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
892 | | false, /* isTypedMethod. Only relevant for methods. */ |
893 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
894 | | }; |
895 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
896 | | static_assert(0 < 1, "There is no slot for us"); |
897 | | static const JSJitInfo className_setterinfo = { |
898 | | { (JSJitGetterOp)set_className }, |
899 | | { prototypes::id::Element }, |
900 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
901 | | JSJitInfo::Setter, |
902 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
903 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
904 | | false, /* isInfallible. False in setters. */ |
905 | | false, /* isMovable. Not relevant for setters. */ |
906 | | false, /* isEliminatable. Not relevant for setters. */ |
907 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
908 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
909 | | false, /* isTypedMethod. Only relevant for methods. */ |
910 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
911 | | }; |
912 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
913 | | static_assert(0 < 1, "There is no slot for us"); |
914 | | |
915 | | MOZ_CAN_RUN_SCRIPT static bool |
916 | | get_classList(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
917 | 0 | { |
918 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.classList", DOM, cx); |
919 | 0 |
|
920 | 0 | auto result(StrongOrRawPtr<nsDOMTokenList>(self->ClassList())); |
921 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
922 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
923 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
924 | 0 | return false; |
925 | 0 | } |
926 | 0 | return true; |
927 | 0 | } |
928 | | |
929 | | MOZ_CAN_RUN_SCRIPT static bool |
930 | | set_classList(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitSetterCallArgs args) |
931 | 0 | { |
932 | 0 | AUTO_PROFILER_LABEL_FAST("set Element.classList", DOM, cx); |
933 | 0 |
|
934 | 0 | JS::Rooted<JS::Value> v(cx); |
935 | 0 | if (!JS_GetProperty(cx, obj, "classList", &v)) { |
936 | 0 | return false; |
937 | 0 | } |
938 | 0 | |
939 | 0 | if (!v.isObject()) { |
940 | 0 | return ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Element.classList"); |
941 | 0 | } |
942 | 0 | |
943 | 0 | JS::Rooted<JSObject*> targetObj(cx, &v.toObject()); |
944 | 0 | return JS_SetProperty(cx, targetObj, "value", args[0]); |
945 | 0 | } |
946 | | |
947 | | static const JSJitInfo classList_getterinfo = { |
948 | | { (JSJitGetterOp)get_classList }, |
949 | | { prototypes::id::Element }, |
950 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
951 | | JSJitInfo::Getter, |
952 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
953 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
954 | | false, /* isInfallible. False in setters. */ |
955 | | true, /* isMovable. Not relevant for setters. */ |
956 | | true, /* isEliminatable. Not relevant for setters. */ |
957 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
958 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
959 | | false, /* isTypedMethod. Only relevant for methods. */ |
960 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
961 | | }; |
962 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
963 | | static_assert(0 < 1, "There is no slot for us"); |
964 | | static const JSJitInfo classList_setterinfo = { |
965 | | { (JSJitGetterOp)set_classList }, |
966 | | { prototypes::id::Element }, |
967 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
968 | | JSJitInfo::Setter, |
969 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
970 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
971 | | false, /* isInfallible. False in setters. */ |
972 | | false, /* isMovable. Not relevant for setters. */ |
973 | | false, /* isEliminatable. Not relevant for setters. */ |
974 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
975 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
976 | | false, /* isTypedMethod. Only relevant for methods. */ |
977 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
978 | | }; |
979 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
980 | | static_assert(0 < 1, "There is no slot for us"); |
981 | | |
982 | | MOZ_CAN_RUN_SCRIPT static bool |
983 | | get_attributes(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
984 | 0 | { |
985 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.attributes", DOM, cx); |
986 | 0 |
|
987 | 0 | auto result(StrongOrRawPtr<nsDOMAttributeMap>(self->Attributes())); |
988 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
989 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
990 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
991 | 0 | return false; |
992 | 0 | } |
993 | 0 | return true; |
994 | 0 | } |
995 | | |
996 | | static const JSJitInfo attributes_getterinfo = { |
997 | | { (JSJitGetterOp)get_attributes }, |
998 | | { prototypes::id::Element }, |
999 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1000 | | JSJitInfo::Getter, |
1001 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
1002 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1003 | | false, /* isInfallible. False in setters. */ |
1004 | | true, /* isMovable. Not relevant for setters. */ |
1005 | | true, /* isEliminatable. Not relevant for setters. */ |
1006 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1007 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1008 | | false, /* isTypedMethod. Only relevant for methods. */ |
1009 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1010 | | }; |
1011 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1012 | | static_assert(0 < 1, "There is no slot for us"); |
1013 | | |
1014 | | MOZ_CAN_RUN_SCRIPT static bool |
1015 | | getAttributeNames(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1016 | 0 | { |
1017 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getAttributeNames", DOM, cx); |
1018 | 0 |
|
1019 | 0 | nsTArray<nsString> result; |
1020 | 0 | self->GetAttributeNames(result); |
1021 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1022 | 0 |
|
1023 | 0 | uint32_t length = result.Length(); |
1024 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
1025 | 0 | if (!returnArray) { |
1026 | 0 | return false; |
1027 | 0 | } |
1028 | 0 | // Scope for 'tmp' |
1029 | 0 | { |
1030 | 0 | JS::Rooted<JS::Value> tmp(cx); |
1031 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
1032 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
1033 | 0 | // are different ways to succeed at wrapping the object. |
1034 | 0 | do { |
1035 | 0 | if (!xpc::NonVoidStringToJsval(cx, result[sequenceIdx0], &tmp)) { |
1036 | 0 | return false; |
1037 | 0 | } |
1038 | 0 | break; |
1039 | 0 | } while (false); |
1040 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
1041 | 0 | JSPROP_ENUMERATE)) { |
1042 | 0 | return false; |
1043 | 0 | } |
1044 | 0 | } |
1045 | 0 | } |
1046 | 0 | args.rval().setObject(*returnArray); |
1047 | 0 | return true; |
1048 | 0 | } |
1049 | | |
1050 | | static const JSJitInfo::ArgType getAttributeNames_methodinfo_argTypes[] = { JSJitInfo::ArgTypeListEnd }; |
1051 | | static const JSTypedMethodJitInfo getAttributeNames_methodinfo = { |
1052 | | { |
1053 | | { (JSJitGetterOp)getAttributeNames }, |
1054 | | { prototypes::id::Element }, |
1055 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1056 | | JSJitInfo::Method, |
1057 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1058 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1059 | | false, /* isInfallible. False in setters. */ |
1060 | | true, /* isMovable. Not relevant for setters. */ |
1061 | | true, /* isEliminatable. Not relevant for setters. */ |
1062 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1063 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1064 | | true, /* isTypedMethod. Only relevant for methods. */ |
1065 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1066 | | }, |
1067 | | getAttributeNames_methodinfo_argTypes |
1068 | | }; |
1069 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1070 | | static_assert(0 < 1, "There is no slot for us"); |
1071 | | |
1072 | | MOZ_CAN_RUN_SCRIPT static bool |
1073 | | getAttribute(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1074 | 0 | { |
1075 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getAttribute", DOM, cx); |
1076 | 0 |
|
1077 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1078 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.getAttribute"); |
1079 | 0 | } |
1080 | 0 | binding_detail::FakeString arg0; |
1081 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
1082 | 0 | return false; |
1083 | 0 | } |
1084 | 0 | DOMString result; |
1085 | 0 | self->GetAttribute(NonNullHelper(Constify(arg0)), result); |
1086 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1087 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
1088 | 0 | return false; |
1089 | 0 | } |
1090 | 0 | return true; |
1091 | 0 | } |
1092 | | |
1093 | | static const JSJitInfo::ArgType getAttribute_methodinfo_argTypes[] = { JSJitInfo::String, JSJitInfo::ArgTypeListEnd }; |
1094 | | static const JSTypedMethodJitInfo getAttribute_methodinfo = { |
1095 | | { |
1096 | | { (JSJitGetterOp)getAttribute }, |
1097 | | { prototypes::id::Element }, |
1098 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1099 | | JSJitInfo::Method, |
1100 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1101 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
1102 | | false, /* isInfallible. False in setters. */ |
1103 | | true, /* isMovable. Not relevant for setters. */ |
1104 | | true, /* isEliminatable. Not relevant for setters. */ |
1105 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1106 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1107 | | true, /* isTypedMethod. Only relevant for methods. */ |
1108 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1109 | | }, |
1110 | | getAttribute_methodinfo_argTypes |
1111 | | }; |
1112 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1113 | | static_assert(0 < 1, "There is no slot for us"); |
1114 | | |
1115 | | MOZ_CAN_RUN_SCRIPT static bool |
1116 | | getAttributeNS(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1117 | 0 | { |
1118 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getAttributeNS", DOM, cx); |
1119 | 0 |
|
1120 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
1121 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.getAttributeNS"); |
1122 | 0 | } |
1123 | 0 | binding_detail::FakeString arg0; |
1124 | 0 | if (!ConvertJSValueToString(cx, args[0], eNull, eNull, arg0)) { |
1125 | 0 | return false; |
1126 | 0 | } |
1127 | 0 | binding_detail::FakeString arg1; |
1128 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
1129 | 0 | return false; |
1130 | 0 | } |
1131 | 0 | DOMString result; |
1132 | 0 | self->GetAttributeNS(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), result); |
1133 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1134 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
1135 | 0 | return false; |
1136 | 0 | } |
1137 | 0 | return true; |
1138 | 0 | } |
1139 | | |
1140 | | static const JSJitInfo::ArgType getAttributeNS_methodinfo_argTypes[] = { JSJitInfo::ArgType(JSJitInfo::Null | JSJitInfo::String), JSJitInfo::String, JSJitInfo::ArgTypeListEnd }; |
1141 | | static const JSTypedMethodJitInfo getAttributeNS_methodinfo = { |
1142 | | { |
1143 | | { (JSJitGetterOp)getAttributeNS }, |
1144 | | { prototypes::id::Element }, |
1145 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1146 | | JSJitInfo::Method, |
1147 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1148 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
1149 | | false, /* isInfallible. False in setters. */ |
1150 | | true, /* isMovable. Not relevant for setters. */ |
1151 | | true, /* isEliminatable. Not relevant for setters. */ |
1152 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1153 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1154 | | true, /* isTypedMethod. Only relevant for methods. */ |
1155 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1156 | | }, |
1157 | | getAttributeNS_methodinfo_argTypes |
1158 | | }; |
1159 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1160 | | static_assert(0 < 1, "There is no slot for us"); |
1161 | | |
1162 | | MOZ_CAN_RUN_SCRIPT static bool |
1163 | | toggleAttribute(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1164 | 0 | { |
1165 | 0 | AUTO_PROFILER_LABEL_FAST("Element.toggleAttribute", DOM, cx); |
1166 | 0 |
|
1167 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1168 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.toggleAttribute"); |
1169 | 0 | } |
1170 | 0 | binding_detail::FakeString arg0; |
1171 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
1172 | 0 | return false; |
1173 | 0 | } |
1174 | 0 | Optional<bool> arg1; |
1175 | 0 | if (args.hasDefined(1)) { |
1176 | 0 | arg1.Construct(); |
1177 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1.Value())) { |
1178 | 0 | return false; |
1179 | 0 | } |
1180 | 0 | } |
1181 | 0 | Maybe<AutoCEReaction> ceReaction; |
1182 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
1183 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
1184 | 0 | if (docGroup) { |
1185 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
1186 | 0 | } |
1187 | 0 | } |
1188 | 0 | FastErrorResult rv; |
1189 | 0 | nsIPrincipal* subjectPrincipal; |
1190 | 0 | { |
1191 | 0 | JS::Realm* realm = js::GetContextRealm(cx); |
1192 | 0 | MOZ_ASSERT(realm); |
1193 | 0 | JSPrincipals* principals = JS::GetRealmPrincipals(realm); |
1194 | 0 | nsIPrincipal* principal = nsJSPrincipals::get(principals); |
1195 | 0 | if (nsContentUtils::IsSystemPrincipal(principal)) { |
1196 | 0 | principal = nullptr; |
1197 | 0 | } |
1198 | 0 |
|
1199 | 0 | subjectPrincipal = principal; |
1200 | 0 | } |
1201 | 0 | bool result(self->ToggleAttribute(NonNullHelper(Constify(arg0)), Constify(arg1), subjectPrincipal, rv)); |
1202 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1203 | 0 | return false; |
1204 | 0 | } |
1205 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1206 | 0 | args.rval().setBoolean(result); |
1207 | 0 | return true; |
1208 | 0 | } |
1209 | | |
1210 | | static const JSJitInfo toggleAttribute_methodinfo = { |
1211 | | { (JSJitGetterOp)toggleAttribute }, |
1212 | | { prototypes::id::Element }, |
1213 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1214 | | JSJitInfo::Method, |
1215 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1216 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
1217 | | false, /* isInfallible. False in setters. */ |
1218 | | false, /* isMovable. Not relevant for setters. */ |
1219 | | false, /* isEliminatable. Not relevant for setters. */ |
1220 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1221 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1222 | | false, /* isTypedMethod. Only relevant for methods. */ |
1223 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1224 | | }; |
1225 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1226 | | static_assert(0 < 1, "There is no slot for us"); |
1227 | | |
1228 | | MOZ_CAN_RUN_SCRIPT static bool |
1229 | | setAttribute(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1230 | 0 | { |
1231 | 0 | AUTO_PROFILER_LABEL_FAST("Element.setAttribute", DOM, cx); |
1232 | 0 |
|
1233 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
1234 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.setAttribute"); |
1235 | 0 | } |
1236 | 0 | binding_detail::FakeString arg0; |
1237 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
1238 | 0 | return false; |
1239 | 0 | } |
1240 | 0 | binding_detail::FakeString arg1; |
1241 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
1242 | 0 | return false; |
1243 | 0 | } |
1244 | 0 | Maybe<AutoCEReaction> ceReaction; |
1245 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
1246 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
1247 | 0 | if (docGroup) { |
1248 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
1249 | 0 | } |
1250 | 0 | } |
1251 | 0 | FastErrorResult rv; |
1252 | 0 | nsIPrincipal* subjectPrincipal; |
1253 | 0 | { |
1254 | 0 | JS::Realm* realm = js::GetContextRealm(cx); |
1255 | 0 | MOZ_ASSERT(realm); |
1256 | 0 | JSPrincipals* principals = JS::GetRealmPrincipals(realm); |
1257 | 0 | nsIPrincipal* principal = nsJSPrincipals::get(principals); |
1258 | 0 | if (nsContentUtils::IsSystemPrincipal(principal)) { |
1259 | 0 | principal = nullptr; |
1260 | 0 | } |
1261 | 0 |
|
1262 | 0 | subjectPrincipal = principal; |
1263 | 0 | } |
1264 | 0 | self->SetAttribute(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), subjectPrincipal, rv); |
1265 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1266 | 0 | return false; |
1267 | 0 | } |
1268 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1269 | 0 | args.rval().setUndefined(); |
1270 | 0 | return true; |
1271 | 0 | } |
1272 | | |
1273 | | static const JSJitInfo setAttribute_methodinfo = { |
1274 | | { (JSJitGetterOp)setAttribute }, |
1275 | | { prototypes::id::Element }, |
1276 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1277 | | JSJitInfo::Method, |
1278 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1279 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1280 | | false, /* isInfallible. False in setters. */ |
1281 | | false, /* isMovable. Not relevant for setters. */ |
1282 | | false, /* isEliminatable. Not relevant for setters. */ |
1283 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1284 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1285 | | false, /* isTypedMethod. Only relevant for methods. */ |
1286 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1287 | | }; |
1288 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1289 | | static_assert(0 < 1, "There is no slot for us"); |
1290 | | |
1291 | | MOZ_CAN_RUN_SCRIPT static bool |
1292 | | setAttributeNS(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1293 | 0 | { |
1294 | 0 | AUTO_PROFILER_LABEL_FAST("Element.setAttributeNS", DOM, cx); |
1295 | 0 |
|
1296 | 0 | if (MOZ_UNLIKELY(args.length() < 3)) { |
1297 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.setAttributeNS"); |
1298 | 0 | } |
1299 | 0 | binding_detail::FakeString arg0; |
1300 | 0 | if (!ConvertJSValueToString(cx, args[0], eNull, eNull, arg0)) { |
1301 | 0 | return false; |
1302 | 0 | } |
1303 | 0 | binding_detail::FakeString arg1; |
1304 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
1305 | 0 | return false; |
1306 | 0 | } |
1307 | 0 | binding_detail::FakeString arg2; |
1308 | 0 | if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2)) { |
1309 | 0 | return false; |
1310 | 0 | } |
1311 | 0 | Maybe<AutoCEReaction> ceReaction; |
1312 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
1313 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
1314 | 0 | if (docGroup) { |
1315 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
1316 | 0 | } |
1317 | 0 | } |
1318 | 0 | FastErrorResult rv; |
1319 | 0 | nsIPrincipal* subjectPrincipal; |
1320 | 0 | { |
1321 | 0 | JS::Realm* realm = js::GetContextRealm(cx); |
1322 | 0 | MOZ_ASSERT(realm); |
1323 | 0 | JSPrincipals* principals = JS::GetRealmPrincipals(realm); |
1324 | 0 | nsIPrincipal* principal = nsJSPrincipals::get(principals); |
1325 | 0 | if (nsContentUtils::IsSystemPrincipal(principal)) { |
1326 | 0 | principal = nullptr; |
1327 | 0 | } |
1328 | 0 |
|
1329 | 0 | subjectPrincipal = principal; |
1330 | 0 | } |
1331 | 0 | self->SetAttributeNS(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), NonNullHelper(Constify(arg2)), subjectPrincipal, rv); |
1332 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1333 | 0 | return false; |
1334 | 0 | } |
1335 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1336 | 0 | args.rval().setUndefined(); |
1337 | 0 | return true; |
1338 | 0 | } |
1339 | | |
1340 | | static const JSJitInfo setAttributeNS_methodinfo = { |
1341 | | { (JSJitGetterOp)setAttributeNS }, |
1342 | | { prototypes::id::Element }, |
1343 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1344 | | JSJitInfo::Method, |
1345 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1346 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1347 | | false, /* isInfallible. False in setters. */ |
1348 | | false, /* isMovable. Not relevant for setters. */ |
1349 | | false, /* isEliminatable. Not relevant for setters. */ |
1350 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1351 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1352 | | false, /* isTypedMethod. Only relevant for methods. */ |
1353 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1354 | | }; |
1355 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1356 | | static_assert(0 < 1, "There is no slot for us"); |
1357 | | |
1358 | | MOZ_CAN_RUN_SCRIPT static bool |
1359 | | removeAttribute(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1360 | 0 | { |
1361 | 0 | AUTO_PROFILER_LABEL_FAST("Element.removeAttribute", DOM, cx); |
1362 | 0 |
|
1363 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1364 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.removeAttribute"); |
1365 | 0 | } |
1366 | 0 | binding_detail::FakeString arg0; |
1367 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
1368 | 0 | return false; |
1369 | 0 | } |
1370 | 0 | Maybe<AutoCEReaction> ceReaction; |
1371 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
1372 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
1373 | 0 | if (docGroup) { |
1374 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
1375 | 0 | } |
1376 | 0 | } |
1377 | 0 | FastErrorResult rv; |
1378 | 0 | self->RemoveAttribute(NonNullHelper(Constify(arg0)), rv); |
1379 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1380 | 0 | return false; |
1381 | 0 | } |
1382 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1383 | 0 | args.rval().setUndefined(); |
1384 | 0 | return true; |
1385 | 0 | } |
1386 | | |
1387 | | static const JSJitInfo removeAttribute_methodinfo = { |
1388 | | { (JSJitGetterOp)removeAttribute }, |
1389 | | { prototypes::id::Element }, |
1390 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1391 | | JSJitInfo::Method, |
1392 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1393 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1394 | | false, /* isInfallible. False in setters. */ |
1395 | | false, /* isMovable. Not relevant for setters. */ |
1396 | | false, /* isEliminatable. Not relevant for setters. */ |
1397 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1398 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1399 | | false, /* isTypedMethod. Only relevant for methods. */ |
1400 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1401 | | }; |
1402 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1403 | | static_assert(0 < 1, "There is no slot for us"); |
1404 | | |
1405 | | MOZ_CAN_RUN_SCRIPT static bool |
1406 | | removeAttributeNS(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1407 | 0 | { |
1408 | 0 | AUTO_PROFILER_LABEL_FAST("Element.removeAttributeNS", DOM, cx); |
1409 | 0 |
|
1410 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
1411 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.removeAttributeNS"); |
1412 | 0 | } |
1413 | 0 | binding_detail::FakeString arg0; |
1414 | 0 | if (!ConvertJSValueToString(cx, args[0], eNull, eNull, arg0)) { |
1415 | 0 | return false; |
1416 | 0 | } |
1417 | 0 | binding_detail::FakeString arg1; |
1418 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
1419 | 0 | return false; |
1420 | 0 | } |
1421 | 0 | Maybe<AutoCEReaction> ceReaction; |
1422 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
1423 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
1424 | 0 | if (docGroup) { |
1425 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
1426 | 0 | } |
1427 | 0 | } |
1428 | 0 | FastErrorResult rv; |
1429 | 0 | self->RemoveAttributeNS(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv); |
1430 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1431 | 0 | return false; |
1432 | 0 | } |
1433 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1434 | 0 | args.rval().setUndefined(); |
1435 | 0 | return true; |
1436 | 0 | } |
1437 | | |
1438 | | static const JSJitInfo removeAttributeNS_methodinfo = { |
1439 | | { (JSJitGetterOp)removeAttributeNS }, |
1440 | | { prototypes::id::Element }, |
1441 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1442 | | JSJitInfo::Method, |
1443 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1444 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1445 | | false, /* isInfallible. False in setters. */ |
1446 | | false, /* isMovable. Not relevant for setters. */ |
1447 | | false, /* isEliminatable. Not relevant for setters. */ |
1448 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1449 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1450 | | false, /* isTypedMethod. Only relevant for methods. */ |
1451 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1452 | | }; |
1453 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1454 | | static_assert(0 < 1, "There is no slot for us"); |
1455 | | |
1456 | | MOZ_CAN_RUN_SCRIPT static bool |
1457 | | hasAttribute(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1458 | 0 | { |
1459 | 0 | AUTO_PROFILER_LABEL_FAST("Element.hasAttribute", DOM, cx); |
1460 | 0 |
|
1461 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1462 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.hasAttribute"); |
1463 | 0 | } |
1464 | 0 | binding_detail::FakeString arg0; |
1465 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
1466 | 0 | return false; |
1467 | 0 | } |
1468 | 0 | bool result(self->HasAttribute(NonNullHelper(Constify(arg0)))); |
1469 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1470 | 0 | args.rval().setBoolean(result); |
1471 | 0 | return true; |
1472 | 0 | } |
1473 | | |
1474 | | static const JSJitInfo::ArgType hasAttribute_methodinfo_argTypes[] = { JSJitInfo::String, JSJitInfo::ArgTypeListEnd }; |
1475 | | static const JSTypedMethodJitInfo hasAttribute_methodinfo = { |
1476 | | { |
1477 | | { (JSJitGetterOp)hasAttribute }, |
1478 | | { prototypes::id::Element }, |
1479 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1480 | | JSJitInfo::Method, |
1481 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1482 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
1483 | | false, /* isInfallible. False in setters. */ |
1484 | | true, /* isMovable. Not relevant for setters. */ |
1485 | | true, /* isEliminatable. Not relevant for setters. */ |
1486 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1487 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1488 | | true, /* isTypedMethod. Only relevant for methods. */ |
1489 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1490 | | }, |
1491 | | hasAttribute_methodinfo_argTypes |
1492 | | }; |
1493 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1494 | | static_assert(0 < 1, "There is no slot for us"); |
1495 | | |
1496 | | MOZ_CAN_RUN_SCRIPT static bool |
1497 | | hasAttributeNS(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1498 | 0 | { |
1499 | 0 | AUTO_PROFILER_LABEL_FAST("Element.hasAttributeNS", DOM, cx); |
1500 | 0 |
|
1501 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
1502 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.hasAttributeNS"); |
1503 | 0 | } |
1504 | 0 | binding_detail::FakeString arg0; |
1505 | 0 | if (!ConvertJSValueToString(cx, args[0], eNull, eNull, arg0)) { |
1506 | 0 | return false; |
1507 | 0 | } |
1508 | 0 | binding_detail::FakeString arg1; |
1509 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
1510 | 0 | return false; |
1511 | 0 | } |
1512 | 0 | bool result(self->HasAttributeNS(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)))); |
1513 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1514 | 0 | args.rval().setBoolean(result); |
1515 | 0 | return true; |
1516 | 0 | } |
1517 | | |
1518 | | static const JSJitInfo::ArgType hasAttributeNS_methodinfo_argTypes[] = { JSJitInfo::ArgType(JSJitInfo::Null | JSJitInfo::String), JSJitInfo::String, JSJitInfo::ArgTypeListEnd }; |
1519 | | static const JSTypedMethodJitInfo hasAttributeNS_methodinfo = { |
1520 | | { |
1521 | | { (JSJitGetterOp)hasAttributeNS }, |
1522 | | { prototypes::id::Element }, |
1523 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1524 | | JSJitInfo::Method, |
1525 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1526 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
1527 | | false, /* isInfallible. False in setters. */ |
1528 | | true, /* isMovable. Not relevant for setters. */ |
1529 | | true, /* isEliminatable. Not relevant for setters. */ |
1530 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1531 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1532 | | true, /* isTypedMethod. Only relevant for methods. */ |
1533 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1534 | | }, |
1535 | | hasAttributeNS_methodinfo_argTypes |
1536 | | }; |
1537 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1538 | | static_assert(0 < 1, "There is no slot for us"); |
1539 | | |
1540 | | MOZ_CAN_RUN_SCRIPT static bool |
1541 | | hasAttributes(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1542 | 0 | { |
1543 | 0 | AUTO_PROFILER_LABEL_FAST("Element.hasAttributes", DOM, cx); |
1544 | 0 |
|
1545 | 0 | bool result(self->HasAttributes()); |
1546 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1547 | 0 | args.rval().setBoolean(result); |
1548 | 0 | return true; |
1549 | 0 | } |
1550 | | |
1551 | | static const JSJitInfo::ArgType hasAttributes_methodinfo_argTypes[] = { JSJitInfo::ArgTypeListEnd }; |
1552 | | static const JSTypedMethodJitInfo hasAttributes_methodinfo = { |
1553 | | { |
1554 | | { (JSJitGetterOp)hasAttributes }, |
1555 | | { prototypes::id::Element }, |
1556 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1557 | | JSJitInfo::Method, |
1558 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1559 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
1560 | | true, /* isInfallible. False in setters. */ |
1561 | | true, /* isMovable. Not relevant for setters. */ |
1562 | | true, /* isEliminatable. Not relevant for setters. */ |
1563 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1564 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1565 | | true, /* isTypedMethod. Only relevant for methods. */ |
1566 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1567 | | }, |
1568 | | hasAttributes_methodinfo_argTypes |
1569 | | }; |
1570 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1571 | | static_assert(0 < 1, "There is no slot for us"); |
1572 | | |
1573 | | MOZ_CAN_RUN_SCRIPT static bool |
1574 | | closest(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1575 | 0 | { |
1576 | 0 | AUTO_PROFILER_LABEL_FAST("Element.closest", DOM, cx); |
1577 | 0 |
|
1578 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1579 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.closest"); |
1580 | 0 | } |
1581 | 0 | binding_detail::FakeString arg0; |
1582 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
1583 | 0 | return false; |
1584 | 0 | } |
1585 | 0 | FastErrorResult rv; |
1586 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Element>(self->Closest(NonNullHelper(Constify(arg0)), rv))); |
1587 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1588 | 0 | return false; |
1589 | 0 | } |
1590 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1591 | 0 | if (!result) { |
1592 | 0 | args.rval().setNull(); |
1593 | 0 | return true; |
1594 | 0 | } |
1595 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
1596 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1597 | 0 | return false; |
1598 | 0 | } |
1599 | 0 | return true; |
1600 | 0 | } |
1601 | | |
1602 | | static const JSJitInfo::ArgType closest_methodinfo_argTypes[] = { JSJitInfo::String, JSJitInfo::ArgTypeListEnd }; |
1603 | | static const JSTypedMethodJitInfo closest_methodinfo = { |
1604 | | { |
1605 | | { (JSJitGetterOp)closest }, |
1606 | | { prototypes::id::Element }, |
1607 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1608 | | JSJitInfo::Method, |
1609 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1610 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
1611 | | false, /* isInfallible. False in setters. */ |
1612 | | false, /* isMovable. Not relevant for setters. */ |
1613 | | false, /* isEliminatable. Not relevant for setters. */ |
1614 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1615 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1616 | | true, /* isTypedMethod. Only relevant for methods. */ |
1617 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1618 | | }, |
1619 | | closest_methodinfo_argTypes |
1620 | | }; |
1621 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1622 | | static_assert(0 < 1, "There is no slot for us"); |
1623 | | |
1624 | | MOZ_CAN_RUN_SCRIPT static bool |
1625 | | matches(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1626 | 0 | { |
1627 | 0 | AUTO_PROFILER_LABEL_FAST("Element.matches", DOM, cx); |
1628 | 0 |
|
1629 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1630 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.matches"); |
1631 | 0 | } |
1632 | 0 | binding_detail::FakeString arg0; |
1633 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
1634 | 0 | return false; |
1635 | 0 | } |
1636 | 0 | FastErrorResult rv; |
1637 | 0 | bool result(self->Matches(NonNullHelper(Constify(arg0)), rv)); |
1638 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1639 | 0 | return false; |
1640 | 0 | } |
1641 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1642 | 0 | args.rval().setBoolean(result); |
1643 | 0 | return true; |
1644 | 0 | } |
1645 | | |
1646 | | static const JSJitInfo::ArgType matches_methodinfo_argTypes[] = { JSJitInfo::String, JSJitInfo::ArgTypeListEnd }; |
1647 | | static const JSTypedMethodJitInfo matches_methodinfo = { |
1648 | | { |
1649 | | { (JSJitGetterOp)matches }, |
1650 | | { prototypes::id::Element }, |
1651 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1652 | | JSJitInfo::Method, |
1653 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1654 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
1655 | | false, /* isInfallible. False in setters. */ |
1656 | | false, /* isMovable. Not relevant for setters. */ |
1657 | | false, /* isEliminatable. Not relevant for setters. */ |
1658 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1659 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1660 | | true, /* isTypedMethod. Only relevant for methods. */ |
1661 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1662 | | }, |
1663 | | matches_methodinfo_argTypes |
1664 | | }; |
1665 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1666 | | static_assert(0 < 1, "There is no slot for us"); |
1667 | | |
1668 | | MOZ_CAN_RUN_SCRIPT static bool |
1669 | | webkitMatchesSelector(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1670 | 0 | { |
1671 | 0 | AUTO_PROFILER_LABEL_FAST("Element.webkitMatchesSelector", DOM, cx); |
1672 | 0 |
|
1673 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1674 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.webkitMatchesSelector"); |
1675 | 0 | } |
1676 | 0 | binding_detail::FakeString arg0; |
1677 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
1678 | 0 | return false; |
1679 | 0 | } |
1680 | 0 | FastErrorResult rv; |
1681 | 0 | bool result(self->Matches(NonNullHelper(Constify(arg0)), rv)); |
1682 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1683 | 0 | return false; |
1684 | 0 | } |
1685 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1686 | 0 | args.rval().setBoolean(result); |
1687 | 0 | return true; |
1688 | 0 | } |
1689 | | |
1690 | | static const JSJitInfo::ArgType webkitMatchesSelector_methodinfo_argTypes[] = { JSJitInfo::String, JSJitInfo::ArgTypeListEnd }; |
1691 | | static const JSTypedMethodJitInfo webkitMatchesSelector_methodinfo = { |
1692 | | { |
1693 | | { (JSJitGetterOp)webkitMatchesSelector }, |
1694 | | { prototypes::id::Element }, |
1695 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1696 | | JSJitInfo::Method, |
1697 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1698 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
1699 | | false, /* isInfallible. False in setters. */ |
1700 | | false, /* isMovable. Not relevant for setters. */ |
1701 | | false, /* isEliminatable. Not relevant for setters. */ |
1702 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1703 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1704 | | true, /* isTypedMethod. Only relevant for methods. */ |
1705 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1706 | | }, |
1707 | | webkitMatchesSelector_methodinfo_argTypes |
1708 | | }; |
1709 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1710 | | static_assert(0 < 1, "There is no slot for us"); |
1711 | | |
1712 | | MOZ_CAN_RUN_SCRIPT static bool |
1713 | | getElementsByTagName(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1714 | 0 | { |
1715 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getElementsByTagName", DOM, cx); |
1716 | 0 |
|
1717 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1718 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.getElementsByTagName"); |
1719 | 0 | } |
1720 | 0 | binding_detail::FakeString arg0; |
1721 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
1722 | 0 | return false; |
1723 | 0 | } |
1724 | 0 | auto result(StrongOrRawPtr<nsIHTMLCollection>(self->GetElementsByTagName(NonNullHelper(Constify(arg0))))); |
1725 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1726 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
1727 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1728 | 0 | return false; |
1729 | 0 | } |
1730 | 0 | return true; |
1731 | 0 | } |
1732 | | |
1733 | | static const JSJitInfo::ArgType getElementsByTagName_methodinfo_argTypes[] = { JSJitInfo::String, JSJitInfo::ArgTypeListEnd }; |
1734 | | static const JSTypedMethodJitInfo getElementsByTagName_methodinfo = { |
1735 | | { |
1736 | | { (JSJitGetterOp)getElementsByTagName }, |
1737 | | { prototypes::id::Element }, |
1738 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1739 | | JSJitInfo::Method, |
1740 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1741 | | JSVAL_TYPE_OBJECT, /* 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 | | true, /* isTypedMethod. Only relevant for methods. */ |
1748 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1749 | | }, |
1750 | | getElementsByTagName_methodinfo_argTypes |
1751 | | }; |
1752 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1753 | | static_assert(0 < 1, "There is no slot for us"); |
1754 | | |
1755 | | MOZ_CAN_RUN_SCRIPT static bool |
1756 | | getElementsByTagNameNS(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1757 | 0 | { |
1758 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getElementsByTagNameNS", DOM, cx); |
1759 | 0 |
|
1760 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
1761 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.getElementsByTagNameNS"); |
1762 | 0 | } |
1763 | 0 | binding_detail::FakeString arg0; |
1764 | 0 | if (!ConvertJSValueToString(cx, args[0], eNull, eNull, arg0)) { |
1765 | 0 | return false; |
1766 | 0 | } |
1767 | 0 | binding_detail::FakeString arg1; |
1768 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
1769 | 0 | return false; |
1770 | 0 | } |
1771 | 0 | FastErrorResult rv; |
1772 | 0 | auto result(StrongOrRawPtr<nsIHTMLCollection>(self->GetElementsByTagNameNS(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv))); |
1773 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1774 | 0 | return false; |
1775 | 0 | } |
1776 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1777 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
1778 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1779 | 0 | return false; |
1780 | 0 | } |
1781 | 0 | return true; |
1782 | 0 | } |
1783 | | |
1784 | | static const JSJitInfo::ArgType getElementsByTagNameNS_methodinfo_argTypes[] = { JSJitInfo::ArgType(JSJitInfo::Null | JSJitInfo::String), JSJitInfo::String, JSJitInfo::ArgTypeListEnd }; |
1785 | | static const JSTypedMethodJitInfo getElementsByTagNameNS_methodinfo = { |
1786 | | { |
1787 | | { (JSJitGetterOp)getElementsByTagNameNS }, |
1788 | | { prototypes::id::Element }, |
1789 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1790 | | JSJitInfo::Method, |
1791 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1792 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1793 | | false, /* isInfallible. False in setters. */ |
1794 | | false, /* isMovable. Not relevant for setters. */ |
1795 | | false, /* isEliminatable. Not relevant for setters. */ |
1796 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1797 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1798 | | true, /* isTypedMethod. Only relevant for methods. */ |
1799 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1800 | | }, |
1801 | | getElementsByTagNameNS_methodinfo_argTypes |
1802 | | }; |
1803 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1804 | | static_assert(0 < 1, "There is no slot for us"); |
1805 | | |
1806 | | MOZ_CAN_RUN_SCRIPT static bool |
1807 | | getElementsByClassName(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1808 | 0 | { |
1809 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getElementsByClassName", DOM, cx); |
1810 | 0 |
|
1811 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1812 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.getElementsByClassName"); |
1813 | 0 | } |
1814 | 0 | binding_detail::FakeString arg0; |
1815 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
1816 | 0 | return false; |
1817 | 0 | } |
1818 | 0 | auto result(StrongOrRawPtr<nsIHTMLCollection>(self->GetElementsByClassName(NonNullHelper(Constify(arg0))))); |
1819 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1820 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
1821 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1822 | 0 | return false; |
1823 | 0 | } |
1824 | 0 | return true; |
1825 | 0 | } |
1826 | | |
1827 | | static const JSJitInfo::ArgType getElementsByClassName_methodinfo_argTypes[] = { JSJitInfo::String, JSJitInfo::ArgTypeListEnd }; |
1828 | | static const JSTypedMethodJitInfo getElementsByClassName_methodinfo = { |
1829 | | { |
1830 | | { (JSJitGetterOp)getElementsByClassName }, |
1831 | | { prototypes::id::Element }, |
1832 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1833 | | JSJitInfo::Method, |
1834 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1835 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1836 | | false, /* isInfallible. False in setters. */ |
1837 | | true, /* isMovable. Not relevant for setters. */ |
1838 | | true, /* isEliminatable. Not relevant for setters. */ |
1839 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1840 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1841 | | true, /* isTypedMethod. Only relevant for methods. */ |
1842 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1843 | | }, |
1844 | | getElementsByClassName_methodinfo_argTypes |
1845 | | }; |
1846 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1847 | | static_assert(0 < 1, "There is no slot for us"); |
1848 | | |
1849 | | MOZ_CAN_RUN_SCRIPT static bool |
1850 | | insertAdjacentElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1851 | 0 | { |
1852 | 0 | AUTO_PROFILER_LABEL_FAST("Element.insertAdjacentElement", DOM, cx); |
1853 | 0 |
|
1854 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
1855 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.insertAdjacentElement"); |
1856 | 0 | } |
1857 | 0 | binding_detail::FakeString arg0; |
1858 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
1859 | 0 | return false; |
1860 | 0 | } |
1861 | 0 | NonNull<mozilla::dom::Element> arg1; |
1862 | 0 | if (args[1].isObject()) { |
1863 | 0 | { |
1864 | 0 | nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[1], arg1); |
1865 | 0 | if (NS_FAILED(rv)) { |
1866 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of Element.insertAdjacentElement", "Element"); |
1867 | 0 | return false; |
1868 | 0 | } |
1869 | 0 | } |
1870 | 0 | } else { |
1871 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of Element.insertAdjacentElement"); |
1872 | 0 | return false; |
1873 | 0 | } |
1874 | 0 | Maybe<AutoCEReaction> ceReaction; |
1875 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
1876 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
1877 | 0 | if (docGroup) { |
1878 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
1879 | 0 | } |
1880 | 0 | } |
1881 | 0 | FastErrorResult rv; |
1882 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Element>(self->InsertAdjacentElement(NonNullHelper(Constify(arg0)), MOZ_KnownLive(NonNullHelper(arg1)), rv))); |
1883 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1884 | 0 | return false; |
1885 | 0 | } |
1886 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1887 | 0 | if (!result) { |
1888 | 0 | args.rval().setNull(); |
1889 | 0 | return true; |
1890 | 0 | } |
1891 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
1892 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1893 | 0 | return false; |
1894 | 0 | } |
1895 | 0 | return true; |
1896 | 0 | } |
1897 | | |
1898 | | static const JSJitInfo::ArgType insertAdjacentElement_methodinfo_argTypes[] = { JSJitInfo::String, JSJitInfo::Object, JSJitInfo::ArgTypeListEnd }; |
1899 | | static const JSTypedMethodJitInfo insertAdjacentElement_methodinfo = { |
1900 | | { |
1901 | | { (JSJitGetterOp)insertAdjacentElement }, |
1902 | | { prototypes::id::Element }, |
1903 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1904 | | JSJitInfo::Method, |
1905 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
1906 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
1907 | | false, /* isInfallible. False in setters. */ |
1908 | | false, /* isMovable. Not relevant for setters. */ |
1909 | | false, /* isEliminatable. Not relevant for setters. */ |
1910 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1911 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1912 | | true, /* isTypedMethod. Only relevant for methods. */ |
1913 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1914 | | }, |
1915 | | insertAdjacentElement_methodinfo_argTypes |
1916 | | }; |
1917 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1918 | | static_assert(0 < 1, "There is no slot for us"); |
1919 | | |
1920 | | MOZ_CAN_RUN_SCRIPT static bool |
1921 | | insertAdjacentText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1922 | 0 | { |
1923 | 0 | AUTO_PROFILER_LABEL_FAST("Element.insertAdjacentText", DOM, cx); |
1924 | 0 |
|
1925 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
1926 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.insertAdjacentText"); |
1927 | 0 | } |
1928 | 0 | binding_detail::FakeString arg0; |
1929 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
1930 | 0 | return false; |
1931 | 0 | } |
1932 | 0 | binding_detail::FakeString arg1; |
1933 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
1934 | 0 | return false; |
1935 | 0 | } |
1936 | 0 | FastErrorResult rv; |
1937 | 0 | self->InsertAdjacentText(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv); |
1938 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1939 | 0 | return false; |
1940 | 0 | } |
1941 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1942 | 0 | args.rval().setUndefined(); |
1943 | 0 | return true; |
1944 | 0 | } |
1945 | | |
1946 | | static const JSJitInfo insertAdjacentText_methodinfo = { |
1947 | | { (JSJitGetterOp)insertAdjacentText }, |
1948 | | { prototypes::id::Element }, |
1949 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1950 | | JSJitInfo::Method, |
1951 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1952 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1953 | | false, /* isInfallible. False in setters. */ |
1954 | | false, /* isMovable. Not relevant for setters. */ |
1955 | | false, /* isEliminatable. Not relevant for setters. */ |
1956 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1957 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1958 | | false, /* isTypedMethod. Only relevant for methods. */ |
1959 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1960 | | }; |
1961 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1962 | | static_assert(0 < 1, "There is no slot for us"); |
1963 | | |
1964 | | MOZ_CAN_RUN_SCRIPT static bool |
1965 | | get_fontSizeInflation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
1966 | 0 | { |
1967 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.fontSizeInflation", DOM, cx); |
1968 | 0 |
|
1969 | 0 | float result(self->FontSizeInflation()); |
1970 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1971 | 0 | args.rval().set(JS_NumberValue(double(result))); |
1972 | 0 | return true; |
1973 | 0 | } |
1974 | | |
1975 | | static const JSJitInfo fontSizeInflation_getterinfo = { |
1976 | | { (JSJitGetterOp)get_fontSizeInflation }, |
1977 | | { prototypes::id::Element }, |
1978 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
1979 | | JSJitInfo::Getter, |
1980 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1981 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
1982 | | true, /* isInfallible. False in setters. */ |
1983 | | false, /* isMovable. Not relevant for setters. */ |
1984 | | false, /* isEliminatable. Not relevant for setters. */ |
1985 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1986 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1987 | | false, /* isTypedMethod. Only relevant for methods. */ |
1988 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1989 | | }; |
1990 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1991 | | static_assert(0 < 1, "There is no slot for us"); |
1992 | | |
1993 | | MOZ_CAN_RUN_SCRIPT static bool |
1994 | | mozMatchesSelector(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
1995 | 0 | { |
1996 | 0 | AUTO_PROFILER_LABEL_FAST("Element.mozMatchesSelector", DOM, cx); |
1997 | 0 |
|
1998 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1999 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.mozMatchesSelector"); |
2000 | 0 | } |
2001 | 0 | binding_detail::FakeString arg0; |
2002 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
2003 | 0 | return false; |
2004 | 0 | } |
2005 | 0 | FastErrorResult rv; |
2006 | 0 | bool result(self->Matches(NonNullHelper(Constify(arg0)), rv)); |
2007 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
2008 | 0 | return false; |
2009 | 0 | } |
2010 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2011 | 0 | args.rval().setBoolean(result); |
2012 | 0 | return true; |
2013 | 0 | } |
2014 | | |
2015 | | static const JSJitInfo::ArgType mozMatchesSelector_methodinfo_argTypes[] = { JSJitInfo::String, JSJitInfo::ArgTypeListEnd }; |
2016 | | static const JSTypedMethodJitInfo mozMatchesSelector_methodinfo = { |
2017 | | { |
2018 | | { (JSJitGetterOp)mozMatchesSelector }, |
2019 | | { prototypes::id::Element }, |
2020 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2021 | | JSJitInfo::Method, |
2022 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
2023 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
2024 | | false, /* isInfallible. False in setters. */ |
2025 | | false, /* isMovable. Not relevant for setters. */ |
2026 | | false, /* isEliminatable. Not relevant for setters. */ |
2027 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2028 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2029 | | true, /* isTypedMethod. Only relevant for methods. */ |
2030 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2031 | | }, |
2032 | | mozMatchesSelector_methodinfo_argTypes |
2033 | | }; |
2034 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2035 | | static_assert(0 < 1, "There is no slot for us"); |
2036 | | |
2037 | | MOZ_CAN_RUN_SCRIPT static bool |
2038 | | setPointerCapture(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2039 | 0 | { |
2040 | 0 | AUTO_PROFILER_LABEL_FAST("Element.setPointerCapture", DOM, cx); |
2041 | 0 |
|
2042 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
2043 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.setPointerCapture"); |
2044 | 0 | } |
2045 | 0 | int32_t arg0; |
2046 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) { |
2047 | 0 | return false; |
2048 | 0 | } |
2049 | 0 | FastErrorResult rv; |
2050 | 0 | self->SetPointerCapture(arg0, rv); |
2051 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
2052 | 0 | return false; |
2053 | 0 | } |
2054 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2055 | 0 | args.rval().setUndefined(); |
2056 | 0 | return true; |
2057 | 0 | } |
2058 | | |
2059 | | static const JSJitInfo setPointerCapture_methodinfo = { |
2060 | | { (JSJitGetterOp)setPointerCapture }, |
2061 | | { prototypes::id::Element }, |
2062 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2063 | | JSJitInfo::Method, |
2064 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2065 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
2066 | | false, /* isInfallible. False in setters. */ |
2067 | | false, /* isMovable. Not relevant for setters. */ |
2068 | | false, /* isEliminatable. Not relevant for setters. */ |
2069 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2070 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2071 | | false, /* isTypedMethod. Only relevant for methods. */ |
2072 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2073 | | }; |
2074 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2075 | | static_assert(0 < 1, "There is no slot for us"); |
2076 | | |
2077 | | MOZ_CAN_RUN_SCRIPT static bool |
2078 | | releasePointerCapture(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2079 | 0 | { |
2080 | 0 | AUTO_PROFILER_LABEL_FAST("Element.releasePointerCapture", DOM, cx); |
2081 | 0 |
|
2082 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
2083 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.releasePointerCapture"); |
2084 | 0 | } |
2085 | 0 | int32_t arg0; |
2086 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) { |
2087 | 0 | return false; |
2088 | 0 | } |
2089 | 0 | FastErrorResult rv; |
2090 | 0 | self->ReleasePointerCapture(arg0, rv); |
2091 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
2092 | 0 | return false; |
2093 | 0 | } |
2094 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2095 | 0 | args.rval().setUndefined(); |
2096 | 0 | return true; |
2097 | 0 | } |
2098 | | |
2099 | | static const JSJitInfo releasePointerCapture_methodinfo = { |
2100 | | { (JSJitGetterOp)releasePointerCapture }, |
2101 | | { prototypes::id::Element }, |
2102 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2103 | | JSJitInfo::Method, |
2104 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2105 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
2106 | | false, /* isInfallible. False in setters. */ |
2107 | | false, /* isMovable. Not relevant for setters. */ |
2108 | | false, /* isEliminatable. Not relevant for setters. */ |
2109 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2110 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2111 | | false, /* isTypedMethod. Only relevant for methods. */ |
2112 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2113 | | }; |
2114 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2115 | | static_assert(0 < 1, "There is no slot for us"); |
2116 | | |
2117 | | MOZ_CAN_RUN_SCRIPT static bool |
2118 | | hasPointerCapture(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2119 | 0 | { |
2120 | 0 | AUTO_PROFILER_LABEL_FAST("Element.hasPointerCapture", DOM, cx); |
2121 | 0 |
|
2122 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
2123 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.hasPointerCapture"); |
2124 | 0 | } |
2125 | 0 | int32_t arg0; |
2126 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) { |
2127 | 0 | return false; |
2128 | 0 | } |
2129 | 0 | bool result(self->HasPointerCapture(arg0)); |
2130 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2131 | 0 | args.rval().setBoolean(result); |
2132 | 0 | return true; |
2133 | 0 | } |
2134 | | |
2135 | | static const JSJitInfo hasPointerCapture_methodinfo = { |
2136 | | { (JSJitGetterOp)hasPointerCapture }, |
2137 | | { prototypes::id::Element }, |
2138 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2139 | | JSJitInfo::Method, |
2140 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2141 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
2142 | | false, /* isInfallible. False in setters. */ |
2143 | | false, /* isMovable. Not relevant for setters. */ |
2144 | | false, /* isEliminatable. Not relevant for setters. */ |
2145 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2146 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2147 | | false, /* isTypedMethod. Only relevant for methods. */ |
2148 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2149 | | }; |
2150 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2151 | | static_assert(0 < 1, "There is no slot for us"); |
2152 | | |
2153 | | MOZ_CAN_RUN_SCRIPT static bool |
2154 | | setCapture(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2155 | 0 | { |
2156 | 0 | AUTO_PROFILER_LABEL_FAST("Element.setCapture", DOM, cx); |
2157 | 0 |
|
2158 | 0 | bool arg0; |
2159 | 0 | if (args.hasDefined(0)) { |
2160 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) { |
2161 | 0 | return false; |
2162 | 0 | } |
2163 | 0 | } else { |
2164 | 0 | arg0 = false; |
2165 | 0 | } |
2166 | 0 | self->SetCapture(arg0); |
2167 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2168 | 0 | args.rval().setUndefined(); |
2169 | 0 | return true; |
2170 | 0 | } |
2171 | | |
2172 | | static const JSJitInfo setCapture_methodinfo = { |
2173 | | { (JSJitGetterOp)setCapture }, |
2174 | | { prototypes::id::Element }, |
2175 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2176 | | JSJitInfo::Method, |
2177 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2178 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
2179 | | false, /* isInfallible. False in setters. */ |
2180 | | false, /* isMovable. Not relevant for setters. */ |
2181 | | false, /* isEliminatable. Not relevant for setters. */ |
2182 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2183 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2184 | | false, /* isTypedMethod. Only relevant for methods. */ |
2185 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2186 | | }; |
2187 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2188 | | static_assert(0 < 1, "There is no slot for us"); |
2189 | | |
2190 | | MOZ_CAN_RUN_SCRIPT static bool |
2191 | | releaseCapture(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2192 | 0 | { |
2193 | 0 | AUTO_PROFILER_LABEL_FAST("Element.releaseCapture", DOM, cx); |
2194 | 0 |
|
2195 | 0 | self->ReleaseCapture(); |
2196 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2197 | 0 | args.rval().setUndefined(); |
2198 | 0 | return true; |
2199 | 0 | } |
2200 | | |
2201 | | static const JSJitInfo releaseCapture_methodinfo = { |
2202 | | { (JSJitGetterOp)releaseCapture }, |
2203 | | { prototypes::id::Element }, |
2204 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2205 | | JSJitInfo::Method, |
2206 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2207 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
2208 | | true, /* isInfallible. False in setters. */ |
2209 | | false, /* isMovable. Not relevant for setters. */ |
2210 | | false, /* isEliminatable. Not relevant for setters. */ |
2211 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2212 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2213 | | false, /* isTypedMethod. Only relevant for methods. */ |
2214 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2215 | | }; |
2216 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2217 | | static_assert(0 < 1, "There is no slot for us"); |
2218 | | |
2219 | | MOZ_CAN_RUN_SCRIPT static bool |
2220 | | setCaptureAlways(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2221 | 0 | { |
2222 | 0 | AUTO_PROFILER_LABEL_FAST("Element.setCaptureAlways", DOM, cx); |
2223 | 0 |
|
2224 | 0 | bool arg0; |
2225 | 0 | if (args.hasDefined(0)) { |
2226 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) { |
2227 | 0 | return false; |
2228 | 0 | } |
2229 | 0 | } else { |
2230 | 0 | arg0 = false; |
2231 | 0 | } |
2232 | 0 | self->SetCaptureAlways(arg0); |
2233 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2234 | 0 | args.rval().setUndefined(); |
2235 | 0 | return true; |
2236 | 0 | } |
2237 | | |
2238 | | static const JSJitInfo setCaptureAlways_methodinfo = { |
2239 | | { (JSJitGetterOp)setCaptureAlways }, |
2240 | | { prototypes::id::Element }, |
2241 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2242 | | JSJitInfo::Method, |
2243 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2244 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
2245 | | false, /* isInfallible. False in setters. */ |
2246 | | false, /* isMovable. Not relevant for setters. */ |
2247 | | false, /* isEliminatable. Not relevant for setters. */ |
2248 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2249 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2250 | | false, /* isTypedMethod. Only relevant for methods. */ |
2251 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2252 | | }; |
2253 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2254 | | static_assert(0 < 1, "There is no slot for us"); |
2255 | | |
2256 | | MOZ_CAN_RUN_SCRIPT static bool |
2257 | | getAttributeNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2258 | 0 | { |
2259 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getAttributeNode", DOM, cx); |
2260 | 0 |
|
2261 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
2262 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.getAttributeNode"); |
2263 | 0 | } |
2264 | 0 | binding_detail::FakeString arg0; |
2265 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
2266 | 0 | return false; |
2267 | 0 | } |
2268 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Attr>(self->GetAttributeNode(NonNullHelper(Constify(arg0))))); |
2269 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2270 | 0 | if (!result) { |
2271 | 0 | args.rval().setNull(); |
2272 | 0 | return true; |
2273 | 0 | } |
2274 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
2275 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
2276 | 0 | return false; |
2277 | 0 | } |
2278 | 0 | return true; |
2279 | 0 | } |
2280 | | |
2281 | | static const JSJitInfo getAttributeNode_methodinfo = { |
2282 | | { (JSJitGetterOp)getAttributeNode }, |
2283 | | { prototypes::id::Element }, |
2284 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2285 | | JSJitInfo::Method, |
2286 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2287 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
2288 | | false, /* isInfallible. False in setters. */ |
2289 | | false, /* isMovable. Not relevant for setters. */ |
2290 | | false, /* isEliminatable. Not relevant for setters. */ |
2291 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2292 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2293 | | false, /* isTypedMethod. Only relevant for methods. */ |
2294 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2295 | | }; |
2296 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2297 | | static_assert(0 < 1, "There is no slot for us"); |
2298 | | |
2299 | | MOZ_CAN_RUN_SCRIPT static bool |
2300 | | setAttributeNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2301 | 0 | { |
2302 | 0 | AUTO_PROFILER_LABEL_FAST("Element.setAttributeNode", DOM, cx); |
2303 | 0 |
|
2304 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
2305 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.setAttributeNode"); |
2306 | 0 | } |
2307 | 0 | NonNull<mozilla::dom::Attr> arg0; |
2308 | 0 | if (args[0].isObject()) { |
2309 | 0 | { |
2310 | 0 | nsresult rv = UnwrapObject<prototypes::id::Attr, mozilla::dom::Attr>(args[0], arg0); |
2311 | 0 | if (NS_FAILED(rv)) { |
2312 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Element.setAttributeNode", "Attr"); |
2313 | 0 | return false; |
2314 | 0 | } |
2315 | 0 | } |
2316 | 0 | } else { |
2317 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Element.setAttributeNode"); |
2318 | 0 | return false; |
2319 | 0 | } |
2320 | 0 | Maybe<AutoCEReaction> ceReaction; |
2321 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
2322 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
2323 | 0 | if (docGroup) { |
2324 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
2325 | 0 | } |
2326 | 0 | } |
2327 | 0 | FastErrorResult rv; |
2328 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Attr>(self->SetAttributeNode(MOZ_KnownLive(NonNullHelper(arg0)), rv))); |
2329 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
2330 | 0 | return false; |
2331 | 0 | } |
2332 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2333 | 0 | if (!result) { |
2334 | 0 | args.rval().setNull(); |
2335 | 0 | return true; |
2336 | 0 | } |
2337 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
2338 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
2339 | 0 | return false; |
2340 | 0 | } |
2341 | 0 | return true; |
2342 | 0 | } |
2343 | | |
2344 | | static const JSJitInfo setAttributeNode_methodinfo = { |
2345 | | { (JSJitGetterOp)setAttributeNode }, |
2346 | | { prototypes::id::Element }, |
2347 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2348 | | JSJitInfo::Method, |
2349 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2350 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
2351 | | false, /* isInfallible. False in setters. */ |
2352 | | false, /* isMovable. Not relevant for setters. */ |
2353 | | false, /* isEliminatable. Not relevant for setters. */ |
2354 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2355 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2356 | | false, /* isTypedMethod. Only relevant for methods. */ |
2357 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2358 | | }; |
2359 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2360 | | static_assert(0 < 1, "There is no slot for us"); |
2361 | | |
2362 | | MOZ_CAN_RUN_SCRIPT static bool |
2363 | | removeAttributeNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2364 | 0 | { |
2365 | 0 | AUTO_PROFILER_LABEL_FAST("Element.removeAttributeNode", DOM, cx); |
2366 | 0 |
|
2367 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
2368 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.removeAttributeNode"); |
2369 | 0 | } |
2370 | 0 | NonNull<mozilla::dom::Attr> arg0; |
2371 | 0 | if (args[0].isObject()) { |
2372 | 0 | { |
2373 | 0 | nsresult rv = UnwrapObject<prototypes::id::Attr, mozilla::dom::Attr>(args[0], arg0); |
2374 | 0 | if (NS_FAILED(rv)) { |
2375 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Element.removeAttributeNode", "Attr"); |
2376 | 0 | return false; |
2377 | 0 | } |
2378 | 0 | } |
2379 | 0 | } else { |
2380 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Element.removeAttributeNode"); |
2381 | 0 | return false; |
2382 | 0 | } |
2383 | 0 | Maybe<AutoCEReaction> ceReaction; |
2384 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
2385 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
2386 | 0 | if (docGroup) { |
2387 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
2388 | 0 | } |
2389 | 0 | } |
2390 | 0 | FastErrorResult rv; |
2391 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Attr>(self->RemoveAttributeNode(MOZ_KnownLive(NonNullHelper(arg0)), rv))); |
2392 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
2393 | 0 | return false; |
2394 | 0 | } |
2395 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2396 | 0 | if (!result) { |
2397 | 0 | args.rval().setNull(); |
2398 | 0 | return true; |
2399 | 0 | } |
2400 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
2401 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
2402 | 0 | return false; |
2403 | 0 | } |
2404 | 0 | return true; |
2405 | 0 | } |
2406 | | |
2407 | | static const JSJitInfo removeAttributeNode_methodinfo = { |
2408 | | { (JSJitGetterOp)removeAttributeNode }, |
2409 | | { prototypes::id::Element }, |
2410 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2411 | | JSJitInfo::Method, |
2412 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2413 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
2414 | | false, /* isInfallible. False in setters. */ |
2415 | | false, /* isMovable. Not relevant for setters. */ |
2416 | | false, /* isEliminatable. Not relevant for setters. */ |
2417 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2418 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2419 | | false, /* isTypedMethod. Only relevant for methods. */ |
2420 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2421 | | }; |
2422 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2423 | | static_assert(0 < 1, "There is no slot for us"); |
2424 | | |
2425 | | MOZ_CAN_RUN_SCRIPT static bool |
2426 | | getAttributeNodeNS(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2427 | 0 | { |
2428 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getAttributeNodeNS", DOM, cx); |
2429 | 0 |
|
2430 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
2431 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.getAttributeNodeNS"); |
2432 | 0 | } |
2433 | 0 | binding_detail::FakeString arg0; |
2434 | 0 | if (!ConvertJSValueToString(cx, args[0], eNull, eNull, arg0)) { |
2435 | 0 | return false; |
2436 | 0 | } |
2437 | 0 | binding_detail::FakeString arg1; |
2438 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
2439 | 0 | return false; |
2440 | 0 | } |
2441 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Attr>(self->GetAttributeNodeNS(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1))))); |
2442 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2443 | 0 | if (!result) { |
2444 | 0 | args.rval().setNull(); |
2445 | 0 | return true; |
2446 | 0 | } |
2447 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
2448 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
2449 | 0 | return false; |
2450 | 0 | } |
2451 | 0 | return true; |
2452 | 0 | } |
2453 | | |
2454 | | static const JSJitInfo getAttributeNodeNS_methodinfo = { |
2455 | | { (JSJitGetterOp)getAttributeNodeNS }, |
2456 | | { prototypes::id::Element }, |
2457 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2458 | | JSJitInfo::Method, |
2459 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2460 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
2461 | | false, /* isInfallible. False in setters. */ |
2462 | | false, /* isMovable. Not relevant for setters. */ |
2463 | | false, /* isEliminatable. Not relevant for setters. */ |
2464 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2465 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2466 | | false, /* isTypedMethod. Only relevant for methods. */ |
2467 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2468 | | }; |
2469 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2470 | | static_assert(0 < 1, "There is no slot for us"); |
2471 | | |
2472 | | MOZ_CAN_RUN_SCRIPT static bool |
2473 | | setAttributeNodeNS(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2474 | 0 | { |
2475 | 0 | AUTO_PROFILER_LABEL_FAST("Element.setAttributeNodeNS", DOM, cx); |
2476 | 0 |
|
2477 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
2478 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.setAttributeNodeNS"); |
2479 | 0 | } |
2480 | 0 | NonNull<mozilla::dom::Attr> arg0; |
2481 | 0 | if (args[0].isObject()) { |
2482 | 0 | { |
2483 | 0 | nsresult rv = UnwrapObject<prototypes::id::Attr, mozilla::dom::Attr>(args[0], arg0); |
2484 | 0 | if (NS_FAILED(rv)) { |
2485 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Element.setAttributeNodeNS", "Attr"); |
2486 | 0 | return false; |
2487 | 0 | } |
2488 | 0 | } |
2489 | 0 | } else { |
2490 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Element.setAttributeNodeNS"); |
2491 | 0 | return false; |
2492 | 0 | } |
2493 | 0 | Maybe<AutoCEReaction> ceReaction; |
2494 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
2495 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
2496 | 0 | if (docGroup) { |
2497 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
2498 | 0 | } |
2499 | 0 | } |
2500 | 0 | FastErrorResult rv; |
2501 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Attr>(self->SetAttributeNodeNS(MOZ_KnownLive(NonNullHelper(arg0)), rv))); |
2502 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
2503 | 0 | return false; |
2504 | 0 | } |
2505 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2506 | 0 | if (!result) { |
2507 | 0 | args.rval().setNull(); |
2508 | 0 | return true; |
2509 | 0 | } |
2510 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
2511 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
2512 | 0 | return false; |
2513 | 0 | } |
2514 | 0 | return true; |
2515 | 0 | } |
2516 | | |
2517 | | static const JSJitInfo setAttributeNodeNS_methodinfo = { |
2518 | | { (JSJitGetterOp)setAttributeNodeNS }, |
2519 | | { prototypes::id::Element }, |
2520 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2521 | | JSJitInfo::Method, |
2522 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2523 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
2524 | | false, /* isInfallible. False in setters. */ |
2525 | | false, /* isMovable. Not relevant for setters. */ |
2526 | | false, /* isEliminatable. Not relevant for setters. */ |
2527 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2528 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2529 | | false, /* isTypedMethod. Only relevant for methods. */ |
2530 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2531 | | }; |
2532 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2533 | | static_assert(0 < 1, "There is no slot for us"); |
2534 | | |
2535 | | MOZ_CAN_RUN_SCRIPT static bool |
2536 | | scrollByNoFlush(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2537 | 0 | { |
2538 | 0 | AUTO_PROFILER_LABEL_FAST("Element.scrollByNoFlush", DOM, cx); |
2539 | 0 |
|
2540 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
2541 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.scrollByNoFlush"); |
2542 | 0 | } |
2543 | 0 | int32_t arg0; |
2544 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) { |
2545 | 0 | return false; |
2546 | 0 | } |
2547 | 0 | int32_t arg1; |
2548 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
2549 | 0 | return false; |
2550 | 0 | } |
2551 | 0 | bool result(self->ScrollByNoFlush(arg0, arg1)); |
2552 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2553 | 0 | args.rval().setBoolean(result); |
2554 | 0 | return true; |
2555 | 0 | } |
2556 | | |
2557 | | static const JSJitInfo scrollByNoFlush_methodinfo = { |
2558 | | { (JSJitGetterOp)scrollByNoFlush }, |
2559 | | { prototypes::id::Element }, |
2560 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2561 | | JSJitInfo::Method, |
2562 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2563 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
2564 | | false, /* isInfallible. False in setters. */ |
2565 | | false, /* isMovable. Not relevant for setters. */ |
2566 | | false, /* isEliminatable. Not relevant for setters. */ |
2567 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2568 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2569 | | false, /* isTypedMethod. Only relevant for methods. */ |
2570 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2571 | | }; |
2572 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2573 | | static_assert(0 < 1, "There is no slot for us"); |
2574 | | |
2575 | | MOZ_CAN_RUN_SCRIPT static bool |
2576 | | getTransformToAncestor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2577 | 0 | { |
2578 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getTransformToAncestor", DOM, cx); |
2579 | 0 |
|
2580 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
2581 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.getTransformToAncestor"); |
2582 | 0 | } |
2583 | 0 | NonNull<mozilla::dom::Element> arg0; |
2584 | 0 | if (args[0].isObject()) { |
2585 | 0 | { |
2586 | 0 | nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0); |
2587 | 0 | if (NS_FAILED(rv)) { |
2588 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Element.getTransformToAncestor", "Element"); |
2589 | 0 | return false; |
2590 | 0 | } |
2591 | 0 | } |
2592 | 0 | } else { |
2593 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Element.getTransformToAncestor"); |
2594 | 0 | return false; |
2595 | 0 | } |
2596 | 0 | auto result(StrongOrRawPtr<mozilla::dom::DOMMatrixReadOnly>(self->GetTransformToAncestor(MOZ_KnownLive(NonNullHelper(arg0))))); |
2597 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2598 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
2599 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
2600 | 0 | return false; |
2601 | 0 | } |
2602 | 0 | return true; |
2603 | 0 | } |
2604 | | |
2605 | | static const JSJitInfo getTransformToAncestor_methodinfo = { |
2606 | | { (JSJitGetterOp)getTransformToAncestor }, |
2607 | | { prototypes::id::Element }, |
2608 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2609 | | JSJitInfo::Method, |
2610 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2611 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
2612 | | false, /* isInfallible. False in setters. */ |
2613 | | false, /* isMovable. Not relevant for setters. */ |
2614 | | false, /* isEliminatable. Not relevant for setters. */ |
2615 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2616 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2617 | | false, /* isTypedMethod. Only relevant for methods. */ |
2618 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2619 | | }; |
2620 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2621 | | static_assert(0 < 1, "There is no slot for us"); |
2622 | | |
2623 | | MOZ_CAN_RUN_SCRIPT static bool |
2624 | | getTransformToParent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2625 | 0 | { |
2626 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getTransformToParent", DOM, cx); |
2627 | 0 |
|
2628 | 0 | auto result(StrongOrRawPtr<mozilla::dom::DOMMatrixReadOnly>(self->GetTransformToParent())); |
2629 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2630 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
2631 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
2632 | 0 | return false; |
2633 | 0 | } |
2634 | 0 | return true; |
2635 | 0 | } |
2636 | | |
2637 | | static const JSJitInfo getTransformToParent_methodinfo = { |
2638 | | { (JSJitGetterOp)getTransformToParent }, |
2639 | | { prototypes::id::Element }, |
2640 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2641 | | JSJitInfo::Method, |
2642 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2643 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
2644 | | false, /* isInfallible. False in setters. */ |
2645 | | false, /* isMovable. Not relevant for setters. */ |
2646 | | false, /* isEliminatable. Not relevant for setters. */ |
2647 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2648 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2649 | | false, /* isTypedMethod. Only relevant for methods. */ |
2650 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2651 | | }; |
2652 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2653 | | static_assert(0 < 1, "There is no slot for us"); |
2654 | | |
2655 | | MOZ_CAN_RUN_SCRIPT static bool |
2656 | | getTransformToViewport(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2657 | 0 | { |
2658 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getTransformToViewport", DOM, cx); |
2659 | 0 |
|
2660 | 0 | auto result(StrongOrRawPtr<mozilla::dom::DOMMatrixReadOnly>(self->GetTransformToViewport())); |
2661 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2662 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
2663 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
2664 | 0 | return false; |
2665 | 0 | } |
2666 | 0 | return true; |
2667 | 0 | } |
2668 | | |
2669 | | static const JSJitInfo getTransformToViewport_methodinfo = { |
2670 | | { (JSJitGetterOp)getTransformToViewport }, |
2671 | | { prototypes::id::Element }, |
2672 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2673 | | JSJitInfo::Method, |
2674 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2675 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
2676 | | false, /* isInfallible. False in setters. */ |
2677 | | false, /* isMovable. Not relevant for setters. */ |
2678 | | false, /* isEliminatable. Not relevant for setters. */ |
2679 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2680 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2681 | | false, /* isTypedMethod. Only relevant for methods. */ |
2682 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2683 | | }; |
2684 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2685 | | static_assert(0 < 1, "There is no slot for us"); |
2686 | | |
2687 | | MOZ_CAN_RUN_SCRIPT static bool |
2688 | | getClientRects(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2689 | 0 | { |
2690 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getClientRects", DOM, cx); |
2691 | 0 |
|
2692 | 0 | auto result(StrongOrRawPtr<mozilla::dom::DOMRectList>(self->GetClientRects())); |
2693 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2694 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
2695 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
2696 | 0 | return false; |
2697 | 0 | } |
2698 | 0 | return true; |
2699 | 0 | } |
2700 | | |
2701 | | static const JSJitInfo getClientRects_methodinfo = { |
2702 | | { (JSJitGetterOp)getClientRects }, |
2703 | | { prototypes::id::Element }, |
2704 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2705 | | JSJitInfo::Method, |
2706 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2707 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
2708 | | false, /* isInfallible. False in setters. */ |
2709 | | false, /* isMovable. Not relevant for setters. */ |
2710 | | false, /* isEliminatable. Not relevant for setters. */ |
2711 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2712 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2713 | | false, /* isTypedMethod. Only relevant for methods. */ |
2714 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2715 | | }; |
2716 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2717 | | static_assert(0 < 1, "There is no slot for us"); |
2718 | | |
2719 | | MOZ_CAN_RUN_SCRIPT static bool |
2720 | | getBoundingClientRect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2721 | 0 | { |
2722 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getBoundingClientRect", DOM, cx); |
2723 | 0 |
|
2724 | 0 | auto result(StrongOrRawPtr<mozilla::dom::DOMRect>(self->GetBoundingClientRect())); |
2725 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2726 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
2727 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
2728 | 0 | return false; |
2729 | 0 | } |
2730 | 0 | return true; |
2731 | 0 | } |
2732 | | |
2733 | | static const JSJitInfo getBoundingClientRect_methodinfo = { |
2734 | | { (JSJitGetterOp)getBoundingClientRect }, |
2735 | | { prototypes::id::Element }, |
2736 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2737 | | JSJitInfo::Method, |
2738 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2739 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
2740 | | false, /* isInfallible. False in setters. */ |
2741 | | false, /* isMovable. Not relevant for setters. */ |
2742 | | false, /* isEliminatable. Not relevant for setters. */ |
2743 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2744 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2745 | | false, /* isTypedMethod. Only relevant for methods. */ |
2746 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2747 | | }; |
2748 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2749 | | static_assert(0 < 1, "There is no slot for us"); |
2750 | | |
2751 | | MOZ_CAN_RUN_SCRIPT static bool |
2752 | | scrollIntoView(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2753 | 0 | { |
2754 | 0 | AUTO_PROFILER_LABEL_FAST("Element.scrollIntoView", DOM, cx); |
2755 | 0 |
|
2756 | 0 | BooleanOrScrollIntoViewOptions arg0; |
2757 | 0 | BooleanOrScrollIntoViewOptionsArgument arg0_holder(arg0); |
2758 | 0 | if (!(args.hasDefined(0))) { |
2759 | 0 | if (!arg0.RawSetAsScrollIntoViewOptions().Init(cx, JS::NullHandleValue, "Member of BooleanOrScrollIntoViewOptions")) { |
2760 | 0 | return false; |
2761 | 0 | } |
2762 | 0 | } else { |
2763 | 0 | { |
2764 | 0 | bool done = false, failed = false, tryNext; |
2765 | 0 | if (!done) { |
2766 | 0 | done = (failed = !arg0_holder.TrySetToScrollIntoViewOptions(cx, args[0], tryNext, false)) || !tryNext; |
2767 | 0 | } |
2768 | 0 | if (!done) { |
2769 | 0 | do { |
2770 | 0 | done = (failed = !arg0_holder.TrySetToBoolean(cx, args[0], tryNext)) || !tryNext; |
2771 | 0 | break; |
2772 | 0 | } while (false); |
2773 | 0 | } |
2774 | 0 | if (failed) { |
2775 | 0 | return false; |
2776 | 0 | } |
2777 | 0 | if (!done) { |
2778 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of Element.scrollIntoView", "ScrollIntoViewOptions"); |
2779 | 0 | return false; |
2780 | 0 | } |
2781 | 0 | } |
2782 | 0 | } |
2783 | 0 | self->ScrollIntoView(Constify(arg0)); |
2784 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2785 | 0 | args.rval().setUndefined(); |
2786 | 0 | return true; |
2787 | 0 | } |
2788 | | |
2789 | | static const JSJitInfo scrollIntoView_methodinfo = { |
2790 | | { (JSJitGetterOp)scrollIntoView }, |
2791 | | { prototypes::id::Element }, |
2792 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2793 | | JSJitInfo::Method, |
2794 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2795 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
2796 | | false, /* isInfallible. False in setters. */ |
2797 | | false, /* isMovable. Not relevant for setters. */ |
2798 | | false, /* isEliminatable. Not relevant for setters. */ |
2799 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2800 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2801 | | false, /* isTypedMethod. Only relevant for methods. */ |
2802 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2803 | | }; |
2804 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2805 | | static_assert(0 < 1, "There is no slot for us"); |
2806 | | |
2807 | | MOZ_CAN_RUN_SCRIPT static bool |
2808 | | get_scrollTop(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
2809 | 0 | { |
2810 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.scrollTop", DOM, cx); |
2811 | 0 |
|
2812 | 0 | int32_t result(self->ScrollTop()); |
2813 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2814 | 0 | args.rval().setInt32(int32_t(result)); |
2815 | 0 | return true; |
2816 | 0 | } |
2817 | | |
2818 | | MOZ_CAN_RUN_SCRIPT static bool |
2819 | | set_scrollTop(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitSetterCallArgs args) |
2820 | 0 | { |
2821 | 0 | AUTO_PROFILER_LABEL_FAST("set Element.scrollTop", DOM, cx); |
2822 | 0 |
|
2823 | 0 | int32_t arg0; |
2824 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) { |
2825 | 0 | return false; |
2826 | 0 | } |
2827 | 0 | self->SetScrollTop(arg0); |
2828 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2829 | 0 |
|
2830 | 0 | return true; |
2831 | 0 | } |
2832 | | |
2833 | | static const JSJitInfo scrollTop_getterinfo = { |
2834 | | { (JSJitGetterOp)get_scrollTop }, |
2835 | | { prototypes::id::Element }, |
2836 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2837 | | JSJitInfo::Getter, |
2838 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2839 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
2840 | | true, /* isInfallible. False in setters. */ |
2841 | | false, /* isMovable. Not relevant for setters. */ |
2842 | | false, /* isEliminatable. Not relevant for setters. */ |
2843 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2844 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2845 | | false, /* isTypedMethod. Only relevant for methods. */ |
2846 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2847 | | }; |
2848 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2849 | | static_assert(0 < 1, "There is no slot for us"); |
2850 | | static const JSJitInfo scrollTop_setterinfo = { |
2851 | | { (JSJitGetterOp)set_scrollTop }, |
2852 | | { prototypes::id::Element }, |
2853 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2854 | | JSJitInfo::Setter, |
2855 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2856 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
2857 | | false, /* isInfallible. False in setters. */ |
2858 | | false, /* isMovable. Not relevant for setters. */ |
2859 | | false, /* isEliminatable. Not relevant for setters. */ |
2860 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2861 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2862 | | false, /* isTypedMethod. Only relevant for methods. */ |
2863 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2864 | | }; |
2865 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2866 | | static_assert(0 < 1, "There is no slot for us"); |
2867 | | |
2868 | | MOZ_CAN_RUN_SCRIPT static bool |
2869 | | get_scrollLeft(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
2870 | 0 | { |
2871 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.scrollLeft", DOM, cx); |
2872 | 0 |
|
2873 | 0 | int32_t result(self->ScrollLeft()); |
2874 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2875 | 0 | args.rval().setInt32(int32_t(result)); |
2876 | 0 | return true; |
2877 | 0 | } |
2878 | | |
2879 | | MOZ_CAN_RUN_SCRIPT static bool |
2880 | | set_scrollLeft(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitSetterCallArgs args) |
2881 | 0 | { |
2882 | 0 | AUTO_PROFILER_LABEL_FAST("set Element.scrollLeft", DOM, cx); |
2883 | 0 |
|
2884 | 0 | int32_t arg0; |
2885 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) { |
2886 | 0 | return false; |
2887 | 0 | } |
2888 | 0 | self->SetScrollLeft(arg0); |
2889 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2890 | 0 |
|
2891 | 0 | return true; |
2892 | 0 | } |
2893 | | |
2894 | | static const JSJitInfo scrollLeft_getterinfo = { |
2895 | | { (JSJitGetterOp)get_scrollLeft }, |
2896 | | { prototypes::id::Element }, |
2897 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2898 | | JSJitInfo::Getter, |
2899 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2900 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
2901 | | true, /* isInfallible. False in setters. */ |
2902 | | false, /* isMovable. Not relevant for setters. */ |
2903 | | false, /* isEliminatable. Not relevant for setters. */ |
2904 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2905 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2906 | | false, /* isTypedMethod. Only relevant for methods. */ |
2907 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2908 | | }; |
2909 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2910 | | static_assert(0 < 1, "There is no slot for us"); |
2911 | | static const JSJitInfo scrollLeft_setterinfo = { |
2912 | | { (JSJitGetterOp)set_scrollLeft }, |
2913 | | { prototypes::id::Element }, |
2914 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2915 | | JSJitInfo::Setter, |
2916 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2917 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
2918 | | false, /* isInfallible. False in setters. */ |
2919 | | false, /* isMovable. Not relevant for setters. */ |
2920 | | false, /* isEliminatable. Not relevant for setters. */ |
2921 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2922 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2923 | | false, /* isTypedMethod. Only relevant for methods. */ |
2924 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2925 | | }; |
2926 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2927 | | static_assert(0 < 1, "There is no slot for us"); |
2928 | | |
2929 | | MOZ_CAN_RUN_SCRIPT static bool |
2930 | | get_scrollWidth(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
2931 | 0 | { |
2932 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.scrollWidth", DOM, cx); |
2933 | 0 |
|
2934 | 0 | int32_t result(self->ScrollWidth()); |
2935 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2936 | 0 | args.rval().setInt32(int32_t(result)); |
2937 | 0 | return true; |
2938 | 0 | } |
2939 | | |
2940 | | static const JSJitInfo scrollWidth_getterinfo = { |
2941 | | { (JSJitGetterOp)get_scrollWidth }, |
2942 | | { prototypes::id::Element }, |
2943 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2944 | | JSJitInfo::Getter, |
2945 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2946 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
2947 | | true, /* isInfallible. False in setters. */ |
2948 | | false, /* isMovable. Not relevant for setters. */ |
2949 | | false, /* isEliminatable. Not relevant for setters. */ |
2950 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2951 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2952 | | false, /* isTypedMethod. Only relevant for methods. */ |
2953 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2954 | | }; |
2955 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2956 | | static_assert(0 < 1, "There is no slot for us"); |
2957 | | |
2958 | | MOZ_CAN_RUN_SCRIPT static bool |
2959 | | get_scrollHeight(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
2960 | 0 | { |
2961 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.scrollHeight", DOM, cx); |
2962 | 0 |
|
2963 | 0 | int32_t result(self->ScrollHeight()); |
2964 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2965 | 0 | args.rval().setInt32(int32_t(result)); |
2966 | 0 | return true; |
2967 | 0 | } |
2968 | | |
2969 | | static const JSJitInfo scrollHeight_getterinfo = { |
2970 | | { (JSJitGetterOp)get_scrollHeight }, |
2971 | | { prototypes::id::Element }, |
2972 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
2973 | | JSJitInfo::Getter, |
2974 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2975 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
2976 | | true, /* isInfallible. False in setters. */ |
2977 | | false, /* isMovable. Not relevant for setters. */ |
2978 | | false, /* isEliminatable. Not relevant for setters. */ |
2979 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2980 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2981 | | false, /* isTypedMethod. Only relevant for methods. */ |
2982 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2983 | | }; |
2984 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2985 | | static_assert(0 < 1, "There is no slot for us"); |
2986 | | |
2987 | | MOZ_CAN_RUN_SCRIPT static bool |
2988 | | scroll(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
2989 | 0 | { |
2990 | 0 | AUTO_PROFILER_LABEL_FAST("Element.scroll", DOM, cx); |
2991 | 0 |
|
2992 | 0 | unsigned argcount = std::min(args.length(), 2u); |
2993 | 0 | switch (argcount) { |
2994 | 0 | case 0: { |
2995 | 0 | MOZ_FALLTHROUGH; |
2996 | 0 | } |
2997 | 0 | case 1: { |
2998 | 0 | binding_detail::FastScrollToOptions arg0; |
2999 | 0 | if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1 of Element.scroll", false)) { |
3000 | 0 | return false; |
3001 | 0 | } |
3002 | 0 | self->Scroll(Constify(arg0)); |
3003 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3004 | 0 | args.rval().setUndefined(); |
3005 | 0 | return true; |
3006 | 0 | break; |
3007 | 0 | } |
3008 | 0 | case 2: { |
3009 | 0 | double arg0; |
3010 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) { |
3011 | 0 | return false; |
3012 | 0 | } |
3013 | 0 | double arg1; |
3014 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) { |
3015 | 0 | return false; |
3016 | 0 | } |
3017 | 0 | self->Scroll(arg0, arg1); |
3018 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3019 | 0 | args.rval().setUndefined(); |
3020 | 0 | return true; |
3021 | 0 | break; |
3022 | 0 | } |
3023 | 0 | default: { |
3024 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.scroll"); |
3025 | 0 | break; |
3026 | 0 | } |
3027 | 0 | } |
3028 | 0 | MOZ_CRASH("We have an always-returning default case"); |
3029 | 0 | return false; |
3030 | 0 | } |
3031 | | |
3032 | | static const JSJitInfo scroll_methodinfo = { |
3033 | | { (JSJitGetterOp)scroll }, |
3034 | | { prototypes::id::Element }, |
3035 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3036 | | JSJitInfo::Method, |
3037 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3038 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
3039 | | false, /* isInfallible. False in setters. */ |
3040 | | false, /* isMovable. Not relevant for setters. */ |
3041 | | false, /* isEliminatable. Not relevant for setters. */ |
3042 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3043 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3044 | | false, /* isTypedMethod. Only relevant for methods. */ |
3045 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3046 | | }; |
3047 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3048 | | static_assert(0 < 1, "There is no slot for us"); |
3049 | | |
3050 | | MOZ_CAN_RUN_SCRIPT static bool |
3051 | | scrollTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
3052 | 0 | { |
3053 | 0 | AUTO_PROFILER_LABEL_FAST("Element.scrollTo", DOM, cx); |
3054 | 0 |
|
3055 | 0 | unsigned argcount = std::min(args.length(), 2u); |
3056 | 0 | switch (argcount) { |
3057 | 0 | case 0: { |
3058 | 0 | MOZ_FALLTHROUGH; |
3059 | 0 | } |
3060 | 0 | case 1: { |
3061 | 0 | binding_detail::FastScrollToOptions arg0; |
3062 | 0 | if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1 of Element.scrollTo", false)) { |
3063 | 0 | return false; |
3064 | 0 | } |
3065 | 0 | self->ScrollTo(Constify(arg0)); |
3066 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3067 | 0 | args.rval().setUndefined(); |
3068 | 0 | return true; |
3069 | 0 | break; |
3070 | 0 | } |
3071 | 0 | case 2: { |
3072 | 0 | double arg0; |
3073 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) { |
3074 | 0 | return false; |
3075 | 0 | } |
3076 | 0 | double arg1; |
3077 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) { |
3078 | 0 | return false; |
3079 | 0 | } |
3080 | 0 | self->ScrollTo(arg0, arg1); |
3081 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3082 | 0 | args.rval().setUndefined(); |
3083 | 0 | return true; |
3084 | 0 | break; |
3085 | 0 | } |
3086 | 0 | default: { |
3087 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.scrollTo"); |
3088 | 0 | break; |
3089 | 0 | } |
3090 | 0 | } |
3091 | 0 | MOZ_CRASH("We have an always-returning default case"); |
3092 | 0 | return false; |
3093 | 0 | } |
3094 | | |
3095 | | static const JSJitInfo scrollTo_methodinfo = { |
3096 | | { (JSJitGetterOp)scrollTo }, |
3097 | | { prototypes::id::Element }, |
3098 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3099 | | JSJitInfo::Method, |
3100 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3101 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
3102 | | false, /* isInfallible. False in setters. */ |
3103 | | false, /* isMovable. Not relevant for setters. */ |
3104 | | false, /* isEliminatable. Not relevant for setters. */ |
3105 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3106 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3107 | | false, /* isTypedMethod. Only relevant for methods. */ |
3108 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3109 | | }; |
3110 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3111 | | static_assert(0 < 1, "There is no slot for us"); |
3112 | | |
3113 | | MOZ_CAN_RUN_SCRIPT static bool |
3114 | | scrollBy(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
3115 | 0 | { |
3116 | 0 | AUTO_PROFILER_LABEL_FAST("Element.scrollBy", DOM, cx); |
3117 | 0 |
|
3118 | 0 | unsigned argcount = std::min(args.length(), 2u); |
3119 | 0 | switch (argcount) { |
3120 | 0 | case 0: { |
3121 | 0 | MOZ_FALLTHROUGH; |
3122 | 0 | } |
3123 | 0 | case 1: { |
3124 | 0 | binding_detail::FastScrollToOptions arg0; |
3125 | 0 | if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1 of Element.scrollBy", false)) { |
3126 | 0 | return false; |
3127 | 0 | } |
3128 | 0 | self->ScrollBy(Constify(arg0)); |
3129 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3130 | 0 | args.rval().setUndefined(); |
3131 | 0 | return true; |
3132 | 0 | break; |
3133 | 0 | } |
3134 | 0 | case 2: { |
3135 | 0 | double arg0; |
3136 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) { |
3137 | 0 | return false; |
3138 | 0 | } |
3139 | 0 | double arg1; |
3140 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) { |
3141 | 0 | return false; |
3142 | 0 | } |
3143 | 0 | self->ScrollBy(arg0, arg1); |
3144 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3145 | 0 | args.rval().setUndefined(); |
3146 | 0 | return true; |
3147 | 0 | break; |
3148 | 0 | } |
3149 | 0 | default: { |
3150 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.scrollBy"); |
3151 | 0 | break; |
3152 | 0 | } |
3153 | 0 | } |
3154 | 0 | MOZ_CRASH("We have an always-returning default case"); |
3155 | 0 | return false; |
3156 | 0 | } |
3157 | | |
3158 | | static const JSJitInfo scrollBy_methodinfo = { |
3159 | | { (JSJitGetterOp)scrollBy }, |
3160 | | { prototypes::id::Element }, |
3161 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3162 | | JSJitInfo::Method, |
3163 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3164 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
3165 | | false, /* isInfallible. False in setters. */ |
3166 | | false, /* isMovable. Not relevant for setters. */ |
3167 | | false, /* isEliminatable. Not relevant for setters. */ |
3168 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3169 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3170 | | false, /* isTypedMethod. Only relevant for methods. */ |
3171 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3172 | | }; |
3173 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3174 | | static_assert(0 < 1, "There is no slot for us"); |
3175 | | |
3176 | | MOZ_CAN_RUN_SCRIPT static bool |
3177 | | mozScrollSnap(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
3178 | 0 | { |
3179 | 0 | AUTO_PROFILER_LABEL_FAST("Element.mozScrollSnap", DOM, cx); |
3180 | 0 |
|
3181 | 0 | self->MozScrollSnap(); |
3182 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3183 | 0 | args.rval().setUndefined(); |
3184 | 0 | return true; |
3185 | 0 | } |
3186 | | |
3187 | | static const JSJitInfo mozScrollSnap_methodinfo = { |
3188 | | { (JSJitGetterOp)mozScrollSnap }, |
3189 | | { prototypes::id::Element }, |
3190 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3191 | | JSJitInfo::Method, |
3192 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3193 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
3194 | | true, /* isInfallible. False in setters. */ |
3195 | | false, /* isMovable. Not relevant for setters. */ |
3196 | | false, /* isEliminatable. Not relevant for setters. */ |
3197 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3198 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3199 | | false, /* isTypedMethod. Only relevant for methods. */ |
3200 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3201 | | }; |
3202 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3203 | | static_assert(0 < 1, "There is no slot for us"); |
3204 | | |
3205 | | MOZ_CAN_RUN_SCRIPT static bool |
3206 | | get_clientTop(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
3207 | 0 | { |
3208 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.clientTop", DOM, cx); |
3209 | 0 |
|
3210 | 0 | int32_t result(self->ClientTop()); |
3211 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3212 | 0 | args.rval().setInt32(int32_t(result)); |
3213 | 0 | return true; |
3214 | 0 | } |
3215 | | |
3216 | | static const JSJitInfo clientTop_getterinfo = { |
3217 | | { (JSJitGetterOp)get_clientTop }, |
3218 | | { prototypes::id::Element }, |
3219 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3220 | | JSJitInfo::Getter, |
3221 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3222 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
3223 | | true, /* isInfallible. False in setters. */ |
3224 | | false, /* isMovable. Not relevant for setters. */ |
3225 | | false, /* isEliminatable. Not relevant for setters. */ |
3226 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3227 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3228 | | false, /* isTypedMethod. Only relevant for methods. */ |
3229 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3230 | | }; |
3231 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3232 | | static_assert(0 < 1, "There is no slot for us"); |
3233 | | |
3234 | | MOZ_CAN_RUN_SCRIPT static bool |
3235 | | get_clientLeft(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
3236 | 0 | { |
3237 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.clientLeft", DOM, cx); |
3238 | 0 |
|
3239 | 0 | int32_t result(self->ClientLeft()); |
3240 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3241 | 0 | args.rval().setInt32(int32_t(result)); |
3242 | 0 | return true; |
3243 | 0 | } |
3244 | | |
3245 | | static const JSJitInfo clientLeft_getterinfo = { |
3246 | | { (JSJitGetterOp)get_clientLeft }, |
3247 | | { prototypes::id::Element }, |
3248 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3249 | | JSJitInfo::Getter, |
3250 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3251 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
3252 | | true, /* isInfallible. False in setters. */ |
3253 | | false, /* isMovable. Not relevant for setters. */ |
3254 | | false, /* isEliminatable. Not relevant for setters. */ |
3255 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3256 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3257 | | false, /* isTypedMethod. Only relevant for methods. */ |
3258 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3259 | | }; |
3260 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3261 | | static_assert(0 < 1, "There is no slot for us"); |
3262 | | |
3263 | | MOZ_CAN_RUN_SCRIPT static bool |
3264 | | get_clientWidth(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
3265 | 0 | { |
3266 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.clientWidth", DOM, cx); |
3267 | 0 |
|
3268 | 0 | int32_t result(self->ClientWidth()); |
3269 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3270 | 0 | args.rval().setInt32(int32_t(result)); |
3271 | 0 | return true; |
3272 | 0 | } |
3273 | | |
3274 | | static const JSJitInfo clientWidth_getterinfo = { |
3275 | | { (JSJitGetterOp)get_clientWidth }, |
3276 | | { prototypes::id::Element }, |
3277 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3278 | | JSJitInfo::Getter, |
3279 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3280 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
3281 | | true, /* isInfallible. False in setters. */ |
3282 | | false, /* isMovable. Not relevant for setters. */ |
3283 | | false, /* isEliminatable. Not relevant for setters. */ |
3284 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3285 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3286 | | false, /* isTypedMethod. Only relevant for methods. */ |
3287 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3288 | | }; |
3289 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3290 | | static_assert(0 < 1, "There is no slot for us"); |
3291 | | |
3292 | | MOZ_CAN_RUN_SCRIPT static bool |
3293 | | get_clientHeight(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
3294 | 0 | { |
3295 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.clientHeight", DOM, cx); |
3296 | 0 |
|
3297 | 0 | int32_t result(self->ClientHeight()); |
3298 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3299 | 0 | args.rval().setInt32(int32_t(result)); |
3300 | 0 | return true; |
3301 | 0 | } |
3302 | | |
3303 | | static const JSJitInfo clientHeight_getterinfo = { |
3304 | | { (JSJitGetterOp)get_clientHeight }, |
3305 | | { prototypes::id::Element }, |
3306 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3307 | | JSJitInfo::Getter, |
3308 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3309 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
3310 | | true, /* isInfallible. False in setters. */ |
3311 | | false, /* isMovable. Not relevant for setters. */ |
3312 | | false, /* isEliminatable. Not relevant for setters. */ |
3313 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3314 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3315 | | false, /* isTypedMethod. Only relevant for methods. */ |
3316 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3317 | | }; |
3318 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3319 | | static_assert(0 < 1, "There is no slot for us"); |
3320 | | |
3321 | | MOZ_CAN_RUN_SCRIPT static bool |
3322 | | get_scrollTopMin(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
3323 | 0 | { |
3324 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.scrollTopMin", DOM, cx); |
3325 | 0 |
|
3326 | 0 | int32_t result(self->ScrollTopMin()); |
3327 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3328 | 0 | args.rval().setInt32(int32_t(result)); |
3329 | 0 | return true; |
3330 | 0 | } |
3331 | | |
3332 | | static const JSJitInfo scrollTopMin_getterinfo = { |
3333 | | { (JSJitGetterOp)get_scrollTopMin }, |
3334 | | { prototypes::id::Element }, |
3335 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3336 | | JSJitInfo::Getter, |
3337 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3338 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
3339 | | true, /* isInfallible. False in setters. */ |
3340 | | false, /* isMovable. Not relevant for setters. */ |
3341 | | false, /* isEliminatable. Not relevant for setters. */ |
3342 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3343 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3344 | | false, /* isTypedMethod. Only relevant for methods. */ |
3345 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3346 | | }; |
3347 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3348 | | static_assert(0 < 1, "There is no slot for us"); |
3349 | | |
3350 | | MOZ_CAN_RUN_SCRIPT static bool |
3351 | | get_scrollTopMax(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
3352 | 0 | { |
3353 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.scrollTopMax", DOM, cx); |
3354 | 0 |
|
3355 | 0 | int32_t result(self->ScrollTopMax()); |
3356 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3357 | 0 | args.rval().setInt32(int32_t(result)); |
3358 | 0 | return true; |
3359 | 0 | } |
3360 | | |
3361 | | static const JSJitInfo scrollTopMax_getterinfo = { |
3362 | | { (JSJitGetterOp)get_scrollTopMax }, |
3363 | | { prototypes::id::Element }, |
3364 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3365 | | JSJitInfo::Getter, |
3366 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3367 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
3368 | | true, /* isInfallible. False in setters. */ |
3369 | | false, /* isMovable. Not relevant for setters. */ |
3370 | | false, /* isEliminatable. Not relevant for setters. */ |
3371 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3372 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3373 | | false, /* isTypedMethod. Only relevant for methods. */ |
3374 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3375 | | }; |
3376 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3377 | | static_assert(0 < 1, "There is no slot for us"); |
3378 | | |
3379 | | MOZ_CAN_RUN_SCRIPT static bool |
3380 | | get_scrollLeftMin(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
3381 | 0 | { |
3382 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.scrollLeftMin", DOM, cx); |
3383 | 0 |
|
3384 | 0 | int32_t result(self->ScrollLeftMin()); |
3385 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3386 | 0 | args.rval().setInt32(int32_t(result)); |
3387 | 0 | return true; |
3388 | 0 | } |
3389 | | |
3390 | | static const JSJitInfo scrollLeftMin_getterinfo = { |
3391 | | { (JSJitGetterOp)get_scrollLeftMin }, |
3392 | | { prototypes::id::Element }, |
3393 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3394 | | JSJitInfo::Getter, |
3395 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3396 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
3397 | | true, /* isInfallible. False in setters. */ |
3398 | | false, /* isMovable. Not relevant for setters. */ |
3399 | | false, /* isEliminatable. Not relevant for setters. */ |
3400 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3401 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3402 | | false, /* isTypedMethod. Only relevant for methods. */ |
3403 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3404 | | }; |
3405 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3406 | | static_assert(0 < 1, "There is no slot for us"); |
3407 | | |
3408 | | MOZ_CAN_RUN_SCRIPT static bool |
3409 | | get_scrollLeftMax(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
3410 | 0 | { |
3411 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.scrollLeftMax", DOM, cx); |
3412 | 0 |
|
3413 | 0 | int32_t result(self->ScrollLeftMax()); |
3414 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3415 | 0 | args.rval().setInt32(int32_t(result)); |
3416 | 0 | return true; |
3417 | 0 | } |
3418 | | |
3419 | | static const JSJitInfo scrollLeftMax_getterinfo = { |
3420 | | { (JSJitGetterOp)get_scrollLeftMax }, |
3421 | | { prototypes::id::Element }, |
3422 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3423 | | JSJitInfo::Getter, |
3424 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3425 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
3426 | | true, /* isInfallible. False in setters. */ |
3427 | | false, /* isMovable. Not relevant for setters. */ |
3428 | | false, /* isEliminatable. Not relevant for setters. */ |
3429 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3430 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3431 | | false, /* isTypedMethod. Only relevant for methods. */ |
3432 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3433 | | }; |
3434 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3435 | | static_assert(0 < 1, "There is no slot for us"); |
3436 | | |
3437 | | MOZ_CAN_RUN_SCRIPT static bool |
3438 | | get_innerHTML(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
3439 | 0 | { |
3440 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.innerHTML", DOM, cx); |
3441 | 0 |
|
3442 | 0 | binding_danger::OOMReporterInstantiator rv; |
3443 | 0 | DOMString result; |
3444 | 0 | self->GetInnerHTML(result, rv); |
3445 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
3446 | 0 | return false; |
3447 | 0 | } |
3448 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3449 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
3450 | 0 | return false; |
3451 | 0 | } |
3452 | 0 | return true; |
3453 | 0 | } |
3454 | | |
3455 | | MOZ_CAN_RUN_SCRIPT static bool |
3456 | | set_innerHTML(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitSetterCallArgs args) |
3457 | 0 | { |
3458 | 0 | AUTO_PROFILER_LABEL_FAST("set Element.innerHTML", DOM, cx); |
3459 | 0 |
|
3460 | 0 | binding_detail::FakeString arg0; |
3461 | 0 | if (!ConvertJSValueToString(cx, args[0], eEmpty, eStringify, arg0)) { |
3462 | 0 | return false; |
3463 | 0 | } |
3464 | 0 | Maybe<AutoCEReaction> ceReaction; |
3465 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
3466 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
3467 | 0 | if (docGroup) { |
3468 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
3469 | 0 | } |
3470 | 0 | } |
3471 | 0 | FastErrorResult rv; |
3472 | 0 | nsIPrincipal* subjectPrincipal; |
3473 | 0 | { |
3474 | 0 | JS::Realm* realm = js::GetContextRealm(cx); |
3475 | 0 | MOZ_ASSERT(realm); |
3476 | 0 | JSPrincipals* principals = JS::GetRealmPrincipals(realm); |
3477 | 0 | nsIPrincipal* principal = nsJSPrincipals::get(principals); |
3478 | 0 | if (nsContentUtils::IsSystemPrincipal(principal)) { |
3479 | 0 | principal = nullptr; |
3480 | 0 | } |
3481 | 0 |
|
3482 | 0 | subjectPrincipal = principal; |
3483 | 0 | } |
3484 | 0 | self->SetInnerHTML(NonNullHelper(Constify(arg0)), subjectPrincipal, rv); |
3485 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
3486 | 0 | return false; |
3487 | 0 | } |
3488 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3489 | 0 |
|
3490 | 0 | return true; |
3491 | 0 | } |
3492 | | |
3493 | | static const JSJitInfo innerHTML_getterinfo = { |
3494 | | { (JSJitGetterOp)get_innerHTML }, |
3495 | | { prototypes::id::Element }, |
3496 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3497 | | JSJitInfo::Getter, |
3498 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
3499 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
3500 | | false, /* isInfallible. False in setters. */ |
3501 | | true, /* isMovable. Not relevant for setters. */ |
3502 | | true, /* isEliminatable. Not relevant for setters. */ |
3503 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3504 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3505 | | false, /* isTypedMethod. Only relevant for methods. */ |
3506 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3507 | | }; |
3508 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3509 | | static_assert(0 < 1, "There is no slot for us"); |
3510 | | static const JSJitInfo innerHTML_setterinfo = { |
3511 | | { (JSJitGetterOp)set_innerHTML }, |
3512 | | { prototypes::id::Element }, |
3513 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3514 | | JSJitInfo::Setter, |
3515 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3516 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
3517 | | false, /* isInfallible. False in setters. */ |
3518 | | false, /* isMovable. Not relevant for setters. */ |
3519 | | false, /* isEliminatable. Not relevant for setters. */ |
3520 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3521 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3522 | | false, /* isTypedMethod. Only relevant for methods. */ |
3523 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3524 | | }; |
3525 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3526 | | static_assert(0 < 1, "There is no slot for us"); |
3527 | | |
3528 | | MOZ_CAN_RUN_SCRIPT static bool |
3529 | | get_outerHTML(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
3530 | 0 | { |
3531 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.outerHTML", DOM, cx); |
3532 | 0 |
|
3533 | 0 | DOMString result; |
3534 | 0 | self->GetOuterHTML(result); |
3535 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3536 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
3537 | 0 | return false; |
3538 | 0 | } |
3539 | 0 | return true; |
3540 | 0 | } |
3541 | | |
3542 | | MOZ_CAN_RUN_SCRIPT static bool |
3543 | | set_outerHTML(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitSetterCallArgs args) |
3544 | 0 | { |
3545 | 0 | AUTO_PROFILER_LABEL_FAST("set Element.outerHTML", DOM, cx); |
3546 | 0 |
|
3547 | 0 | binding_detail::FakeString arg0; |
3548 | 0 | if (!ConvertJSValueToString(cx, args[0], eEmpty, eStringify, arg0)) { |
3549 | 0 | return false; |
3550 | 0 | } |
3551 | 0 | Maybe<AutoCEReaction> ceReaction; |
3552 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
3553 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
3554 | 0 | if (docGroup) { |
3555 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
3556 | 0 | } |
3557 | 0 | } |
3558 | 0 | FastErrorResult rv; |
3559 | 0 | self->SetOuterHTML(NonNullHelper(Constify(arg0)), rv); |
3560 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
3561 | 0 | return false; |
3562 | 0 | } |
3563 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3564 | 0 |
|
3565 | 0 | return true; |
3566 | 0 | } |
3567 | | |
3568 | | static const JSJitInfo outerHTML_getterinfo = { |
3569 | | { (JSJitGetterOp)get_outerHTML }, |
3570 | | { prototypes::id::Element }, |
3571 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3572 | | JSJitInfo::Getter, |
3573 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
3574 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
3575 | | false, /* isInfallible. False in setters. */ |
3576 | | true, /* isMovable. Not relevant for setters. */ |
3577 | | true, /* isEliminatable. Not relevant for setters. */ |
3578 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3579 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3580 | | false, /* isTypedMethod. Only relevant for methods. */ |
3581 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3582 | | }; |
3583 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3584 | | static_assert(0 < 1, "There is no slot for us"); |
3585 | | static const JSJitInfo outerHTML_setterinfo = { |
3586 | | { (JSJitGetterOp)set_outerHTML }, |
3587 | | { prototypes::id::Element }, |
3588 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3589 | | JSJitInfo::Setter, |
3590 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3591 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
3592 | | false, /* isInfallible. False in setters. */ |
3593 | | false, /* isMovable. Not relevant for setters. */ |
3594 | | false, /* isEliminatable. Not relevant for setters. */ |
3595 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3596 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3597 | | false, /* isTypedMethod. Only relevant for methods. */ |
3598 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3599 | | }; |
3600 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3601 | | static_assert(0 < 1, "There is no slot for us"); |
3602 | | |
3603 | | MOZ_CAN_RUN_SCRIPT static bool |
3604 | | insertAdjacentHTML(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
3605 | 0 | { |
3606 | 0 | AUTO_PROFILER_LABEL_FAST("Element.insertAdjacentHTML", DOM, cx); |
3607 | 0 |
|
3608 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
3609 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.insertAdjacentHTML"); |
3610 | 0 | } |
3611 | 0 | binding_detail::FakeString arg0; |
3612 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
3613 | 0 | return false; |
3614 | 0 | } |
3615 | 0 | binding_detail::FakeString arg1; |
3616 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
3617 | 0 | return false; |
3618 | 0 | } |
3619 | 0 | Maybe<AutoCEReaction> ceReaction; |
3620 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
3621 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
3622 | 0 | if (docGroup) { |
3623 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
3624 | 0 | } |
3625 | 0 | } |
3626 | 0 | FastErrorResult rv; |
3627 | 0 | self->InsertAdjacentHTML(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv); |
3628 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
3629 | 0 | return false; |
3630 | 0 | } |
3631 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3632 | 0 | args.rval().setUndefined(); |
3633 | 0 | return true; |
3634 | 0 | } |
3635 | | |
3636 | | static const JSJitInfo insertAdjacentHTML_methodinfo = { |
3637 | | { (JSJitGetterOp)insertAdjacentHTML }, |
3638 | | { prototypes::id::Element }, |
3639 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3640 | | JSJitInfo::Method, |
3641 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3642 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
3643 | | false, /* isInfallible. False in setters. */ |
3644 | | false, /* isMovable. Not relevant for setters. */ |
3645 | | false, /* isEliminatable. Not relevant for setters. */ |
3646 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3647 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3648 | | false, /* isTypedMethod. Only relevant for methods. */ |
3649 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3650 | | }; |
3651 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3652 | | static_assert(0 < 1, "There is no slot for us"); |
3653 | | |
3654 | | MOZ_CAN_RUN_SCRIPT static bool |
3655 | | querySelector(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
3656 | 0 | { |
3657 | 0 | AUTO_PROFILER_LABEL_FAST("Element.querySelector", DOM, cx); |
3658 | 0 |
|
3659 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
3660 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.querySelector"); |
3661 | 0 | } |
3662 | 0 | binding_detail::FakeString arg0; |
3663 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
3664 | 0 | return false; |
3665 | 0 | } |
3666 | 0 | FastErrorResult rv; |
3667 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Element>(self->QuerySelector(NonNullHelper(Constify(arg0)), rv))); |
3668 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
3669 | 0 | return false; |
3670 | 0 | } |
3671 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3672 | 0 | if (!result) { |
3673 | 0 | args.rval().setNull(); |
3674 | 0 | return true; |
3675 | 0 | } |
3676 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
3677 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
3678 | 0 | return false; |
3679 | 0 | } |
3680 | 0 | return true; |
3681 | 0 | } |
3682 | | |
3683 | | static const JSJitInfo::ArgType querySelector_methodinfo_argTypes[] = { JSJitInfo::String, JSJitInfo::ArgTypeListEnd }; |
3684 | | static const JSTypedMethodJitInfo querySelector_methodinfo = { |
3685 | | { |
3686 | | { (JSJitGetterOp)querySelector }, |
3687 | | { prototypes::id::Element }, |
3688 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3689 | | JSJitInfo::Method, |
3690 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
3691 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
3692 | | false, /* isInfallible. False in setters. */ |
3693 | | false, /* isMovable. Not relevant for setters. */ |
3694 | | false, /* isEliminatable. Not relevant for setters. */ |
3695 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3696 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3697 | | true, /* isTypedMethod. Only relevant for methods. */ |
3698 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3699 | | }, |
3700 | | querySelector_methodinfo_argTypes |
3701 | | }; |
3702 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3703 | | static_assert(0 < 1, "There is no slot for us"); |
3704 | | |
3705 | | MOZ_CAN_RUN_SCRIPT static bool |
3706 | | querySelectorAll(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
3707 | 0 | { |
3708 | 0 | AUTO_PROFILER_LABEL_FAST("Element.querySelectorAll", DOM, cx); |
3709 | 0 |
|
3710 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
3711 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.querySelectorAll"); |
3712 | 0 | } |
3713 | 0 | binding_detail::FakeString arg0; |
3714 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
3715 | 0 | return false; |
3716 | 0 | } |
3717 | 0 | FastErrorResult rv; |
3718 | 0 | auto result(StrongOrRawPtr<nsINodeList>(self->QuerySelectorAll(NonNullHelper(Constify(arg0)), rv))); |
3719 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
3720 | 0 | return false; |
3721 | 0 | } |
3722 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3723 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
3724 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
3725 | 0 | return false; |
3726 | 0 | } |
3727 | 0 | return true; |
3728 | 0 | } |
3729 | | |
3730 | | static const JSJitInfo::ArgType querySelectorAll_methodinfo_argTypes[] = { JSJitInfo::String, JSJitInfo::ArgTypeListEnd }; |
3731 | | static const JSTypedMethodJitInfo querySelectorAll_methodinfo = { |
3732 | | { |
3733 | | { (JSJitGetterOp)querySelectorAll }, |
3734 | | { prototypes::id::Element }, |
3735 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3736 | | JSJitInfo::Method, |
3737 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
3738 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
3739 | | false, /* isInfallible. False in setters. */ |
3740 | | false, /* isMovable. Not relevant for setters. */ |
3741 | | false, /* isEliminatable. Not relevant for setters. */ |
3742 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3743 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3744 | | true, /* isTypedMethod. Only relevant for methods. */ |
3745 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3746 | | }, |
3747 | | querySelectorAll_methodinfo_argTypes |
3748 | | }; |
3749 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3750 | | static_assert(0 < 1, "There is no slot for us"); |
3751 | | |
3752 | | MOZ_CAN_RUN_SCRIPT static bool |
3753 | | attachShadow(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
3754 | 0 | { |
3755 | 0 | AUTO_PROFILER_LABEL_FAST("Element.attachShadow", DOM, cx); |
3756 | 0 |
|
3757 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
3758 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.attachShadow"); |
3759 | 0 | } |
3760 | 0 | binding_detail::FastShadowRootInit arg0; |
3761 | 0 | if (!arg0.Init(cx, args[0], "Argument 1 of Element.attachShadow", false)) { |
3762 | 0 | return false; |
3763 | 0 | } |
3764 | 0 | FastErrorResult rv; |
3765 | 0 | auto result(StrongOrRawPtr<mozilla::dom::ShadowRoot>(self->AttachShadow(Constify(arg0), rv))); |
3766 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
3767 | 0 | return false; |
3768 | 0 | } |
3769 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3770 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
3771 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
3772 | 0 | return false; |
3773 | 0 | } |
3774 | 0 | return true; |
3775 | 0 | } |
3776 | | |
3777 | | static const JSJitInfo attachShadow_methodinfo = { |
3778 | | { (JSJitGetterOp)attachShadow }, |
3779 | | { prototypes::id::Element }, |
3780 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3781 | | JSJitInfo::Method, |
3782 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3783 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
3784 | | false, /* isInfallible. False in setters. */ |
3785 | | false, /* isMovable. Not relevant for setters. */ |
3786 | | false, /* isEliminatable. Not relevant for setters. */ |
3787 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3788 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3789 | | false, /* isTypedMethod. Only relevant for methods. */ |
3790 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3791 | | }; |
3792 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3793 | | static_assert(0 < 1, "There is no slot for us"); |
3794 | | |
3795 | | MOZ_CAN_RUN_SCRIPT static bool |
3796 | | get_shadowRoot(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
3797 | 0 | { |
3798 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.shadowRoot", DOM, cx); |
3799 | 0 |
|
3800 | 0 | auto result(StrongOrRawPtr<mozilla::dom::ShadowRoot>(self->GetShadowRootByMode())); |
3801 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3802 | 0 | if (!result) { |
3803 | 0 | args.rval().setNull(); |
3804 | 0 | return true; |
3805 | 0 | } |
3806 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
3807 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
3808 | 0 | return false; |
3809 | 0 | } |
3810 | 0 | return true; |
3811 | 0 | } |
3812 | | |
3813 | | static const JSJitInfo shadowRoot_getterinfo = { |
3814 | | { (JSJitGetterOp)get_shadowRoot }, |
3815 | | { prototypes::id::Element }, |
3816 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3817 | | JSJitInfo::Getter, |
3818 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3819 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
3820 | | false, /* isInfallible. False in setters. */ |
3821 | | false, /* isMovable. Not relevant for setters. */ |
3822 | | false, /* isEliminatable. Not relevant for setters. */ |
3823 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3824 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3825 | | false, /* isTypedMethod. Only relevant for methods. */ |
3826 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3827 | | }; |
3828 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3829 | | static_assert(0 < 1, "There is no slot for us"); |
3830 | | |
3831 | | MOZ_CAN_RUN_SCRIPT static bool |
3832 | | get_openOrClosedShadowRoot(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
3833 | 0 | { |
3834 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.openOrClosedShadowRoot", DOM, cx); |
3835 | 0 |
|
3836 | 0 | auto result(StrongOrRawPtr<mozilla::dom::ShadowRoot>(self->GetShadowRoot())); |
3837 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3838 | 0 | if (!result) { |
3839 | 0 | args.rval().setNull(); |
3840 | 0 | return true; |
3841 | 0 | } |
3842 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
3843 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
3844 | 0 | return false; |
3845 | 0 | } |
3846 | 0 | return true; |
3847 | 0 | } |
3848 | | |
3849 | | static const JSJitInfo openOrClosedShadowRoot_getterinfo = { |
3850 | | { (JSJitGetterOp)get_openOrClosedShadowRoot }, |
3851 | | { prototypes::id::Element }, |
3852 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3853 | | JSJitInfo::Getter, |
3854 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3855 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
3856 | | false, /* isInfallible. False in setters. */ |
3857 | | false, /* isMovable. Not relevant for setters. */ |
3858 | | false, /* isEliminatable. Not relevant for setters. */ |
3859 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3860 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3861 | | false, /* isTypedMethod. Only relevant for methods. */ |
3862 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3863 | | }; |
3864 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3865 | | static_assert(0 < 1, "There is no slot for us"); |
3866 | | |
3867 | | MOZ_CAN_RUN_SCRIPT static bool |
3868 | | get_assignedSlot(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
3869 | 0 | { |
3870 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.assignedSlot", DOM, cx); |
3871 | 0 |
|
3872 | 0 | auto result(StrongOrRawPtr<mozilla::dom::HTMLSlotElement>(self->GetAssignedSlotByMode())); |
3873 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3874 | 0 | if (!result) { |
3875 | 0 | args.rval().setNull(); |
3876 | 0 | return true; |
3877 | 0 | } |
3878 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
3879 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
3880 | 0 | return false; |
3881 | 0 | } |
3882 | 0 | return true; |
3883 | 0 | } |
3884 | | |
3885 | | static const JSJitInfo assignedSlot_getterinfo = { |
3886 | | { (JSJitGetterOp)get_assignedSlot }, |
3887 | | { prototypes::id::Element }, |
3888 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3889 | | JSJitInfo::Getter, |
3890 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3891 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
3892 | | false, /* isInfallible. False in setters. */ |
3893 | | false, /* isMovable. Not relevant for setters. */ |
3894 | | false, /* isEliminatable. Not relevant for setters. */ |
3895 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3896 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3897 | | false, /* isTypedMethod. Only relevant for methods. */ |
3898 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3899 | | }; |
3900 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3901 | | static_assert(0 < 1, "There is no slot for us"); |
3902 | | |
3903 | | MOZ_CAN_RUN_SCRIPT static bool |
3904 | | get_openOrClosedAssignedSlot(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
3905 | 0 | { |
3906 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.openOrClosedAssignedSlot", DOM, cx); |
3907 | 0 |
|
3908 | 0 | auto result(StrongOrRawPtr<mozilla::dom::HTMLSlotElement>(self->GetAssignedSlot())); |
3909 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3910 | 0 | if (!result) { |
3911 | 0 | args.rval().setNull(); |
3912 | 0 | return true; |
3913 | 0 | } |
3914 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
3915 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
3916 | 0 | return false; |
3917 | 0 | } |
3918 | 0 | return true; |
3919 | 0 | } |
3920 | | |
3921 | | static const JSJitInfo openOrClosedAssignedSlot_getterinfo = { |
3922 | | { (JSJitGetterOp)get_openOrClosedAssignedSlot }, |
3923 | | { prototypes::id::Element }, |
3924 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3925 | | JSJitInfo::Getter, |
3926 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3927 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
3928 | | false, /* isInfallible. False in setters. */ |
3929 | | false, /* isMovable. Not relevant for setters. */ |
3930 | | false, /* isEliminatable. Not relevant for setters. */ |
3931 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3932 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3933 | | false, /* isTypedMethod. Only relevant for methods. */ |
3934 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3935 | | }; |
3936 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3937 | | static_assert(0 < 1, "There is no slot for us"); |
3938 | | |
3939 | | MOZ_CAN_RUN_SCRIPT static bool |
3940 | | get_slot(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
3941 | 0 | { |
3942 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.slot", DOM, cx); |
3943 | 0 |
|
3944 | 0 | DOMString result; |
3945 | 0 | self->GetSlot(result); |
3946 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3947 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
3948 | 0 | return false; |
3949 | 0 | } |
3950 | 0 | return true; |
3951 | 0 | } |
3952 | | |
3953 | | MOZ_CAN_RUN_SCRIPT static bool |
3954 | | set_slot(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitSetterCallArgs args) |
3955 | 0 | { |
3956 | 0 | AUTO_PROFILER_LABEL_FAST("set Element.slot", DOM, cx); |
3957 | 0 |
|
3958 | 0 | binding_detail::FakeString arg0; |
3959 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
3960 | 0 | return false; |
3961 | 0 | } |
3962 | 0 | Maybe<AutoCEReaction> ceReaction; |
3963 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
3964 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
3965 | 0 | if (docGroup) { |
3966 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
3967 | 0 | } |
3968 | 0 | } |
3969 | 0 | FastErrorResult rv; |
3970 | 0 | self->SetSlot(NonNullHelper(Constify(arg0)), rv); |
3971 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
3972 | 0 | return false; |
3973 | 0 | } |
3974 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3975 | 0 |
|
3976 | 0 | return true; |
3977 | 0 | } |
3978 | | |
3979 | | static const JSJitInfo slot_getterinfo = { |
3980 | | { (JSJitGetterOp)get_slot }, |
3981 | | { prototypes::id::Element }, |
3982 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
3983 | | JSJitInfo::Getter, |
3984 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3985 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
3986 | | false, /* isInfallible. False in setters. */ |
3987 | | false, /* isMovable. Not relevant for setters. */ |
3988 | | false, /* isEliminatable. Not relevant for setters. */ |
3989 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3990 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3991 | | false, /* isTypedMethod. Only relevant for methods. */ |
3992 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3993 | | }; |
3994 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3995 | | static_assert(0 < 1, "There is no slot for us"); |
3996 | | static const JSJitInfo slot_setterinfo = { |
3997 | | { (JSJitGetterOp)set_slot }, |
3998 | | { prototypes::id::Element }, |
3999 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4000 | | JSJitInfo::Setter, |
4001 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
4002 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
4003 | | false, /* isInfallible. False in setters. */ |
4004 | | false, /* isMovable. Not relevant for setters. */ |
4005 | | false, /* isEliminatable. Not relevant for setters. */ |
4006 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4007 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4008 | | false, /* isTypedMethod. Only relevant for methods. */ |
4009 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4010 | | }; |
4011 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4012 | | static_assert(0 < 1, "There is no slot for us"); |
4013 | | |
4014 | | MOZ_CAN_RUN_SCRIPT static bool |
4015 | | requestFullscreen(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
4016 | 0 | { |
4017 | 0 | AUTO_PROFILER_LABEL_FAST("Element.requestFullscreen", DOM, cx); |
4018 | 0 |
|
4019 | 0 | FastErrorResult rv; |
4020 | 0 | auto result(StrongOrRawPtr<Promise>(self->RequestFullscreen(nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv))); |
4021 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
4022 | 0 | return false; |
4023 | 0 | } |
4024 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
4025 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
4026 | 0 | return false; |
4027 | 0 | } |
4028 | 0 | return true; |
4029 | 0 | } |
4030 | | |
4031 | | MOZ_CAN_RUN_SCRIPT static bool |
4032 | | requestFullscreen_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
4033 | 0 | { |
4034 | 0 | bool ok = requestFullscreen(cx, obj, self, args); |
4035 | 0 | if (ok) { |
4036 | 0 | return true; |
4037 | 0 | } |
4038 | 0 | return ConvertExceptionToPromise(cx, args.rval()); |
4039 | 0 | } |
4040 | | |
4041 | | static const JSJitInfo requestFullscreen_methodinfo = { |
4042 | | { (JSJitGetterOp)requestFullscreen_promiseWrapper }, |
4043 | | { prototypes::id::Element }, |
4044 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4045 | | JSJitInfo::Method, |
4046 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
4047 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
4048 | | false, /* isInfallible. False in setters. */ |
4049 | | false, /* isMovable. Not relevant for setters. */ |
4050 | | false, /* isEliminatable. Not relevant for setters. */ |
4051 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4052 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4053 | | false, /* isTypedMethod. Only relevant for methods. */ |
4054 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4055 | | }; |
4056 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4057 | | static_assert(0 < 1, "There is no slot for us"); |
4058 | | |
4059 | | MOZ_CAN_RUN_SCRIPT static bool |
4060 | | mozRequestFullScreen(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
4061 | 0 | { |
4062 | 0 | AUTO_PROFILER_LABEL_FAST("Element.mozRequestFullScreen", DOM, cx); |
4063 | 0 |
|
4064 | 0 | FastErrorResult rv; |
4065 | 0 | auto result(StrongOrRawPtr<Promise>(self->RequestFullscreen(nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv))); |
4066 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
4067 | 0 | return false; |
4068 | 0 | } |
4069 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
4070 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
4071 | 0 | return false; |
4072 | 0 | } |
4073 | 0 | return true; |
4074 | 0 | } |
4075 | | |
4076 | | MOZ_CAN_RUN_SCRIPT static bool |
4077 | | mozRequestFullScreen_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
4078 | 0 | { |
4079 | 0 | bool ok = mozRequestFullScreen(cx, obj, self, args); |
4080 | 0 | if (ok) { |
4081 | 0 | return true; |
4082 | 0 | } |
4083 | 0 | return ConvertExceptionToPromise(cx, args.rval()); |
4084 | 0 | } |
4085 | | |
4086 | | static const JSJitInfo mozRequestFullScreen_methodinfo = { |
4087 | | { (JSJitGetterOp)mozRequestFullScreen_promiseWrapper }, |
4088 | | { prototypes::id::Element }, |
4089 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4090 | | JSJitInfo::Method, |
4091 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
4092 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
4093 | | false, /* isInfallible. False in setters. */ |
4094 | | false, /* isMovable. Not relevant for setters. */ |
4095 | | false, /* isEliminatable. Not relevant for setters. */ |
4096 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4097 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4098 | | false, /* isTypedMethod. Only relevant for methods. */ |
4099 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4100 | | }; |
4101 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4102 | | static_assert(0 < 1, "There is no slot for us"); |
4103 | | |
4104 | | MOZ_CAN_RUN_SCRIPT static bool |
4105 | | get_onfullscreenchange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
4106 | 0 | { |
4107 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.onfullscreenchange", DOM, cx); |
4108 | 0 |
|
4109 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnfullscreenchange()); |
4110 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
4111 | 0 | if (result) { |
4112 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
4113 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
4114 | 0 | return false; |
4115 | 0 | } |
4116 | 0 | return true; |
4117 | 0 | } else { |
4118 | 0 | args.rval().setNull(); |
4119 | 0 | return true; |
4120 | 0 | } |
4121 | 0 | } |
4122 | | |
4123 | | MOZ_CAN_RUN_SCRIPT static bool |
4124 | | set_onfullscreenchange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitSetterCallArgs args) |
4125 | 0 | { |
4126 | 0 | AUTO_PROFILER_LABEL_FAST("set Element.onfullscreenchange", DOM, cx); |
4127 | 0 |
|
4128 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
4129 | 0 | if (args[0].isObject()) { |
4130 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
4131 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
4132 | 0 | } |
4133 | 0 | } else { |
4134 | 0 | arg0 = nullptr; |
4135 | 0 | } |
4136 | 0 | self->SetOnfullscreenchange(Constify(arg0)); |
4137 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
4138 | 0 |
|
4139 | 0 | return true; |
4140 | 0 | } |
4141 | | |
4142 | | static const JSJitInfo onfullscreenchange_getterinfo = { |
4143 | | { (JSJitGetterOp)get_onfullscreenchange }, |
4144 | | { prototypes::id::Element }, |
4145 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4146 | | JSJitInfo::Getter, |
4147 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
4148 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
4149 | | false, /* isInfallible. False in setters. */ |
4150 | | false, /* isMovable. Not relevant for setters. */ |
4151 | | false, /* isEliminatable. Not relevant for setters. */ |
4152 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4153 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4154 | | false, /* isTypedMethod. Only relevant for methods. */ |
4155 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4156 | | }; |
4157 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4158 | | static_assert(0 < 1, "There is no slot for us"); |
4159 | | static const JSJitInfo onfullscreenchange_setterinfo = { |
4160 | | { (JSJitGetterOp)set_onfullscreenchange }, |
4161 | | { prototypes::id::Element }, |
4162 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4163 | | JSJitInfo::Setter, |
4164 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
4165 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
4166 | | false, /* isInfallible. False in setters. */ |
4167 | | false, /* isMovable. Not relevant for setters. */ |
4168 | | false, /* isEliminatable. Not relevant for setters. */ |
4169 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4170 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4171 | | false, /* isTypedMethod. Only relevant for methods. */ |
4172 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4173 | | }; |
4174 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4175 | | static_assert(0 < 1, "There is no slot for us"); |
4176 | | |
4177 | | MOZ_CAN_RUN_SCRIPT static bool |
4178 | | get_onfullscreenerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
4179 | 0 | { |
4180 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.onfullscreenerror", DOM, cx); |
4181 | 0 |
|
4182 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnfullscreenerror()); |
4183 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
4184 | 0 | if (result) { |
4185 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
4186 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
4187 | 0 | return false; |
4188 | 0 | } |
4189 | 0 | return true; |
4190 | 0 | } else { |
4191 | 0 | args.rval().setNull(); |
4192 | 0 | return true; |
4193 | 0 | } |
4194 | 0 | } |
4195 | | |
4196 | | MOZ_CAN_RUN_SCRIPT static bool |
4197 | | set_onfullscreenerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitSetterCallArgs args) |
4198 | 0 | { |
4199 | 0 | AUTO_PROFILER_LABEL_FAST("set Element.onfullscreenerror", DOM, cx); |
4200 | 0 |
|
4201 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
4202 | 0 | if (args[0].isObject()) { |
4203 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
4204 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
4205 | 0 | } |
4206 | 0 | } else { |
4207 | 0 | arg0 = nullptr; |
4208 | 0 | } |
4209 | 0 | self->SetOnfullscreenerror(Constify(arg0)); |
4210 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
4211 | 0 |
|
4212 | 0 | return true; |
4213 | 0 | } |
4214 | | |
4215 | | static const JSJitInfo onfullscreenerror_getterinfo = { |
4216 | | { (JSJitGetterOp)get_onfullscreenerror }, |
4217 | | { prototypes::id::Element }, |
4218 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4219 | | JSJitInfo::Getter, |
4220 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
4221 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
4222 | | false, /* isInfallible. False in setters. */ |
4223 | | false, /* isMovable. Not relevant for setters. */ |
4224 | | false, /* isEliminatable. Not relevant for setters. */ |
4225 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4226 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4227 | | false, /* isTypedMethod. Only relevant for methods. */ |
4228 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4229 | | }; |
4230 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4231 | | static_assert(0 < 1, "There is no slot for us"); |
4232 | | static const JSJitInfo onfullscreenerror_setterinfo = { |
4233 | | { (JSJitGetterOp)set_onfullscreenerror }, |
4234 | | { prototypes::id::Element }, |
4235 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4236 | | JSJitInfo::Setter, |
4237 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
4238 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
4239 | | false, /* isInfallible. False in setters. */ |
4240 | | false, /* isMovable. Not relevant for setters. */ |
4241 | | false, /* isEliminatable. Not relevant for setters. */ |
4242 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4243 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4244 | | false, /* isTypedMethod. Only relevant for methods. */ |
4245 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4246 | | }; |
4247 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4248 | | static_assert(0 < 1, "There is no slot for us"); |
4249 | | |
4250 | | MOZ_CAN_RUN_SCRIPT static bool |
4251 | | requestPointerLock(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
4252 | 0 | { |
4253 | 0 | AUTO_PROFILER_LABEL_FAST("Element.requestPointerLock", DOM, cx); |
4254 | 0 |
|
4255 | 0 | self->RequestPointerLock(nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem); |
4256 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
4257 | 0 | args.rval().setUndefined(); |
4258 | 0 | return true; |
4259 | 0 | } |
4260 | | |
4261 | | static const JSJitInfo requestPointerLock_methodinfo = { |
4262 | | { (JSJitGetterOp)requestPointerLock }, |
4263 | | { prototypes::id::Element }, |
4264 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4265 | | JSJitInfo::Method, |
4266 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
4267 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
4268 | | true, /* isInfallible. False in setters. */ |
4269 | | false, /* isMovable. Not relevant for setters. */ |
4270 | | false, /* isEliminatable. Not relevant for setters. */ |
4271 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4272 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4273 | | false, /* isTypedMethod. Only relevant for methods. */ |
4274 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4275 | | }; |
4276 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4277 | | static_assert(0 < 1, "There is no slot for us"); |
4278 | | |
4279 | | MOZ_CAN_RUN_SCRIPT static bool |
4280 | | getAsFlexContainer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
4281 | 0 | { |
4282 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getAsFlexContainer", DOM, cx); |
4283 | 0 |
|
4284 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Flex>(self->GetAsFlexContainer())); |
4285 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
4286 | 0 | if (!result) { |
4287 | 0 | args.rval().setNull(); |
4288 | 0 | return true; |
4289 | 0 | } |
4290 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
4291 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
4292 | 0 | return false; |
4293 | 0 | } |
4294 | 0 | return true; |
4295 | 0 | } |
4296 | | |
4297 | | static const JSJitInfo::ArgType getAsFlexContainer_methodinfo_argTypes[] = { JSJitInfo::ArgTypeListEnd }; |
4298 | | static const JSTypedMethodJitInfo getAsFlexContainer_methodinfo = { |
4299 | | { |
4300 | | { (JSJitGetterOp)getAsFlexContainer }, |
4301 | | { prototypes::id::Element }, |
4302 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4303 | | JSJitInfo::Method, |
4304 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
4305 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
4306 | | false, /* isInfallible. False in setters. */ |
4307 | | true, /* isMovable. Not relevant for setters. */ |
4308 | | true, /* isEliminatable. Not relevant for setters. */ |
4309 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4310 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4311 | | true, /* isTypedMethod. Only relevant for methods. */ |
4312 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4313 | | }, |
4314 | | getAsFlexContainer_methodinfo_argTypes |
4315 | | }; |
4316 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4317 | | static_assert(0 < 1, "There is no slot for us"); |
4318 | | |
4319 | | MOZ_CAN_RUN_SCRIPT static bool |
4320 | | getGridFragments(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
4321 | 0 | { |
4322 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getGridFragments", DOM, cx); |
4323 | 0 |
|
4324 | 0 | nsTArray<StrongPtrForMember<mozilla::dom::Grid>::Type> result; |
4325 | 0 | self->GetGridFragments(result); |
4326 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
4327 | 0 |
|
4328 | 0 | uint32_t length = result.Length(); |
4329 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
4330 | 0 | if (!returnArray) { |
4331 | 0 | return false; |
4332 | 0 | } |
4333 | 0 | // Scope for 'tmp' |
4334 | 0 | { |
4335 | 0 | JS::Rooted<JS::Value> tmp(cx); |
4336 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
4337 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
4338 | 0 | // are different ways to succeed at wrapping the object. |
4339 | 0 | do { |
4340 | 0 | if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) { |
4341 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
4342 | 0 | return false; |
4343 | 0 | } |
4344 | 0 | break; |
4345 | 0 | } while (false); |
4346 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
4347 | 0 | JSPROP_ENUMERATE)) { |
4348 | 0 | return false; |
4349 | 0 | } |
4350 | 0 | } |
4351 | 0 | } |
4352 | 0 | args.rval().setObject(*returnArray); |
4353 | 0 | return true; |
4354 | 0 | } |
4355 | | |
4356 | | static const JSJitInfo::ArgType getGridFragments_methodinfo_argTypes[] = { JSJitInfo::ArgTypeListEnd }; |
4357 | | static const JSTypedMethodJitInfo getGridFragments_methodinfo = { |
4358 | | { |
4359 | | { (JSJitGetterOp)getGridFragments }, |
4360 | | { prototypes::id::Element }, |
4361 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4362 | | JSJitInfo::Method, |
4363 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
4364 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
4365 | | false, /* isInfallible. False in setters. */ |
4366 | | true, /* isMovable. Not relevant for setters. */ |
4367 | | true, /* isEliminatable. Not relevant for setters. */ |
4368 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4369 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4370 | | true, /* isTypedMethod. Only relevant for methods. */ |
4371 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4372 | | }, |
4373 | | getGridFragments_methodinfo_argTypes |
4374 | | }; |
4375 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4376 | | static_assert(0 < 1, "There is no slot for us"); |
4377 | | |
4378 | | MOZ_CAN_RUN_SCRIPT static bool |
4379 | | getElementsWithGrid(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
4380 | 0 | { |
4381 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getElementsWithGrid", DOM, cx); |
4382 | 0 |
|
4383 | 0 | nsTArray<StrongPtrForMember<mozilla::dom::Element>::Type> result; |
4384 | 0 | self->GetElementsWithGrid(result); |
4385 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
4386 | 0 |
|
4387 | 0 | uint32_t length = result.Length(); |
4388 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
4389 | 0 | if (!returnArray) { |
4390 | 0 | return false; |
4391 | 0 | } |
4392 | 0 | // Scope for 'tmp' |
4393 | 0 | { |
4394 | 0 | JS::Rooted<JS::Value> tmp(cx); |
4395 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
4396 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
4397 | 0 | // are different ways to succeed at wrapping the object. |
4398 | 0 | do { |
4399 | 0 | if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) { |
4400 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
4401 | 0 | return false; |
4402 | 0 | } |
4403 | 0 | break; |
4404 | 0 | } while (false); |
4405 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
4406 | 0 | JSPROP_ENUMERATE)) { |
4407 | 0 | return false; |
4408 | 0 | } |
4409 | 0 | } |
4410 | 0 | } |
4411 | 0 | args.rval().setObject(*returnArray); |
4412 | 0 | return true; |
4413 | 0 | } |
4414 | | |
4415 | | static const JSJitInfo::ArgType getElementsWithGrid_methodinfo_argTypes[] = { JSJitInfo::ArgTypeListEnd }; |
4416 | | static const JSTypedMethodJitInfo getElementsWithGrid_methodinfo = { |
4417 | | { |
4418 | | { (JSJitGetterOp)getElementsWithGrid }, |
4419 | | { prototypes::id::Element }, |
4420 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4421 | | JSJitInfo::Method, |
4422 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
4423 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
4424 | | false, /* isInfallible. False in setters. */ |
4425 | | true, /* isMovable. Not relevant for setters. */ |
4426 | | true, /* isEliminatable. Not relevant for setters. */ |
4427 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4428 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4429 | | true, /* isTypedMethod. Only relevant for methods. */ |
4430 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4431 | | }, |
4432 | | getElementsWithGrid_methodinfo_argTypes |
4433 | | }; |
4434 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4435 | | static_assert(0 < 1, "There is no slot for us"); |
4436 | | |
4437 | | MOZ_CAN_RUN_SCRIPT static bool |
4438 | | animate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
4439 | 0 | { |
4440 | 0 | AUTO_PROFILER_LABEL_FAST("Element.animate", DOM, cx); |
4441 | 0 |
|
4442 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
4443 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.animate"); |
4444 | 0 | } |
4445 | 0 | JS::Rooted<JSObject*> arg0(cx); |
4446 | 0 | if (args[0].isObject()) { |
4447 | 0 | arg0 = &args[0].toObject(); |
4448 | 0 | } else if (args[0].isNullOrUndefined()) { |
4449 | 0 | arg0 = nullptr; |
4450 | 0 | } else { |
4451 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Element.animate"); |
4452 | 0 | return false; |
4453 | 0 | } |
4454 | 0 | UnrestrictedDoubleOrKeyframeAnimationOptions arg1; |
4455 | 0 | UnrestrictedDoubleOrKeyframeAnimationOptionsArgument arg1_holder(arg1); |
4456 | 0 | if (!(args.hasDefined(1))) { |
4457 | 0 | if (!arg1.RawSetAsKeyframeAnimationOptions().Init(cx, JS::NullHandleValue, "Member of UnrestrictedDoubleOrKeyframeAnimationOptions")) { |
4458 | 0 | return false; |
4459 | 0 | } |
4460 | 0 | } else { |
4461 | 0 | { |
4462 | 0 | bool done = false, failed = false, tryNext; |
4463 | 0 | if (!done) { |
4464 | 0 | done = (failed = !arg1_holder.TrySetToKeyframeAnimationOptions(cx, args[1], tryNext, false)) || !tryNext; |
4465 | 0 | } |
4466 | 0 | if (!done) { |
4467 | 0 | do { |
4468 | 0 | done = (failed = !arg1_holder.TrySetToUnrestrictedDouble(cx, args[1], tryNext)) || !tryNext; |
4469 | 0 | break; |
4470 | 0 | } while (false); |
4471 | 0 | } |
4472 | 0 | if (failed) { |
4473 | 0 | return false; |
4474 | 0 | } |
4475 | 0 | if (!done) { |
4476 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of Element.animate", "KeyframeAnimationOptions"); |
4477 | 0 | return false; |
4478 | 0 | } |
4479 | 0 | } |
4480 | 0 | } |
4481 | 0 | FastErrorResult rv; |
4482 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Animation>(self->Animate(cx, arg0, Constify(arg1), rv))); |
4483 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
4484 | 0 | return false; |
4485 | 0 | } |
4486 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
4487 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
4488 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
4489 | 0 | return false; |
4490 | 0 | } |
4491 | 0 | return true; |
4492 | 0 | } |
4493 | | |
4494 | | static const JSJitInfo animate_methodinfo = { |
4495 | | { (JSJitGetterOp)animate }, |
4496 | | { prototypes::id::Element }, |
4497 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4498 | | JSJitInfo::Method, |
4499 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
4500 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
4501 | | false, /* isInfallible. False in setters. */ |
4502 | | false, /* isMovable. Not relevant for setters. */ |
4503 | | false, /* isEliminatable. Not relevant for setters. */ |
4504 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4505 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4506 | | false, /* isTypedMethod. Only relevant for methods. */ |
4507 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4508 | | }; |
4509 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4510 | | static_assert(0 < 1, "There is no slot for us"); |
4511 | | |
4512 | | MOZ_CAN_RUN_SCRIPT static bool |
4513 | | getAnimations(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
4514 | 0 | { |
4515 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getAnimations", DOM, cx); |
4516 | 0 |
|
4517 | 0 | binding_detail::FastAnimationFilter arg0; |
4518 | 0 | if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1 of Element.getAnimations", false)) { |
4519 | 0 | return false; |
4520 | 0 | } |
4521 | 0 | nsTArray<StrongPtrForMember<mozilla::dom::Animation>::Type> result; |
4522 | 0 | self->GetAnimations(Constify(arg0), result); |
4523 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
4524 | 0 |
|
4525 | 0 | uint32_t length = result.Length(); |
4526 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
4527 | 0 | if (!returnArray) { |
4528 | 0 | return false; |
4529 | 0 | } |
4530 | 0 | // Scope for 'tmp' |
4531 | 0 | { |
4532 | 0 | JS::Rooted<JS::Value> tmp(cx); |
4533 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
4534 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
4535 | 0 | // are different ways to succeed at wrapping the object. |
4536 | 0 | do { |
4537 | 0 | if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) { |
4538 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
4539 | 0 | return false; |
4540 | 0 | } |
4541 | 0 | break; |
4542 | 0 | } while (false); |
4543 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
4544 | 0 | JSPROP_ENUMERATE)) { |
4545 | 0 | return false; |
4546 | 0 | } |
4547 | 0 | } |
4548 | 0 | } |
4549 | 0 | args.rval().setObject(*returnArray); |
4550 | 0 | return true; |
4551 | 0 | } |
4552 | | |
4553 | | static const JSJitInfo getAnimations_methodinfo = { |
4554 | | { (JSJitGetterOp)getAnimations }, |
4555 | | { prototypes::id::Element }, |
4556 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4557 | | JSJitInfo::Method, |
4558 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
4559 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
4560 | | false, /* isInfallible. False in setters. */ |
4561 | | false, /* isMovable. Not relevant for setters. */ |
4562 | | false, /* isEliminatable. Not relevant for setters. */ |
4563 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4564 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4565 | | false, /* isTypedMethod. Only relevant for methods. */ |
4566 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4567 | | }; |
4568 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4569 | | static_assert(0 < 1, "There is no slot for us"); |
4570 | | |
4571 | | MOZ_CAN_RUN_SCRIPT static bool |
4572 | | before(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
4573 | 0 | { |
4574 | 0 | AUTO_PROFILER_LABEL_FAST("Element.before", DOM, cx); |
4575 | 0 |
|
4576 | 0 | AutoSequence<OwningNodeOrString> arg0; |
4577 | 0 | if (args.length() > 0) { |
4578 | 0 | if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) { |
4579 | 0 | JS_ReportOutOfMemory(cx); |
4580 | 0 | return false; |
4581 | 0 | } |
4582 | 0 | for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) { |
4583 | 0 | OwningNodeOrString& slot = *arg0.AppendElement(mozilla::fallible); |
4584 | 0 | { |
4585 | 0 | bool done = false, failed = false, tryNext; |
4586 | 0 | if (args[variadicArg].isObject()) { |
4587 | 0 | done = (failed = !slot.TrySetToNode(cx, args[variadicArg], tryNext, false)) || !tryNext; |
4588 | 0 |
|
4589 | 0 | } |
4590 | 0 | if (!done) { |
4591 | 0 | do { |
4592 | 0 | done = (failed = !slot.TrySetToString(cx, args[variadicArg], tryNext)) || !tryNext; |
4593 | 0 | break; |
4594 | 0 | } while (false); |
4595 | 0 | } |
4596 | 0 | if (failed) { |
4597 | 0 | return false; |
4598 | 0 | } |
4599 | 0 | if (!done) { |
4600 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of Element.before", "Node"); |
4601 | 0 | return false; |
4602 | 0 | } |
4603 | 0 | } |
4604 | 0 | } |
4605 | 0 | } |
4606 | 0 | Maybe<AutoCEReaction> ceReaction; |
4607 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
4608 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
4609 | 0 | if (docGroup) { |
4610 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
4611 | 0 | } |
4612 | 0 | } |
4613 | 0 | FastErrorResult rv; |
4614 | 0 | self->Before(Constify(arg0), rv); |
4615 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
4616 | 0 | return false; |
4617 | 0 | } |
4618 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
4619 | 0 | args.rval().setUndefined(); |
4620 | 0 | return true; |
4621 | 0 | } |
4622 | | |
4623 | | static const JSJitInfo before_methodinfo = { |
4624 | | { (JSJitGetterOp)before }, |
4625 | | { prototypes::id::Element }, |
4626 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4627 | | JSJitInfo::Method, |
4628 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
4629 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
4630 | | false, /* isInfallible. False in setters. */ |
4631 | | false, /* isMovable. Not relevant for setters. */ |
4632 | | false, /* isEliminatable. Not relevant for setters. */ |
4633 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4634 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4635 | | false, /* isTypedMethod. Only relevant for methods. */ |
4636 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4637 | | }; |
4638 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4639 | | static_assert(0 < 1, "There is no slot for us"); |
4640 | | |
4641 | | MOZ_CAN_RUN_SCRIPT static bool |
4642 | | after(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
4643 | 0 | { |
4644 | 0 | AUTO_PROFILER_LABEL_FAST("Element.after", DOM, cx); |
4645 | 0 |
|
4646 | 0 | AutoSequence<OwningNodeOrString> arg0; |
4647 | 0 | if (args.length() > 0) { |
4648 | 0 | if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) { |
4649 | 0 | JS_ReportOutOfMemory(cx); |
4650 | 0 | return false; |
4651 | 0 | } |
4652 | 0 | for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) { |
4653 | 0 | OwningNodeOrString& slot = *arg0.AppendElement(mozilla::fallible); |
4654 | 0 | { |
4655 | 0 | bool done = false, failed = false, tryNext; |
4656 | 0 | if (args[variadicArg].isObject()) { |
4657 | 0 | done = (failed = !slot.TrySetToNode(cx, args[variadicArg], tryNext, false)) || !tryNext; |
4658 | 0 |
|
4659 | 0 | } |
4660 | 0 | if (!done) { |
4661 | 0 | do { |
4662 | 0 | done = (failed = !slot.TrySetToString(cx, args[variadicArg], tryNext)) || !tryNext; |
4663 | 0 | break; |
4664 | 0 | } while (false); |
4665 | 0 | } |
4666 | 0 | if (failed) { |
4667 | 0 | return false; |
4668 | 0 | } |
4669 | 0 | if (!done) { |
4670 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of Element.after", "Node"); |
4671 | 0 | return false; |
4672 | 0 | } |
4673 | 0 | } |
4674 | 0 | } |
4675 | 0 | } |
4676 | 0 | Maybe<AutoCEReaction> ceReaction; |
4677 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
4678 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
4679 | 0 | if (docGroup) { |
4680 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
4681 | 0 | } |
4682 | 0 | } |
4683 | 0 | FastErrorResult rv; |
4684 | 0 | self->After(Constify(arg0), rv); |
4685 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
4686 | 0 | return false; |
4687 | 0 | } |
4688 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
4689 | 0 | args.rval().setUndefined(); |
4690 | 0 | return true; |
4691 | 0 | } |
4692 | | |
4693 | | static const JSJitInfo after_methodinfo = { |
4694 | | { (JSJitGetterOp)after }, |
4695 | | { prototypes::id::Element }, |
4696 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4697 | | JSJitInfo::Method, |
4698 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
4699 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
4700 | | false, /* isInfallible. False in setters. */ |
4701 | | false, /* isMovable. Not relevant for setters. */ |
4702 | | false, /* isEliminatable. Not relevant for setters. */ |
4703 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4704 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4705 | | false, /* isTypedMethod. Only relevant for methods. */ |
4706 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4707 | | }; |
4708 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4709 | | static_assert(0 < 1, "There is no slot for us"); |
4710 | | |
4711 | | MOZ_CAN_RUN_SCRIPT static bool |
4712 | | replaceWith(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
4713 | 0 | { |
4714 | 0 | AUTO_PROFILER_LABEL_FAST("Element.replaceWith", DOM, cx); |
4715 | 0 |
|
4716 | 0 | AutoSequence<OwningNodeOrString> arg0; |
4717 | 0 | if (args.length() > 0) { |
4718 | 0 | if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) { |
4719 | 0 | JS_ReportOutOfMemory(cx); |
4720 | 0 | return false; |
4721 | 0 | } |
4722 | 0 | for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) { |
4723 | 0 | OwningNodeOrString& slot = *arg0.AppendElement(mozilla::fallible); |
4724 | 0 | { |
4725 | 0 | bool done = false, failed = false, tryNext; |
4726 | 0 | if (args[variadicArg].isObject()) { |
4727 | 0 | done = (failed = !slot.TrySetToNode(cx, args[variadicArg], tryNext, false)) || !tryNext; |
4728 | 0 |
|
4729 | 0 | } |
4730 | 0 | if (!done) { |
4731 | 0 | do { |
4732 | 0 | done = (failed = !slot.TrySetToString(cx, args[variadicArg], tryNext)) || !tryNext; |
4733 | 0 | break; |
4734 | 0 | } while (false); |
4735 | 0 | } |
4736 | 0 | if (failed) { |
4737 | 0 | return false; |
4738 | 0 | } |
4739 | 0 | if (!done) { |
4740 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of Element.replaceWith", "Node"); |
4741 | 0 | return false; |
4742 | 0 | } |
4743 | 0 | } |
4744 | 0 | } |
4745 | 0 | } |
4746 | 0 | Maybe<AutoCEReaction> ceReaction; |
4747 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
4748 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
4749 | 0 | if (docGroup) { |
4750 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
4751 | 0 | } |
4752 | 0 | } |
4753 | 0 | FastErrorResult rv; |
4754 | 0 | self->ReplaceWith(Constify(arg0), rv); |
4755 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
4756 | 0 | return false; |
4757 | 0 | } |
4758 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
4759 | 0 | args.rval().setUndefined(); |
4760 | 0 | return true; |
4761 | 0 | } |
4762 | | |
4763 | | static const JSJitInfo replaceWith_methodinfo = { |
4764 | | { (JSJitGetterOp)replaceWith }, |
4765 | | { prototypes::id::Element }, |
4766 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4767 | | JSJitInfo::Method, |
4768 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
4769 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
4770 | | false, /* isInfallible. False in setters. */ |
4771 | | false, /* isMovable. Not relevant for setters. */ |
4772 | | false, /* isEliminatable. Not relevant for setters. */ |
4773 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4774 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4775 | | false, /* isTypedMethod. Only relevant for methods. */ |
4776 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4777 | | }; |
4778 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4779 | | static_assert(0 < 1, "There is no slot for us"); |
4780 | | |
4781 | | MOZ_CAN_RUN_SCRIPT static bool |
4782 | | remove(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
4783 | 0 | { |
4784 | 0 | AUTO_PROFILER_LABEL_FAST("Element.remove", DOM, cx); |
4785 | 0 |
|
4786 | 0 | Maybe<AutoCEReaction> ceReaction; |
4787 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
4788 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
4789 | 0 | if (docGroup) { |
4790 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
4791 | 0 | } |
4792 | 0 | } |
4793 | 0 | self->Remove(); |
4794 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
4795 | 0 | args.rval().setUndefined(); |
4796 | 0 | return true; |
4797 | 0 | } |
4798 | | |
4799 | | static const JSJitInfo remove_methodinfo = { |
4800 | | { (JSJitGetterOp)remove }, |
4801 | | { prototypes::id::Element }, |
4802 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4803 | | JSJitInfo::Method, |
4804 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
4805 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
4806 | | true, /* isInfallible. False in setters. */ |
4807 | | false, /* isMovable. Not relevant for setters. */ |
4808 | | false, /* isEliminatable. Not relevant for setters. */ |
4809 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4810 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4811 | | false, /* isTypedMethod. Only relevant for methods. */ |
4812 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4813 | | }; |
4814 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4815 | | static_assert(0 < 1, "There is no slot for us"); |
4816 | | |
4817 | | MOZ_CAN_RUN_SCRIPT static bool |
4818 | | getBoxQuads(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
4819 | 0 | { |
4820 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getBoxQuads", DOM, cx); |
4821 | 0 |
|
4822 | 0 | binding_detail::FastBoxQuadOptions arg0; |
4823 | 0 | if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1 of Element.getBoxQuads", false)) { |
4824 | 0 | return false; |
4825 | 0 | } |
4826 | 0 | FastErrorResult rv; |
4827 | 0 | nsTArray<StrongPtrForMember<mozilla::dom::DOMQuad>::Type> result; |
4828 | 0 | self->GetBoxQuads(Constify(arg0), result, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv); |
4829 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
4830 | 0 | return false; |
4831 | 0 | } |
4832 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
4833 | 0 |
|
4834 | 0 | uint32_t length = result.Length(); |
4835 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
4836 | 0 | if (!returnArray) { |
4837 | 0 | return false; |
4838 | 0 | } |
4839 | 0 | // Scope for 'tmp' |
4840 | 0 | { |
4841 | 0 | JS::Rooted<JS::Value> tmp(cx); |
4842 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
4843 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
4844 | 0 | // are different ways to succeed at wrapping the object. |
4845 | 0 | do { |
4846 | 0 | if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) { |
4847 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
4848 | 0 | return false; |
4849 | 0 | } |
4850 | 0 | break; |
4851 | 0 | } while (false); |
4852 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
4853 | 0 | JSPROP_ENUMERATE)) { |
4854 | 0 | return false; |
4855 | 0 | } |
4856 | 0 | } |
4857 | 0 | } |
4858 | 0 | args.rval().setObject(*returnArray); |
4859 | 0 | return true; |
4860 | 0 | } |
4861 | | |
4862 | | static const JSJitInfo getBoxQuads_methodinfo = { |
4863 | | { (JSJitGetterOp)getBoxQuads }, |
4864 | | { prototypes::id::Element }, |
4865 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4866 | | JSJitInfo::Method, |
4867 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
4868 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
4869 | | false, /* isInfallible. False in setters. */ |
4870 | | false, /* isMovable. Not relevant for setters. */ |
4871 | | false, /* isEliminatable. Not relevant for setters. */ |
4872 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4873 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4874 | | false, /* isTypedMethod. Only relevant for methods. */ |
4875 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4876 | | }; |
4877 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4878 | | static_assert(0 < 1, "There is no slot for us"); |
4879 | | |
4880 | | MOZ_CAN_RUN_SCRIPT static bool |
4881 | | convertQuadFromNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
4882 | 0 | { |
4883 | 0 | AUTO_PROFILER_LABEL_FAST("Element.convertQuadFromNode", DOM, cx); |
4884 | 0 |
|
4885 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
4886 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.convertQuadFromNode"); |
4887 | 0 | } |
4888 | 0 | NonNull<mozilla::dom::DOMQuad> arg0; |
4889 | 0 | if (args[0].isObject()) { |
4890 | 0 | { |
4891 | 0 | nsresult rv = UnwrapObject<prototypes::id::DOMQuad, mozilla::dom::DOMQuad>(args[0], arg0); |
4892 | 0 | if (NS_FAILED(rv)) { |
4893 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Element.convertQuadFromNode", "DOMQuad"); |
4894 | 0 | return false; |
4895 | 0 | } |
4896 | 0 | } |
4897 | 0 | } else { |
4898 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Element.convertQuadFromNode"); |
4899 | 0 | return false; |
4900 | 0 | } |
4901 | 0 | TextOrElementOrDocument arg1; |
4902 | 0 | TextOrElementOrDocumentArgument arg1_holder(arg1); |
4903 | 0 | { |
4904 | 0 | bool done = false, failed = false, tryNext; |
4905 | 0 | if (args[1].isObject()) { |
4906 | 0 | done = (failed = !arg1_holder.TrySetToText(cx, args[1], tryNext, false)) || !tryNext || |
4907 | 0 | (failed = !arg1_holder.TrySetToElement(cx, args[1], tryNext, false)) || !tryNext || |
4908 | 0 | (failed = !arg1_holder.TrySetToDocument(cx, args[1], tryNext, false)) || !tryNext; |
4909 | 0 |
|
4910 | 0 | } |
4911 | 0 | if (failed) { |
4912 | 0 | return false; |
4913 | 0 | } |
4914 | 0 | if (!done) { |
4915 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of Element.convertQuadFromNode", "Text, Element, Document"); |
4916 | 0 | return false; |
4917 | 0 | } |
4918 | 0 | } |
4919 | 0 | binding_detail::FastConvertCoordinateOptions arg2; |
4920 | 0 | if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue, "Argument 3 of Element.convertQuadFromNode", false)) { |
4921 | 0 | return false; |
4922 | 0 | } |
4923 | 0 | FastErrorResult rv; |
4924 | 0 | auto result(StrongOrRawPtr<mozilla::dom::DOMQuad>(self->ConvertQuadFromNode(MOZ_KnownLive(NonNullHelper(arg0)), Constify(arg1), Constify(arg2), nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv))); |
4925 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
4926 | 0 | return false; |
4927 | 0 | } |
4928 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
4929 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
4930 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
4931 | 0 | return false; |
4932 | 0 | } |
4933 | 0 | return true; |
4934 | 0 | } |
4935 | | |
4936 | | static const JSJitInfo convertQuadFromNode_methodinfo = { |
4937 | | { (JSJitGetterOp)convertQuadFromNode }, |
4938 | | { prototypes::id::Element }, |
4939 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
4940 | | JSJitInfo::Method, |
4941 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
4942 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
4943 | | false, /* isInfallible. False in setters. */ |
4944 | | false, /* isMovable. Not relevant for setters. */ |
4945 | | false, /* isEliminatable. Not relevant for setters. */ |
4946 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
4947 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
4948 | | false, /* isTypedMethod. Only relevant for methods. */ |
4949 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
4950 | | }; |
4951 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
4952 | | static_assert(0 < 1, "There is no slot for us"); |
4953 | | |
4954 | | MOZ_CAN_RUN_SCRIPT static bool |
4955 | | convertRectFromNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
4956 | 0 | { |
4957 | 0 | AUTO_PROFILER_LABEL_FAST("Element.convertRectFromNode", DOM, cx); |
4958 | 0 |
|
4959 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
4960 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.convertRectFromNode"); |
4961 | 0 | } |
4962 | 0 | NonNull<mozilla::dom::DOMRectReadOnly> arg0; |
4963 | 0 | if (args[0].isObject()) { |
4964 | 0 | { |
4965 | 0 | nsresult rv = UnwrapObject<prototypes::id::DOMRectReadOnly, mozilla::dom::DOMRectReadOnly>(args[0], arg0); |
4966 | 0 | if (NS_FAILED(rv)) { |
4967 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Element.convertRectFromNode", "DOMRectReadOnly"); |
4968 | 0 | return false; |
4969 | 0 | } |
4970 | 0 | } |
4971 | 0 | } else { |
4972 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Element.convertRectFromNode"); |
4973 | 0 | return false; |
4974 | 0 | } |
4975 | 0 | TextOrElementOrDocument arg1; |
4976 | 0 | TextOrElementOrDocumentArgument arg1_holder(arg1); |
4977 | 0 | { |
4978 | 0 | bool done = false, failed = false, tryNext; |
4979 | 0 | if (args[1].isObject()) { |
4980 | 0 | done = (failed = !arg1_holder.TrySetToText(cx, args[1], tryNext, false)) || !tryNext || |
4981 | 0 | (failed = !arg1_holder.TrySetToElement(cx, args[1], tryNext, false)) || !tryNext || |
4982 | 0 | (failed = !arg1_holder.TrySetToDocument(cx, args[1], tryNext, false)) || !tryNext; |
4983 | 0 |
|
4984 | 0 | } |
4985 | 0 | if (failed) { |
4986 | 0 | return false; |
4987 | 0 | } |
4988 | 0 | if (!done) { |
4989 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of Element.convertRectFromNode", "Text, Element, Document"); |
4990 | 0 | return false; |
4991 | 0 | } |
4992 | 0 | } |
4993 | 0 | binding_detail::FastConvertCoordinateOptions arg2; |
4994 | 0 | if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue, "Argument 3 of Element.convertRectFromNode", false)) { |
4995 | 0 | return false; |
4996 | 0 | } |
4997 | 0 | FastErrorResult rv; |
4998 | 0 | auto result(StrongOrRawPtr<mozilla::dom::DOMQuad>(self->ConvertRectFromNode(MOZ_KnownLive(NonNullHelper(arg0)), Constify(arg1), Constify(arg2), nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv))); |
4999 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
5000 | 0 | return false; |
5001 | 0 | } |
5002 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
5003 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
5004 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
5005 | 0 | return false; |
5006 | 0 | } |
5007 | 0 | return true; |
5008 | 0 | } |
5009 | | |
5010 | | static const JSJitInfo convertRectFromNode_methodinfo = { |
5011 | | { (JSJitGetterOp)convertRectFromNode }, |
5012 | | { prototypes::id::Element }, |
5013 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
5014 | | JSJitInfo::Method, |
5015 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
5016 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
5017 | | false, /* isInfallible. False in setters. */ |
5018 | | false, /* isMovable. Not relevant for setters. */ |
5019 | | false, /* isEliminatable. Not relevant for setters. */ |
5020 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
5021 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
5022 | | false, /* isTypedMethod. Only relevant for methods. */ |
5023 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
5024 | | }; |
5025 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
5026 | | static_assert(0 < 1, "There is no slot for us"); |
5027 | | |
5028 | | MOZ_CAN_RUN_SCRIPT static bool |
5029 | | convertPointFromNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
5030 | 0 | { |
5031 | 0 | AUTO_PROFILER_LABEL_FAST("Element.convertPointFromNode", DOM, cx); |
5032 | 0 |
|
5033 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
5034 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.convertPointFromNode"); |
5035 | 0 | } |
5036 | 0 | binding_detail::FastDOMPointInit arg0; |
5037 | 0 | if (!arg0.Init(cx, args[0], "Argument 1 of Element.convertPointFromNode", false)) { |
5038 | 0 | return false; |
5039 | 0 | } |
5040 | 0 | TextOrElementOrDocument arg1; |
5041 | 0 | TextOrElementOrDocumentArgument arg1_holder(arg1); |
5042 | 0 | { |
5043 | 0 | bool done = false, failed = false, tryNext; |
5044 | 0 | if (args[1].isObject()) { |
5045 | 0 | done = (failed = !arg1_holder.TrySetToText(cx, args[1], tryNext, false)) || !tryNext || |
5046 | 0 | (failed = !arg1_holder.TrySetToElement(cx, args[1], tryNext, false)) || !tryNext || |
5047 | 0 | (failed = !arg1_holder.TrySetToDocument(cx, args[1], tryNext, false)) || !tryNext; |
5048 | 0 |
|
5049 | 0 | } |
5050 | 0 | if (failed) { |
5051 | 0 | return false; |
5052 | 0 | } |
5053 | 0 | if (!done) { |
5054 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of Element.convertPointFromNode", "Text, Element, Document"); |
5055 | 0 | return false; |
5056 | 0 | } |
5057 | 0 | } |
5058 | 0 | binding_detail::FastConvertCoordinateOptions arg2; |
5059 | 0 | if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue, "Argument 3 of Element.convertPointFromNode", false)) { |
5060 | 0 | return false; |
5061 | 0 | } |
5062 | 0 | FastErrorResult rv; |
5063 | 0 | auto result(StrongOrRawPtr<mozilla::dom::DOMPoint>(self->ConvertPointFromNode(Constify(arg0), Constify(arg1), Constify(arg2), nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv))); |
5064 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
5065 | 0 | return false; |
5066 | 0 | } |
5067 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
5068 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
5069 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
5070 | 0 | return false; |
5071 | 0 | } |
5072 | 0 | return true; |
5073 | 0 | } |
5074 | | |
5075 | | static const JSJitInfo convertPointFromNode_methodinfo = { |
5076 | | { (JSJitGetterOp)convertPointFromNode }, |
5077 | | { prototypes::id::Element }, |
5078 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
5079 | | JSJitInfo::Method, |
5080 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
5081 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
5082 | | false, /* isInfallible. False in setters. */ |
5083 | | false, /* isMovable. Not relevant for setters. */ |
5084 | | false, /* isEliminatable. Not relevant for setters. */ |
5085 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
5086 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
5087 | | false, /* isTypedMethod. Only relevant for methods. */ |
5088 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
5089 | | }; |
5090 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
5091 | | static_assert(0 < 1, "There is no slot for us"); |
5092 | | |
5093 | | MOZ_CAN_RUN_SCRIPT static bool |
5094 | | get_previousElementSibling(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
5095 | 0 | { |
5096 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.previousElementSibling", DOM, cx); |
5097 | 0 |
|
5098 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Element>(self->GetPreviousElementSibling())); |
5099 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
5100 | 0 | if (!result) { |
5101 | 0 | args.rval().setNull(); |
5102 | 0 | return true; |
5103 | 0 | } |
5104 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
5105 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
5106 | 0 | return false; |
5107 | 0 | } |
5108 | 0 | return true; |
5109 | 0 | } |
5110 | | |
5111 | | static const JSJitInfo previousElementSibling_getterinfo = { |
5112 | | { (JSJitGetterOp)get_previousElementSibling }, |
5113 | | { prototypes::id::Element }, |
5114 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
5115 | | JSJitInfo::Getter, |
5116 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
5117 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
5118 | | false, /* isInfallible. False in setters. */ |
5119 | | true, /* isMovable. Not relevant for setters. */ |
5120 | | true, /* isEliminatable. Not relevant for setters. */ |
5121 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
5122 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
5123 | | false, /* isTypedMethod. Only relevant for methods. */ |
5124 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
5125 | | }; |
5126 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
5127 | | static_assert(0 < 1, "There is no slot for us"); |
5128 | | |
5129 | | MOZ_CAN_RUN_SCRIPT static bool |
5130 | | get_nextElementSibling(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
5131 | 0 | { |
5132 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.nextElementSibling", DOM, cx); |
5133 | 0 |
|
5134 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Element>(self->GetNextElementSibling())); |
5135 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
5136 | 0 | if (!result) { |
5137 | 0 | args.rval().setNull(); |
5138 | 0 | return true; |
5139 | 0 | } |
5140 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
5141 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
5142 | 0 | return false; |
5143 | 0 | } |
5144 | 0 | return true; |
5145 | 0 | } |
5146 | | |
5147 | | static const JSJitInfo nextElementSibling_getterinfo = { |
5148 | | { (JSJitGetterOp)get_nextElementSibling }, |
5149 | | { prototypes::id::Element }, |
5150 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
5151 | | JSJitInfo::Getter, |
5152 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
5153 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
5154 | | false, /* isInfallible. False in setters. */ |
5155 | | true, /* isMovable. Not relevant for setters. */ |
5156 | | true, /* isEliminatable. Not relevant for setters. */ |
5157 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
5158 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
5159 | | false, /* isTypedMethod. Only relevant for methods. */ |
5160 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
5161 | | }; |
5162 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
5163 | | static_assert(0 < 1, "There is no slot for us"); |
5164 | | |
5165 | | MOZ_CAN_RUN_SCRIPT static bool |
5166 | | get_children(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
5167 | 0 | { |
5168 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.children", DOM, cx); |
5169 | 0 |
|
5170 | 0 | auto result(StrongOrRawPtr<nsIHTMLCollection>(self->Children())); |
5171 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
5172 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
5173 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
5174 | 0 | return false; |
5175 | 0 | } |
5176 | 0 | return true; |
5177 | 0 | } |
5178 | | |
5179 | | static const JSJitInfo children_getterinfo = { |
5180 | | { (JSJitGetterOp)get_children }, |
5181 | | { prototypes::id::Element }, |
5182 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
5183 | | JSJitInfo::Getter, |
5184 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
5185 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
5186 | | false, /* isInfallible. False in setters. */ |
5187 | | true, /* isMovable. Not relevant for setters. */ |
5188 | | true, /* isEliminatable. Not relevant for setters. */ |
5189 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
5190 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
5191 | | false, /* isTypedMethod. Only relevant for methods. */ |
5192 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
5193 | | }; |
5194 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
5195 | | static_assert(0 < 1, "There is no slot for us"); |
5196 | | |
5197 | | MOZ_CAN_RUN_SCRIPT static bool |
5198 | | get_firstElementChild(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
5199 | 0 | { |
5200 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.firstElementChild", DOM, cx); |
5201 | 0 |
|
5202 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Element>(self->GetFirstElementChild())); |
5203 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
5204 | 0 | if (!result) { |
5205 | 0 | args.rval().setNull(); |
5206 | 0 | return true; |
5207 | 0 | } |
5208 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
5209 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
5210 | 0 | return false; |
5211 | 0 | } |
5212 | 0 | return true; |
5213 | 0 | } |
5214 | | |
5215 | | static const JSJitInfo firstElementChild_getterinfo = { |
5216 | | { (JSJitGetterOp)get_firstElementChild }, |
5217 | | { prototypes::id::Element }, |
5218 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
5219 | | JSJitInfo::Getter, |
5220 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
5221 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
5222 | | false, /* isInfallible. False in setters. */ |
5223 | | true, /* isMovable. Not relevant for setters. */ |
5224 | | true, /* isEliminatable. Not relevant for setters. */ |
5225 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
5226 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
5227 | | false, /* isTypedMethod. Only relevant for methods. */ |
5228 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
5229 | | }; |
5230 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
5231 | | static_assert(0 < 1, "There is no slot for us"); |
5232 | | |
5233 | | MOZ_CAN_RUN_SCRIPT static bool |
5234 | | get_lastElementChild(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
5235 | 0 | { |
5236 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.lastElementChild", DOM, cx); |
5237 | 0 |
|
5238 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Element>(self->GetLastElementChild())); |
5239 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
5240 | 0 | if (!result) { |
5241 | 0 | args.rval().setNull(); |
5242 | 0 | return true; |
5243 | 0 | } |
5244 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
5245 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
5246 | 0 | return false; |
5247 | 0 | } |
5248 | 0 | return true; |
5249 | 0 | } |
5250 | | |
5251 | | static const JSJitInfo lastElementChild_getterinfo = { |
5252 | | { (JSJitGetterOp)get_lastElementChild }, |
5253 | | { prototypes::id::Element }, |
5254 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
5255 | | JSJitInfo::Getter, |
5256 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
5257 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
5258 | | false, /* isInfallible. False in setters. */ |
5259 | | true, /* isMovable. Not relevant for setters. */ |
5260 | | true, /* isEliminatable. Not relevant for setters. */ |
5261 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
5262 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
5263 | | false, /* isTypedMethod. Only relevant for methods. */ |
5264 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
5265 | | }; |
5266 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
5267 | | static_assert(0 < 1, "There is no slot for us"); |
5268 | | |
5269 | | MOZ_CAN_RUN_SCRIPT static bool |
5270 | | get_childElementCount(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, JSJitGetterCallArgs args) |
5271 | 0 | { |
5272 | 0 | AUTO_PROFILER_LABEL_FAST("get Element.childElementCount", DOM, cx); |
5273 | 0 |
|
5274 | 0 | uint32_t result(self->ChildElementCount()); |
5275 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
5276 | 0 | args.rval().setNumber(result); |
5277 | 0 | return true; |
5278 | 0 | } |
5279 | | |
5280 | | static const JSJitInfo childElementCount_getterinfo = { |
5281 | | { (JSJitGetterOp)get_childElementCount }, |
5282 | | { prototypes::id::Element }, |
5283 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
5284 | | JSJitInfo::Getter, |
5285 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
5286 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
5287 | | true, /* isInfallible. False in setters. */ |
5288 | | true, /* isMovable. Not relevant for setters. */ |
5289 | | true, /* isEliminatable. Not relevant for setters. */ |
5290 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
5291 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
5292 | | false, /* isTypedMethod. Only relevant for methods. */ |
5293 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
5294 | | }; |
5295 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
5296 | | static_assert(0 < 1, "There is no slot for us"); |
5297 | | |
5298 | | MOZ_CAN_RUN_SCRIPT static bool |
5299 | | getElementsByAttribute(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
5300 | 0 | { |
5301 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getElementsByAttribute", DOM, cx); |
5302 | 0 |
|
5303 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
5304 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.getElementsByAttribute"); |
5305 | 0 | } |
5306 | 0 | binding_detail::FakeString arg0; |
5307 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
5308 | 0 | return false; |
5309 | 0 | } |
5310 | 0 | binding_detail::FakeString arg1; |
5311 | 0 | if (!ConvertJSValueToString(cx, args[1], eEmpty, eStringify, arg1)) { |
5312 | 0 | return false; |
5313 | 0 | } |
5314 | 0 | auto result(StrongOrRawPtr<nsIHTMLCollection>(self->GetElementsByAttribute(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1))))); |
5315 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
5316 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
5317 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
5318 | 0 | return false; |
5319 | 0 | } |
5320 | 0 | return true; |
5321 | 0 | } |
5322 | | |
5323 | | static const JSJitInfo getElementsByAttribute_methodinfo = { |
5324 | | { (JSJitGetterOp)getElementsByAttribute }, |
5325 | | { prototypes::id::Element }, |
5326 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
5327 | | JSJitInfo::Method, |
5328 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
5329 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
5330 | | false, /* isInfallible. False in setters. */ |
5331 | | false, /* isMovable. Not relevant for setters. */ |
5332 | | false, /* isEliminatable. Not relevant for setters. */ |
5333 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
5334 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
5335 | | false, /* isTypedMethod. Only relevant for methods. */ |
5336 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
5337 | | }; |
5338 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
5339 | | static_assert(0 < 1, "There is no slot for us"); |
5340 | | |
5341 | | MOZ_CAN_RUN_SCRIPT static bool |
5342 | | getElementsByAttributeNS(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
5343 | 0 | { |
5344 | 0 | AUTO_PROFILER_LABEL_FAST("Element.getElementsByAttributeNS", DOM, cx); |
5345 | 0 |
|
5346 | 0 | if (MOZ_UNLIKELY(args.length() < 3)) { |
5347 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Element.getElementsByAttributeNS"); |
5348 | 0 | } |
5349 | 0 | binding_detail::FakeString arg0; |
5350 | 0 | if (!ConvertJSValueToString(cx, args[0], eNull, eNull, arg0)) { |
5351 | 0 | return false; |
5352 | 0 | } |
5353 | 0 | binding_detail::FakeString arg1; |
5354 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
5355 | 0 | return false; |
5356 | 0 | } |
5357 | 0 | binding_detail::FakeString arg2; |
5358 | 0 | if (!ConvertJSValueToString(cx, args[2], eEmpty, eStringify, arg2)) { |
5359 | 0 | return false; |
5360 | 0 | } |
5361 | 0 | FastErrorResult rv; |
5362 | 0 | auto result(StrongOrRawPtr<nsIHTMLCollection>(self->GetElementsByAttributeNS(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), NonNullHelper(Constify(arg2)), rv))); |
5363 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
5364 | 0 | return false; |
5365 | 0 | } |
5366 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
5367 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
5368 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
5369 | 0 | return false; |
5370 | 0 | } |
5371 | 0 | return true; |
5372 | 0 | } |
5373 | | |
5374 | | static const JSJitInfo getElementsByAttributeNS_methodinfo = { |
5375 | | { (JSJitGetterOp)getElementsByAttributeNS }, |
5376 | | { prototypes::id::Element }, |
5377 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
5378 | | JSJitInfo::Method, |
5379 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
5380 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
5381 | | false, /* isInfallible. False in setters. */ |
5382 | | false, /* isMovable. Not relevant for setters. */ |
5383 | | false, /* isEliminatable. Not relevant for setters. */ |
5384 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
5385 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
5386 | | false, /* isTypedMethod. Only relevant for methods. */ |
5387 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
5388 | | }; |
5389 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
5390 | | static_assert(0 < 1, "There is no slot for us"); |
5391 | | |
5392 | | MOZ_CAN_RUN_SCRIPT static bool |
5393 | | prepend(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
5394 | 0 | { |
5395 | 0 | AUTO_PROFILER_LABEL_FAST("Element.prepend", DOM, cx); |
5396 | 0 |
|
5397 | 0 | AutoSequence<OwningNodeOrString> arg0; |
5398 | 0 | if (args.length() > 0) { |
5399 | 0 | if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) { |
5400 | 0 | JS_ReportOutOfMemory(cx); |
5401 | 0 | return false; |
5402 | 0 | } |
5403 | 0 | for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) { |
5404 | 0 | OwningNodeOrString& slot = *arg0.AppendElement(mozilla::fallible); |
5405 | 0 | { |
5406 | 0 | bool done = false, failed = false, tryNext; |
5407 | 0 | if (args[variadicArg].isObject()) { |
5408 | 0 | done = (failed = !slot.TrySetToNode(cx, args[variadicArg], tryNext, false)) || !tryNext; |
5409 | 0 |
|
5410 | 0 | } |
5411 | 0 | if (!done) { |
5412 | 0 | do { |
5413 | 0 | done = (failed = !slot.TrySetToString(cx, args[variadicArg], tryNext)) || !tryNext; |
5414 | 0 | break; |
5415 | 0 | } while (false); |
5416 | 0 | } |
5417 | 0 | if (failed) { |
5418 | 0 | return false; |
5419 | 0 | } |
5420 | 0 | if (!done) { |
5421 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of Element.prepend", "Node"); |
5422 | 0 | return false; |
5423 | 0 | } |
5424 | 0 | } |
5425 | 0 | } |
5426 | 0 | } |
5427 | 0 | Maybe<AutoCEReaction> ceReaction; |
5428 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
5429 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
5430 | 0 | if (docGroup) { |
5431 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
5432 | 0 | } |
5433 | 0 | } |
5434 | 0 | FastErrorResult rv; |
5435 | 0 | self->Prepend(Constify(arg0), rv); |
5436 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
5437 | 0 | return false; |
5438 | 0 | } |
5439 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
5440 | 0 | args.rval().setUndefined(); |
5441 | 0 | return true; |
5442 | 0 | } |
5443 | | |
5444 | | static const JSJitInfo prepend_methodinfo = { |
5445 | | { (JSJitGetterOp)prepend }, |
5446 | | { prototypes::id::Element }, |
5447 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
5448 | | JSJitInfo::Method, |
5449 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
5450 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
5451 | | false, /* isInfallible. False in setters. */ |
5452 | | false, /* isMovable. Not relevant for setters. */ |
5453 | | false, /* isEliminatable. Not relevant for setters. */ |
5454 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
5455 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
5456 | | false, /* isTypedMethod. Only relevant for methods. */ |
5457 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
5458 | | }; |
5459 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
5460 | | static_assert(0 < 1, "There is no slot for us"); |
5461 | | |
5462 | | MOZ_CAN_RUN_SCRIPT static bool |
5463 | | append(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Element* self, const JSJitMethodCallArgs& args) |
5464 | 0 | { |
5465 | 0 | AUTO_PROFILER_LABEL_FAST("Element.append", DOM, cx); |
5466 | 0 |
|
5467 | 0 | AutoSequence<OwningNodeOrString> arg0; |
5468 | 0 | if (args.length() > 0) { |
5469 | 0 | if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) { |
5470 | 0 | JS_ReportOutOfMemory(cx); |
5471 | 0 | return false; |
5472 | 0 | } |
5473 | 0 | for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) { |
5474 | 0 | OwningNodeOrString& slot = *arg0.AppendElement(mozilla::fallible); |
5475 | 0 | { |
5476 | 0 | bool done = false, failed = false, tryNext; |
5477 | 0 | if (args[variadicArg].isObject()) { |
5478 | 0 | done = (failed = !slot.TrySetToNode(cx, args[variadicArg], tryNext, false)) || !tryNext; |
5479 | 0 |
|
5480 | 0 | } |
5481 | 0 | if (!done) { |
5482 | 0 | do { |
5483 | 0 | done = (failed = !slot.TrySetToString(cx, args[variadicArg], tryNext)) || !tryNext; |
5484 | 0 | break; |
5485 | 0 | } while (false); |
5486 | 0 | } |
5487 | 0 | if (failed) { |
5488 | 0 | return false; |
5489 | 0 | } |
5490 | 0 | if (!done) { |
5491 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of Element.append", "Node"); |
5492 | 0 | return false; |
5493 | 0 | } |
5494 | 0 | } |
5495 | 0 | } |
5496 | 0 | } |
5497 | 0 | Maybe<AutoCEReaction> ceReaction; |
5498 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
5499 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
5500 | 0 | if (docGroup) { |
5501 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
5502 | 0 | } |
5503 | 0 | } |
5504 | 0 | FastErrorResult rv; |
5505 | 0 | self->Append(Constify(arg0), rv); |
5506 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
5507 | 0 | return false; |
5508 | 0 | } |
5509 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
5510 | 0 | args.rval().setUndefined(); |
5511 | 0 | return true; |
5512 | 0 | } |
5513 | | |
5514 | | static const JSJitInfo append_methodinfo = { |
5515 | | { (JSJitGetterOp)append }, |
5516 | | { prototypes::id::Element }, |
5517 | | { PrototypeTraits<prototypes::id::Element>::Depth }, |
5518 | | JSJitInfo::Method, |
5519 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
5520 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
5521 | | false, /* isInfallible. False in setters. */ |
5522 | | false, /* isMovable. Not relevant for setters. */ |
5523 | | false, /* isEliminatable. Not relevant for setters. */ |
5524 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
5525 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
5526 | | false, /* isTypedMethod. Only relevant for methods. */ |
5527 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
5528 | | }; |
5529 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
5530 | | static_assert(0 < 1, "There is no slot for us"); |
5531 | | |
5532 | | static bool |
5533 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
5534 | 0 | { |
5535 | 0 | mozilla::dom::Element* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Element>(obj); |
5536 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
5537 | 0 | // obviously can't preserve if we're not initialized. |
5538 | 0 | if (self && self->GetWrapperPreserveColor()) { |
5539 | 0 | PreserveWrapper(self); |
5540 | 0 | } |
5541 | 0 | return true; |
5542 | 0 | } |
5543 | | |
5544 | | static void |
5545 | | _finalize(js::FreeOp* fop, JSObject* obj) |
5546 | 0 | { |
5547 | 0 | mozilla::dom::Element* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Element>(obj); |
5548 | 0 | if (self) { |
5549 | 0 | ClearWrapper(self, self, obj); |
5550 | 0 | AddForDeferredFinalization<mozilla::dom::Element>(self); |
5551 | 0 | } |
5552 | 0 | } |
5553 | | |
5554 | | static size_t |
5555 | | _objectMoved(JSObject* obj, JSObject* old) |
5556 | 0 | { |
5557 | 0 | mozilla::dom::Element* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Element>(obj); |
5558 | 0 | if (self) { |
5559 | 0 | UpdateWrapper(self, self, obj, old); |
5560 | 0 | } |
5561 | 0 |
|
5562 | 0 | return 0; |
5563 | 0 | } |
5564 | | |
5565 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
5566 | | #if defined(__clang__) |
5567 | | #pragma clang diagnostic push |
5568 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
5569 | | #endif |
5570 | | static const JSFunctionSpec sMethods_specs[] = { |
5571 | | JS_FNSPEC("getAttributeNames", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getAttributeNames_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5572 | | JS_FNSPEC("getAttribute", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getAttribute_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5573 | | JS_FNSPEC("getAttributeNS", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getAttributeNS_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
5574 | | JS_FNSPEC("toggleAttribute", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&toggleAttribute_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5575 | | JS_FNSPEC("setAttribute", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setAttribute_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
5576 | | JS_FNSPEC("setAttributeNS", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setAttributeNS_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
5577 | | JS_FNSPEC("removeAttribute", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&removeAttribute_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5578 | | JS_FNSPEC("removeAttributeNS", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&removeAttributeNS_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
5579 | | JS_FNSPEC("hasAttribute", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&hasAttribute_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5580 | | JS_FNSPEC("hasAttributeNS", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&hasAttributeNS_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
5581 | | JS_FNSPEC("hasAttributes", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&hasAttributes_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5582 | | JS_FNSPEC("closest", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&closest_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5583 | | JS_FNSPEC("matches", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&matches_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5584 | | JS_FNSPEC("webkitMatchesSelector", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&webkitMatchesSelector_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5585 | | JS_FNSPEC("getElementsByTagName", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getElementsByTagName_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5586 | | JS_FNSPEC("getElementsByTagNameNS", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getElementsByTagNameNS_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
5587 | | JS_FNSPEC("getElementsByClassName", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getElementsByClassName_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5588 | | JS_FNSPEC("insertAdjacentElement", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&insertAdjacentElement_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
5589 | | JS_FNSPEC("insertAdjacentText", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&insertAdjacentText_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
5590 | | JS_FNSPEC("mozMatchesSelector", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&mozMatchesSelector_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5591 | | JS_FS_END, |
5592 | | JS_FNSPEC("setPointerCapture", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setPointerCapture_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5593 | | JS_FNSPEC("releasePointerCapture", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&releasePointerCapture_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5594 | | JS_FNSPEC("hasPointerCapture", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&hasPointerCapture_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5595 | | JS_FS_END, |
5596 | | JS_FNSPEC("setCapture", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setCapture_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5597 | | JS_FNSPEC("releaseCapture", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&releaseCapture_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5598 | | JS_FNSPEC("getAttributeNode", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getAttributeNode_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5599 | | JS_FNSPEC("setAttributeNode", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setAttributeNode_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5600 | | JS_FNSPEC("removeAttributeNode", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&removeAttributeNode_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5601 | | JS_FNSPEC("getAttributeNodeNS", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getAttributeNodeNS_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
5602 | | JS_FNSPEC("setAttributeNodeNS", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setAttributeNodeNS_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5603 | | JS_FNSPEC("getClientRects", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getClientRects_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5604 | | JS_FNSPEC("getBoundingClientRect", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getBoundingClientRect_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5605 | | JS_FNSPEC("scrollIntoView", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&scrollIntoView_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5606 | | JS_FNSPEC("scroll", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&scroll_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5607 | | JS_FNSPEC("scrollTo", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&scrollTo_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5608 | | JS_FNSPEC("scrollBy", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&scrollBy_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5609 | | JS_FNSPEC("insertAdjacentHTML", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&insertAdjacentHTML_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
5610 | | JS_FNSPEC("querySelector", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&querySelector_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5611 | | JS_FNSPEC("querySelectorAll", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&querySelectorAll_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5612 | | JS_FS_END, |
5613 | | JS_FNSPEC("attachShadow", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&attachShadow_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5614 | | JS_FS_END, |
5615 | | JS_FNSPEC("requestFullscreen", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&requestFullscreen_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5616 | | JS_FS_END, |
5617 | | JS_FNSPEC("mozRequestFullScreen", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&mozRequestFullScreen_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5618 | | JS_FS_END, |
5619 | | JS_FNSPEC("requestPointerLock", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&requestPointerLock_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5620 | | JS_FS_END, |
5621 | | JS_FNSPEC("animate", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&animate_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5622 | | JS_FS_END, |
5623 | | JS_FNSPEC("getAnimations", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getAnimations_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5624 | | JS_FS_END, |
5625 | | JS_FNSPEC("before", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&before_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5626 | | JS_FNSPEC("after", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&after_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5627 | | JS_FNSPEC("replaceWith", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&replaceWith_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5628 | | JS_FNSPEC("remove", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&remove_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5629 | | JS_FS_END, |
5630 | | JS_FNSPEC("getBoxQuads", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getBoxQuads_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5631 | | JS_FS_END, |
5632 | | JS_FNSPEC("convertQuadFromNode", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&convertQuadFromNode_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
5633 | | JS_FNSPEC("convertRectFromNode", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&convertRectFromNode_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
5634 | | JS_FNSPEC("convertPointFromNode", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&convertPointFromNode_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
5635 | | JS_FS_END, |
5636 | | JS_FNSPEC("getElementsByAttribute", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getElementsByAttribute_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
5637 | | JS_FNSPEC("getElementsByAttributeNS", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getElementsByAttributeNS_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
5638 | | JS_FS_END, |
5639 | | JS_FNSPEC("prepend", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&prepend_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5640 | | JS_FNSPEC("append", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&append_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5641 | | JS_FS_END |
5642 | | }; |
5643 | | #if defined(__clang__) |
5644 | | #pragma clang diagnostic pop |
5645 | | #endif |
5646 | | |
5647 | | // Can't be const because the pref-enabled boolean needs to be writable |
5648 | | static PrefableDisablers sMethods_disablers21 = { |
5649 | | true, false, 0, nullptr |
5650 | | }; |
5651 | | |
5652 | | // Can't be const because the pref-enabled boolean needs to be writable |
5653 | | static PrefableDisablers sMethods_disablers42 = { |
5654 | | true, false, 0, &nsDocument::IsShadowDOMEnabled |
5655 | | }; |
5656 | | |
5657 | | // Can't be const because the pref-enabled boolean needs to be writable |
5658 | | static PrefableDisablers sMethods_disablers44 = { |
5659 | | true, false, 0, &nsDocument::IsUnprefixedFullscreenEnabled |
5660 | | }; |
5661 | | |
5662 | | // Can't be const because the pref-enabled boolean needs to be writable |
5663 | | static PrefableDisablers sMethods_disablers48 = { |
5664 | | true, false, 0, nullptr |
5665 | | }; |
5666 | | |
5667 | | // Can't be const because the pref-enabled boolean needs to be writable |
5668 | | static PrefableDisablers sMethods_disablers52 = { |
5669 | | true, false, 0, &nsDocument::IsWebAnimationsGetAnimationsEnabled |
5670 | | }; |
5671 | | |
5672 | | // Can't be const because the pref-enabled boolean needs to be writable |
5673 | | static PrefableDisablers sMethods_disablers59 = { |
5674 | | true, false, 0, &nsINode::HasBoxQuadsSupport |
5675 | | }; |
5676 | | |
5677 | | // Can't be const because the pref-enabled boolean needs to be writable |
5678 | | static PrefableDisablers sMethods_disablers61 = { |
5679 | | true, false, 0, nullptr |
5680 | | }; |
5681 | | |
5682 | | // Can't be const because the pref-enabled boolean needs to be writable |
5683 | | static PrefableDisablers sMethods_disablers65 = { |
5684 | | true, false, 0, &IsChromeOrXBL |
5685 | | }; |
5686 | | |
5687 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
5688 | | { nullptr, &sMethods_specs[0] }, |
5689 | | { &sMethods_disablers21, &sMethods_specs[21] }, |
5690 | | { nullptr, &sMethods_specs[25] }, |
5691 | | { &sMethods_disablers42, &sMethods_specs[42] }, |
5692 | | { &sMethods_disablers44, &sMethods_specs[44] }, |
5693 | | { nullptr, &sMethods_specs[46] }, |
5694 | | { &sMethods_disablers48, &sMethods_specs[48] }, |
5695 | | { nullptr, &sMethods_specs[50] }, |
5696 | | { &sMethods_disablers52, &sMethods_specs[52] }, |
5697 | | { nullptr, &sMethods_specs[54] }, |
5698 | | { &sMethods_disablers59, &sMethods_specs[59] }, |
5699 | | { &sMethods_disablers61, &sMethods_specs[61] }, |
5700 | | { &sMethods_disablers65, &sMethods_specs[65] }, |
5701 | | { nullptr, &sMethods_specs[68] }, |
5702 | | { nullptr, nullptr } |
5703 | | }; |
5704 | | |
5705 | | static_assert(14 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
5706 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
5707 | | static_assert(20 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
5708 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
5709 | | |
5710 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
5711 | | #if defined(__clang__) |
5712 | | #pragma clang diagnostic push |
5713 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
5714 | | #endif |
5715 | | static const JSFunctionSpec sChromeMethods_specs[] = { |
5716 | | JS_FNSPEC("setCaptureAlways", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setCaptureAlways_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5717 | | JS_FNSPEC("scrollByNoFlush", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&scrollByNoFlush_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
5718 | | JS_FNSPEC("getTransformToAncestor", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getTransformToAncestor_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5719 | | JS_FNSPEC("getTransformToParent", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getTransformToParent_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5720 | | JS_FNSPEC("getTransformToViewport", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getTransformToViewport_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5721 | | JS_FNSPEC("mozScrollSnap", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&mozScrollSnap_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5722 | | JS_FNSPEC("getAsFlexContainer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getAsFlexContainer_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5723 | | JS_FNSPEC("getGridFragments", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getGridFragments_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5724 | | JS_FNSPEC("getElementsWithGrid", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getElementsWithGrid_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5725 | | JS_FNSPEC("QueryInterface", QueryInterface, nullptr, 1, 0, nullptr), |
5726 | | JS_FS_END |
5727 | | }; |
5728 | | #if defined(__clang__) |
5729 | | #pragma clang diagnostic pop |
5730 | | #endif |
5731 | | |
5732 | | |
5733 | | static const Prefable<const JSFunctionSpec> sChromeMethods[] = { |
5734 | | { nullptr, &sChromeMethods_specs[0] }, |
5735 | | { nullptr, nullptr } |
5736 | | }; |
5737 | | |
5738 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
5739 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
5740 | | static_assert(10 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
5741 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
5742 | | |
5743 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
5744 | | #if defined(__clang__) |
5745 | | #pragma clang diagnostic push |
5746 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
5747 | | #endif |
5748 | | static const JSPropertySpec sAttributes_specs[] = { |
5749 | | { "namespaceURI", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &namespaceURI_getterinfo, nullptr, nullptr }, |
5750 | | { "prefix", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &prefix_getterinfo, nullptr, nullptr }, |
5751 | | { "localName", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &localName_getterinfo, nullptr, nullptr }, |
5752 | | { "tagName", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &tagName_getterinfo, nullptr, nullptr }, |
5753 | | { "id", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &id_getterinfo, GenericSetter<NormalThisPolicy>, &id_setterinfo }, |
5754 | | { "className", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &className_getterinfo, GenericSetter<NormalThisPolicy>, &className_setterinfo }, |
5755 | | { "classList", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &classList_getterinfo, GenericSetter<NormalThisPolicy>, &classList_setterinfo }, |
5756 | | { "attributes", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &attributes_getterinfo, nullptr, nullptr }, |
5757 | | { "scrollTop", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &scrollTop_getterinfo, GenericSetter<NormalThisPolicy>, &scrollTop_setterinfo }, |
5758 | | { "scrollLeft", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &scrollLeft_getterinfo, GenericSetter<NormalThisPolicy>, &scrollLeft_setterinfo }, |
5759 | | { "scrollWidth", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &scrollWidth_getterinfo, nullptr, nullptr }, |
5760 | | { "scrollHeight", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &scrollHeight_getterinfo, nullptr, nullptr }, |
5761 | | { "clientTop", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &clientTop_getterinfo, nullptr, nullptr }, |
5762 | | { "clientLeft", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &clientLeft_getterinfo, nullptr, nullptr }, |
5763 | | { "clientWidth", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &clientWidth_getterinfo, nullptr, nullptr }, |
5764 | | { "clientHeight", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &clientHeight_getterinfo, nullptr, nullptr }, |
5765 | | { "scrollTopMax", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &scrollTopMax_getterinfo, nullptr, nullptr }, |
5766 | | { "scrollLeftMax", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &scrollLeftMax_getterinfo, nullptr, nullptr }, |
5767 | | { "innerHTML", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &innerHTML_getterinfo, GenericSetter<NormalThisPolicy>, &innerHTML_setterinfo }, |
5768 | | { "outerHTML", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &outerHTML_getterinfo, GenericSetter<NormalThisPolicy>, &outerHTML_setterinfo }, |
5769 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr }, |
5770 | | { "shadowRoot", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &shadowRoot_getterinfo, nullptr, nullptr }, |
5771 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr }, |
5772 | | { "openOrClosedShadowRoot", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &openOrClosedShadowRoot_getterinfo, nullptr, nullptr }, |
5773 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr }, |
5774 | | { "assignedSlot", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &assignedSlot_getterinfo, nullptr, nullptr }, |
5775 | | { "slot", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &slot_getterinfo, GenericSetter<NormalThisPolicy>, &slot_setterinfo }, |
5776 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr }, |
5777 | | { "onfullscreenchange", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onfullscreenchange_getterinfo, GenericSetter<NormalThisPolicy>, &onfullscreenchange_setterinfo }, |
5778 | | { "onfullscreenerror", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onfullscreenerror_getterinfo, GenericSetter<NormalThisPolicy>, &onfullscreenerror_setterinfo }, |
5779 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr }, |
5780 | | { "previousElementSibling", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &previousElementSibling_getterinfo, nullptr, nullptr }, |
5781 | | { "nextElementSibling", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &nextElementSibling_getterinfo, nullptr, nullptr }, |
5782 | | { "children", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &children_getterinfo, nullptr, nullptr }, |
5783 | | { "firstElementChild", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &firstElementChild_getterinfo, nullptr, nullptr }, |
5784 | | { "lastElementChild", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &lastElementChild_getterinfo, nullptr, nullptr }, |
5785 | | { "childElementCount", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &childElementCount_getterinfo, nullptr, nullptr }, |
5786 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
5787 | | }; |
5788 | | #if defined(__clang__) |
5789 | | #pragma clang diagnostic pop |
5790 | | #endif |
5791 | | |
5792 | | // Can't be const because the pref-enabled boolean needs to be writable |
5793 | | static PrefableDisablers sAttributes_disablers21 = { |
5794 | | true, false, 0, &nsDocument::IsShadowDOMEnabled |
5795 | | }; |
5796 | | |
5797 | | // Can't be const because the pref-enabled boolean needs to be writable |
5798 | | static PrefableDisablers sAttributes_disablers23 = { |
5799 | | true, false, 0, &nsDocument::IsShadowDOMEnabledAndCallerIsChromeOrAddon |
5800 | | }; |
5801 | | |
5802 | | // Can't be const because the pref-enabled boolean needs to be writable |
5803 | | static PrefableDisablers sAttributes_disablers25 = { |
5804 | | true, false, 0, &nsDocument::IsShadowDOMEnabled |
5805 | | }; |
5806 | | |
5807 | | // Can't be const because the pref-enabled boolean needs to be writable |
5808 | | static PrefableDisablers sAttributes_disablers28 = { |
5809 | | true, false, 0, &nsDocument::IsUnprefixedFullscreenEnabled |
5810 | | }; |
5811 | | |
5812 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
5813 | | { nullptr, &sAttributes_specs[0] }, |
5814 | | { &sAttributes_disablers21, &sAttributes_specs[21] }, |
5815 | | { &sAttributes_disablers23, &sAttributes_specs[23] }, |
5816 | | { &sAttributes_disablers25, &sAttributes_specs[25] }, |
5817 | | { &sAttributes_disablers28, &sAttributes_specs[28] }, |
5818 | | { nullptr, &sAttributes_specs[31] }, |
5819 | | { nullptr, nullptr } |
5820 | | }; |
5821 | | |
5822 | | static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
5823 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
5824 | | static_assert(20 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
5825 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
5826 | | |
5827 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
5828 | | #if defined(__clang__) |
5829 | | #pragma clang diagnostic push |
5830 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
5831 | | #endif |
5832 | | static const JSPropertySpec sChromeAttributes_specs[] = { |
5833 | | { "fontSizeInflation", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &fontSizeInflation_getterinfo, nullptr, nullptr }, |
5834 | | { "scrollTopMin", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &scrollTopMin_getterinfo, nullptr, nullptr }, |
5835 | | { "scrollLeftMin", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &scrollLeftMin_getterinfo, nullptr, nullptr }, |
5836 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr }, |
5837 | | { "openOrClosedAssignedSlot", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &openOrClosedAssignedSlot_getterinfo, nullptr, nullptr }, |
5838 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
5839 | | }; |
5840 | | #if defined(__clang__) |
5841 | | #pragma clang diagnostic pop |
5842 | | #endif |
5843 | | |
5844 | | // Can't be const because the pref-enabled boolean needs to be writable |
5845 | | static PrefableDisablers sChromeAttributes_disablers4 = { |
5846 | | true, false, 0, &nsDocument::IsShadowDOMEnabled |
5847 | | }; |
5848 | | |
5849 | | static const Prefable<const JSPropertySpec> sChromeAttributes[] = { |
5850 | | { nullptr, &sChromeAttributes_specs[0] }, |
5851 | | { &sChromeAttributes_disablers4, &sChromeAttributes_specs[4] }, |
5852 | | { nullptr, nullptr } |
5853 | | }; |
5854 | | |
5855 | | static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
5856 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
5857 | | static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
5858 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
5859 | | |
5860 | | |
5861 | | static uint16_t sNativeProperties_sortedPropertyIndices[89]; |
5862 | | static PropertyInfo sNativeProperties_propertyInfos[89]; |
5863 | | |
5864 | | static const NativePropertiesN<2> sNativeProperties = { |
5865 | | false, 0, |
5866 | | false, 0, |
5867 | | true, 0 /* sMethods */, |
5868 | | true, 1 /* sAttributes */, |
5869 | | false, 0, |
5870 | | false, 0, |
5871 | | false, 0, |
5872 | | -1, |
5873 | | 89, |
5874 | | sNativeProperties_sortedPropertyIndices, |
5875 | | { |
5876 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
5877 | | { sAttributes, &sNativeProperties_propertyInfos[57] } |
5878 | | } |
5879 | | }; |
5880 | | static_assert(89 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
5881 | | "We have a property info count that is oversized"); |
5882 | | |
5883 | | static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[14]; |
5884 | | static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[14]; |
5885 | | |
5886 | | static const NativePropertiesN<2> sChromeOnlyNativeProperties = { |
5887 | | false, 0, |
5888 | | false, 0, |
5889 | | true, 0 /* sChromeMethods */, |
5890 | | true, 1 /* sChromeAttributes */, |
5891 | | false, 0, |
5892 | | false, 0, |
5893 | | false, 0, |
5894 | | -1, |
5895 | | 14, |
5896 | | sChromeOnlyNativeProperties_sortedPropertyIndices, |
5897 | | { |
5898 | | { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }, |
5899 | | { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[10] } |
5900 | | } |
5901 | | }; |
5902 | | static_assert(14 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount), |
5903 | | "We have a property info count that is oversized"); |
5904 | | |
5905 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
5906 | | { |
5907 | | "Function", |
5908 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
5909 | | &sBoringInterfaceObjectClassClassOps, |
5910 | | JS_NULL_CLASS_SPEC, |
5911 | | JS_NULL_CLASS_EXT, |
5912 | | &sInterfaceObjectClassObjectOps |
5913 | | }, |
5914 | | eInterface, |
5915 | | true, |
5916 | | prototypes::id::Element, |
5917 | | PrototypeTraits<prototypes::id::Element>::Depth, |
5918 | | sNativePropertyHooks, |
5919 | | "function Element() {\n [native code]\n}", |
5920 | | Node_Binding::GetConstructorObject |
5921 | | }; |
5922 | | |
5923 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
5924 | | { |
5925 | | "ElementPrototype", |
5926 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
5927 | | JS_NULL_CLASS_OPS, |
5928 | | JS_NULL_CLASS_SPEC, |
5929 | | JS_NULL_CLASS_EXT, |
5930 | | JS_NULL_OBJECT_OPS |
5931 | | }, |
5932 | | eInterfacePrototype, |
5933 | | false, |
5934 | | prototypes::id::Element, |
5935 | | PrototypeTraits<prototypes::id::Element>::Depth, |
5936 | | sNativePropertyHooks, |
5937 | | "[object ElementPrototype]", |
5938 | | Node_Binding::GetProtoObject |
5939 | | }; |
5940 | | |
5941 | | static const js::ClassOps sClassOps = { |
5942 | | _addProperty, /* addProperty */ |
5943 | | nullptr, /* delProperty */ |
5944 | | nullptr, /* enumerate */ |
5945 | | nullptr, /* newEnumerate */ |
5946 | | nullptr, /* resolve */ |
5947 | | nullptr, /* mayResolve */ |
5948 | | _finalize, /* finalize */ |
5949 | | nullptr, /* call */ |
5950 | | nullptr, /* hasInstance */ |
5951 | | nullptr, /* construct */ |
5952 | | nullptr, /* trace */ |
5953 | | }; |
5954 | | |
5955 | | static const js::ClassExtension sClassExtension = { |
5956 | | nullptr, /* weakmapKeyDelegateOp */ |
5957 | | _objectMoved /* objectMovedOp */ |
5958 | | }; |
5959 | | |
5960 | | static const DOMJSClass sClass = { |
5961 | | { "Element", |
5962 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
5963 | | &sClassOps, |
5964 | | JS_NULL_CLASS_SPEC, |
5965 | | &sClassExtension, |
5966 | | JS_NULL_OBJECT_OPS |
5967 | | }, |
5968 | | { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
5969 | | IsBaseOf<nsISupports, mozilla::dom::Element >::value, |
5970 | | sNativePropertyHooks, |
5971 | | FindAssociatedGlobalForNative<mozilla::dom::Element>::Get, |
5972 | | GetProtoObjectHandle, |
5973 | | GetCCParticipant<mozilla::dom::Element>::Get() |
5974 | | }; |
5975 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
5976 | | "Must have the right minimal number of reserved slots."); |
5977 | | static_assert(1 >= 1, |
5978 | | "Must have enough reserved slots."); |
5979 | | |
5980 | | const JSClass* |
5981 | | GetJSClass() |
5982 | 0 | { |
5983 | 0 | return sClass.ToJSClass(); |
5984 | 0 | } |
5985 | | |
5986 | | bool |
5987 | | Wrap(JSContext* aCx, mozilla::dom::Element* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
5988 | 0 | { |
5989 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::Element>::value, |
5990 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
5991 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) == |
5992 | 0 | reinterpret_cast<mozilla::dom::Element*>(aObject), |
5993 | 0 | "Multiple inheritance for mozilla::dom::Element is broken."); |
5994 | 0 | MOZ_ASSERT(static_cast<nsINode*>(aObject) == |
5995 | 0 | reinterpret_cast<nsINode*>(aObject), |
5996 | 0 | "Multiple inheritance for nsINode is broken."); |
5997 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
5998 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
5999 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
6000 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
6001 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
6002 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
6003 | 0 | "You should probably not be using Wrap() directly; use " |
6004 | 0 | "GetOrCreateDOMReflector instead"); |
6005 | 0 |
|
6006 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
6007 | 0 | "nsISupports must be on our primary inheritance chain"); |
6008 | 0 |
|
6009 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
6010 | 0 | if (!global) { |
6011 | 0 | return false; |
6012 | 0 | } |
6013 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
6014 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
6015 | 0 |
|
6016 | 0 | // That might have ended up wrapping us already, due to the wonders |
6017 | 0 | // of XBL. Check for that, and bail out as needed. |
6018 | 0 | aReflector.set(aCache->GetWrapper()); |
6019 | 0 | if (aReflector) { |
6020 | | #ifdef DEBUG |
6021 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
6022 | | #endif // DEBUG |
6023 | | return true; |
6024 | 0 | } |
6025 | 0 |
|
6026 | 0 | JSAutoRealm ar(aCx, global); |
6027 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
6028 | 0 | if (!canonicalProto) { |
6029 | 0 | return false; |
6030 | 0 | } |
6031 | 0 | JS::Rooted<JSObject*> proto(aCx); |
6032 | 0 | if (aGivenProto) { |
6033 | 0 | proto = aGivenProto; |
6034 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
6035 | 0 | // coming in, we changed compartments to that of "parent" so may need |
6036 | 0 | // to wrap the proto here. |
6037 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
6038 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
6039 | 0 | return false; |
6040 | 0 | } |
6041 | 0 | } |
6042 | 0 | } else { |
6043 | 0 | proto = canonicalProto; |
6044 | 0 | } |
6045 | 0 |
|
6046 | 0 | BindingJSObjectCreator<mozilla::dom::Element> creator(aCx); |
6047 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
6048 | 0 | if (!aReflector) { |
6049 | 0 | return false; |
6050 | 0 | } |
6051 | 0 | |
6052 | 0 | aCache->SetWrapper(aReflector); |
6053 | 0 | creator.InitializationSucceeded(); |
6054 | 0 |
|
6055 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
6056 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
6057 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
6058 | 0 | // otherwise we won't be able to properly recreate it later, since |
6059 | 0 | // we won't know what proto to use. Note that we don't check |
6060 | 0 | // aGivenProto here, since it's entirely possible (and even |
6061 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
6062 | 0 | // same as canonicalProto. |
6063 | 0 | if (proto != canonicalProto) { |
6064 | 0 | PreserveWrapper(aObject); |
6065 | 0 | } |
6066 | 0 |
|
6067 | 0 | return true; |
6068 | 0 | } |
6069 | | |
6070 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
6071 | | nullptr, |
6072 | | nullptr, |
6073 | | nullptr, |
6074 | | { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() }, |
6075 | | prototypes::id::Element, |
6076 | | constructors::id::Element, |
6077 | | Node_Binding::sNativePropertyHooks, |
6078 | | &DefaultXrayExpandoObjectClass |
6079 | | } }; |
6080 | | |
6081 | | static const char* const unscopableNames[] = { |
6082 | | "slot", |
6083 | | "before", |
6084 | | "after", |
6085 | | "replaceWith", |
6086 | | "remove", |
6087 | | "prepend", |
6088 | | "append", |
6089 | | nullptr |
6090 | | }; |
6091 | | |
6092 | | void |
6093 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
6094 | 0 | { |
6095 | 0 | JS::Handle<JSObject*> parentProto(Node_Binding::GetProtoObjectHandle(aCx)); |
6096 | 0 | if (!parentProto) { |
6097 | 0 | return; |
6098 | 0 | } |
6099 | 0 | |
6100 | 0 | JS::Handle<JSObject*> constructorProto(Node_Binding::GetConstructorObjectHandle(aCx)); |
6101 | 0 | if (!constructorProto) { |
6102 | 0 | return; |
6103 | 0 | } |
6104 | 0 | |
6105 | 0 | static bool sIdsInited = false; |
6106 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
6107 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
6108 | 0 | return; |
6109 | 0 | } |
6110 | 0 | if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) { |
6111 | 0 | return; |
6112 | 0 | } |
6113 | 0 | sIdsInited = true; |
6114 | 0 | } |
6115 | 0 |
|
6116 | 0 | static bool sPrefCachesInited = false; |
6117 | 0 | if (!sPrefCachesInited && NS_IsMainThread()) { |
6118 | 0 | sPrefCachesInited = true; |
6119 | 0 | Preferences::AddBoolVarCache(&sMethods[1].disablers->enabled, "dom.w3c_pointer_events.enabled"); |
6120 | 0 | Preferences::AddBoolVarCache(&sMethods[6].disablers->enabled, "dom.pointer-lock.enabled"); |
6121 | 0 | Preferences::AddBoolVarCache(&sMethods[11].disablers->enabled, "layout.css.convertFromNode.enabled"); |
6122 | 0 | } |
6123 | 0 |
|
6124 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::Element); |
6125 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::Element); |
6126 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
6127 | 0 | &sPrototypeClass.mBase, protoCache, |
6128 | 0 | nullptr, |
6129 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
6130 | 0 | interfaceCache, |
6131 | 0 | sNativeProperties.Upcast(), |
6132 | 0 | sChromeOnlyNativeProperties.Upcast(), |
6133 | 0 | "Element", aDefineOnGlobal, |
6134 | 0 | unscopableNames, |
6135 | 0 | false); |
6136 | 0 | } |
6137 | | |
6138 | | JSObject* |
6139 | | GetProtoObject(JSContext* aCx) |
6140 | 0 | { |
6141 | 0 | return GetProtoObjectHandle(aCx); |
6142 | 0 | } |
6143 | | |
6144 | | JSObject* |
6145 | | GetConstructorObject(JSContext* aCx) |
6146 | 0 | { |
6147 | 0 | return GetConstructorObjectHandle(aCx); |
6148 | 0 | } |
6149 | | |
6150 | | } // namespace Element_Binding |
6151 | | |
6152 | | |
6153 | | |
6154 | | } // namespace dom |
6155 | | } // namespace mozilla |