Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM AnonymousContent.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "AnonymousContentBinding.h"
4 : #include "KeyframeAnimationOptionsBinding.h"
5 : #include "WrapperFactory.h"
6 : #include "mozilla/OwningNonNull.h"
7 : #include "mozilla/dom/Animation.h"
8 : #include "mozilla/dom/AnonymousContent.h"
9 : #include "mozilla/dom/BindingUtils.h"
10 : #include "mozilla/dom/DOMJSClass.h"
11 : #include "mozilla/dom/DOMRect.h"
12 : #include "mozilla/dom/NonRefcountedDOMObject.h"
13 : #include "mozilla/dom/Nullable.h"
14 : #include "mozilla/dom/UnionConversions.h"
15 : #include "mozilla/dom/XrayExpandoClass.h"
16 : #include "nsContentUtils.h"
17 : #include "nsDocument.h"
18 : #include "nsISupports.h"
19 :
20 : namespace mozilla {
21 : namespace dom {
22 :
23 : namespace AnonymousContentBinding {
24 :
25 : static bool
26 0 : getTextContentForElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnonymousContent* self, const JSJitMethodCallArgs& args)
27 : {
28 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
29 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnonymousContent.getTextContentForElement");
30 : }
31 0 : binding_detail::FakeString arg0;
32 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
33 0 : return false;
34 : }
35 0 : binding_detail::FastErrorResult rv;
36 0 : DOMString result;
37 0 : self->GetTextContentForElement(NonNullHelper(Constify(arg0)), result, rv);
38 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
39 0 : return false;
40 : }
41 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
42 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
43 0 : return false;
44 : }
45 0 : return true;
46 : }
47 :
48 : static const JSJitInfo getTextContentForElement_methodinfo = {
49 : { (JSJitGetterOp)getTextContentForElement },
50 : { prototypes::id::AnonymousContent },
51 : { PrototypeTraits<prototypes::id::AnonymousContent>::Depth },
52 : JSJitInfo::Method,
53 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
54 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
55 : false, /* isInfallible. False in setters. */
56 : false, /* isMovable. Not relevant for setters. */
57 : false, /* isEliminatable. Not relevant for setters. */
58 : false, /* isAlwaysInSlot. Only relevant for getters. */
59 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
60 : false, /* isTypedMethod. Only relevant for methods. */
61 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
62 : };
63 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
64 : static_assert(0 < 1, "There is no slot for us");
65 :
66 : static bool
67 0 : setTextContentForElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnonymousContent* self, const JSJitMethodCallArgs& args)
68 : {
69 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
70 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnonymousContent.setTextContentForElement");
71 : }
72 0 : binding_detail::FakeString arg0;
73 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
74 0 : return false;
75 : }
76 0 : binding_detail::FakeString arg1;
77 0 : if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
78 0 : return false;
79 : }
80 0 : binding_detail::FastErrorResult rv;
81 0 : self->SetTextContentForElement(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv);
82 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
83 0 : return false;
84 : }
85 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
86 0 : args.rval().setUndefined();
87 0 : return true;
88 : }
89 :
90 : static const JSJitInfo setTextContentForElement_methodinfo = {
91 : { (JSJitGetterOp)setTextContentForElement },
92 : { prototypes::id::AnonymousContent },
93 : { PrototypeTraits<prototypes::id::AnonymousContent>::Depth },
94 : JSJitInfo::Method,
95 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
96 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
97 : false, /* isInfallible. False in setters. */
98 : false, /* isMovable. Not relevant for setters. */
99 : false, /* isEliminatable. Not relevant for setters. */
100 : false, /* isAlwaysInSlot. Only relevant for getters. */
101 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
102 : false, /* isTypedMethod. Only relevant for methods. */
103 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
104 : };
105 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
106 : static_assert(0 < 1, "There is no slot for us");
107 :
108 : static bool
109 0 : getAttributeForElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnonymousContent* self, const JSJitMethodCallArgs& args)
110 : {
111 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
112 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnonymousContent.getAttributeForElement");
113 : }
114 0 : binding_detail::FakeString arg0;
115 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
116 0 : return false;
117 : }
118 0 : binding_detail::FakeString arg1;
119 0 : if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
120 0 : return false;
121 : }
122 0 : binding_detail::FastErrorResult rv;
123 0 : DOMString result;
124 0 : self->GetAttributeForElement(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), result, rv);
125 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
126 0 : return false;
127 : }
128 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
129 0 : if (!xpc::StringToJsval(cx, result, args.rval())) {
130 0 : return false;
131 : }
132 0 : return true;
133 : }
134 :
135 : static const JSJitInfo getAttributeForElement_methodinfo = {
136 : { (JSJitGetterOp)getAttributeForElement },
137 : { prototypes::id::AnonymousContent },
138 : { PrototypeTraits<prototypes::id::AnonymousContent>::Depth },
139 : JSJitInfo::Method,
140 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
141 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
142 : false, /* isInfallible. False in setters. */
143 : false, /* isMovable. Not relevant for setters. */
144 : false, /* isEliminatable. Not relevant for setters. */
145 : false, /* isAlwaysInSlot. Only relevant for getters. */
146 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
147 : false, /* isTypedMethod. Only relevant for methods. */
148 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
149 : };
150 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
151 : static_assert(0 < 1, "There is no slot for us");
152 :
153 : static bool
154 0 : setAttributeForElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnonymousContent* self, const JSJitMethodCallArgs& args)
155 : {
156 0 : if (MOZ_UNLIKELY(args.length() < 3)) {
157 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnonymousContent.setAttributeForElement");
158 : }
159 0 : binding_detail::FakeString arg0;
160 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
161 0 : return false;
162 : }
163 0 : binding_detail::FakeString arg1;
164 0 : if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
165 0 : return false;
166 : }
167 0 : binding_detail::FakeString arg2;
168 0 : if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2)) {
169 0 : return false;
170 : }
171 0 : binding_detail::FastErrorResult rv;
172 0 : self->SetAttributeForElement(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), NonNullHelper(Constify(arg2)), rv);
173 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
174 0 : return false;
175 : }
176 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
177 0 : args.rval().setUndefined();
178 0 : return true;
179 : }
180 :
181 : static const JSJitInfo setAttributeForElement_methodinfo = {
182 : { (JSJitGetterOp)setAttributeForElement },
183 : { prototypes::id::AnonymousContent },
184 : { PrototypeTraits<prototypes::id::AnonymousContent>::Depth },
185 : JSJitInfo::Method,
186 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
187 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
188 : false, /* isInfallible. False in setters. */
189 : false, /* isMovable. Not relevant for setters. */
190 : false, /* isEliminatable. Not relevant for setters. */
191 : false, /* isAlwaysInSlot. Only relevant for getters. */
192 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
193 : false, /* isTypedMethod. Only relevant for methods. */
194 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
195 : };
196 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
197 : static_assert(0 < 1, "There is no slot for us");
198 :
199 : static bool
200 0 : removeAttributeForElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnonymousContent* self, const JSJitMethodCallArgs& args)
201 : {
202 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
203 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnonymousContent.removeAttributeForElement");
204 : }
205 0 : binding_detail::FakeString arg0;
206 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
207 0 : return false;
208 : }
209 0 : binding_detail::FakeString arg1;
210 0 : if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
211 0 : return false;
212 : }
213 0 : binding_detail::FastErrorResult rv;
214 0 : self->RemoveAttributeForElement(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv);
215 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
216 0 : return false;
217 : }
218 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
219 0 : args.rval().setUndefined();
220 0 : return true;
221 : }
222 :
223 : static const JSJitInfo removeAttributeForElement_methodinfo = {
224 : { (JSJitGetterOp)removeAttributeForElement },
225 : { prototypes::id::AnonymousContent },
226 : { PrototypeTraits<prototypes::id::AnonymousContent>::Depth },
227 : JSJitInfo::Method,
228 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
229 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
230 : false, /* isInfallible. False in setters. */
231 : false, /* isMovable. Not relevant for setters. */
232 : false, /* isEliminatable. Not relevant for setters. */
233 : false, /* isAlwaysInSlot. Only relevant for getters. */
234 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
235 : false, /* isTypedMethod. Only relevant for methods. */
236 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
237 : };
238 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
239 : static_assert(0 < 1, "There is no slot for us");
240 :
241 : static bool
242 0 : getCanvasContext(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnonymousContent* self, const JSJitMethodCallArgs& args)
243 : {
244 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
245 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnonymousContent.getCanvasContext");
246 : }
247 0 : binding_detail::FakeString arg0;
248 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
249 0 : return false;
250 : }
251 0 : binding_detail::FakeString arg1;
252 0 : if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
253 0 : return false;
254 : }
255 0 : binding_detail::FastErrorResult rv;
256 0 : auto result(StrongOrRawPtr<nsISupports>(self->GetCanvasContext(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv)));
257 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
258 0 : return false;
259 : }
260 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
261 0 : if (!result) {
262 0 : args.rval().setNull();
263 0 : return true;
264 : }
265 0 : if (!WrapObject(cx, result, args.rval())) {
266 0 : return false;
267 : }
268 0 : return true;
269 : }
270 :
271 : static const JSJitInfo getCanvasContext_methodinfo = {
272 : { (JSJitGetterOp)getCanvasContext },
273 : { prototypes::id::AnonymousContent },
274 : { PrototypeTraits<prototypes::id::AnonymousContent>::Depth },
275 : JSJitInfo::Method,
276 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
277 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
278 : false, /* isInfallible. False in setters. */
279 : false, /* isMovable. Not relevant for setters. */
280 : false, /* isEliminatable. Not relevant for setters. */
281 : false, /* isAlwaysInSlot. Only relevant for getters. */
282 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
283 : false, /* isTypedMethod. Only relevant for methods. */
284 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
285 : };
286 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
287 : static_assert(0 < 1, "There is no slot for us");
288 :
289 : static bool
290 0 : setAnimationForElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnonymousContent* self, const JSJitMethodCallArgs& args)
291 : {
292 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
293 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnonymousContent.setAnimationForElement");
294 : }
295 0 : binding_detail::FakeString arg0;
296 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
297 0 : return false;
298 : }
299 0 : JS::Rooted<JSObject*> arg1(cx);
300 0 : if (args[1].isObject()) {
301 0 : arg1 = &args[1].toObject();
302 0 : } else if (args[1].isNullOrUndefined()) {
303 0 : arg1 = nullptr;
304 : } else {
305 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of AnonymousContent.setAnimationForElement");
306 0 : return false;
307 : }
308 0 : UnrestrictedDoubleOrKeyframeAnimationOptions arg2;
309 0 : UnrestrictedDoubleOrKeyframeAnimationOptionsArgument arg2_holder(arg2);
310 0 : if (!(args.hasDefined(2))) {
311 0 : if (!arg2.RawSetAsKeyframeAnimationOptions().Init(cx, JS::NullHandleValue, "Member of UnrestrictedDoubleOrKeyframeAnimationOptions")) {
312 0 : return false;
313 : }
314 : } else {
315 : {
316 0 : bool done = false, failed = false, tryNext;
317 0 : if (!done) {
318 0 : done = (failed = !arg2_holder.TrySetToKeyframeAnimationOptions(cx, args[2], tryNext, false)) || !tryNext;
319 : }
320 0 : if (!done) {
321 : do {
322 0 : done = (failed = !arg2_holder.TrySetToUnrestrictedDouble(cx, args[2], tryNext)) || !tryNext;
323 0 : break;
324 : } while (0);
325 : }
326 0 : if (failed) {
327 0 : return false;
328 : }
329 0 : if (!done) {
330 0 : ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 3 of AnonymousContent.setAnimationForElement", "KeyframeAnimationOptions");
331 0 : return false;
332 : }
333 : }
334 : }
335 0 : binding_detail::FastErrorResult rv;
336 0 : auto result(StrongOrRawPtr<mozilla::dom::Animation>(self->SetAnimationForElement(cx, NonNullHelper(Constify(arg0)), arg1, Constify(arg2), rv)));
337 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
338 0 : return false;
339 : }
340 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
341 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
342 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
343 0 : return false;
344 : }
345 0 : return true;
346 : }
347 :
348 : static const JSJitInfo setAnimationForElement_methodinfo = {
349 : { (JSJitGetterOp)setAnimationForElement },
350 : { prototypes::id::AnonymousContent },
351 : { PrototypeTraits<prototypes::id::AnonymousContent>::Depth },
352 : JSJitInfo::Method,
353 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
354 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
355 : false, /* isInfallible. False in setters. */
356 : false, /* isMovable. Not relevant for setters. */
357 : false, /* isEliminatable. Not relevant for setters. */
358 : false, /* isAlwaysInSlot. Only relevant for getters. */
359 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
360 : false, /* isTypedMethod. Only relevant for methods. */
361 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
362 : };
363 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
364 : static_assert(0 < 1, "There is no slot for us");
365 :
366 : static bool
367 0 : setCutoutRectsForElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnonymousContent* self, const JSJitMethodCallArgs& args)
368 : {
369 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
370 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnonymousContent.setCutoutRectsForElement");
371 : }
372 0 : binding_detail::FakeString arg0;
373 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
374 0 : return false;
375 : }
376 0 : binding_detail::AutoSequence<OwningNonNull<mozilla::dom::DOMRect>> arg1;
377 0 : if (args[1].isObject()) {
378 0 : JS::ForOfIterator iter(cx);
379 0 : if (!iter.init(args[1], JS::ForOfIterator::AllowNonIterable)) {
380 0 : return false;
381 : }
382 0 : if (!iter.valueIsIterable()) {
383 0 : ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 2 of AnonymousContent.setCutoutRectsForElement");
384 0 : return false;
385 : }
386 0 : binding_detail::AutoSequence<OwningNonNull<mozilla::dom::DOMRect>> &arr = arg1;
387 0 : JS::Rooted<JS::Value> temp(cx);
388 : while (true) {
389 : bool done;
390 0 : if (!iter.next(&temp, &done)) {
391 0 : return false;
392 : }
393 0 : if (done) {
394 0 : break;
395 : }
396 0 : OwningNonNull<mozilla::dom::DOMRect>* slotPtr = arr.AppendElement(mozilla::fallible);
397 0 : if (!slotPtr) {
398 0 : JS_ReportOutOfMemory(cx);
399 0 : return false;
400 : }
401 0 : OwningNonNull<mozilla::dom::DOMRect>& slot = *slotPtr;
402 0 : if (temp.isObject()) {
403 : static_assert(IsRefcounted<mozilla::dom::DOMRect>::value, "We can only store refcounted classes.");{
404 0 : nsresult rv = UnwrapObject<prototypes::id::DOMRect, mozilla::dom::DOMRect>(&temp, slot);
405 0 : if (NS_FAILED(rv)) {
406 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Element of argument 2 of AnonymousContent.setCutoutRectsForElement", "DOMRect");
407 0 : return false;
408 : }
409 : }
410 : } else {
411 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Element of argument 2 of AnonymousContent.setCutoutRectsForElement");
412 0 : return false;
413 : }
414 0 : }
415 : } else {
416 0 : ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 2 of AnonymousContent.setCutoutRectsForElement");
417 0 : return false;
418 : }
419 0 : binding_detail::FastErrorResult rv;
420 0 : self->SetCutoutRectsForElement(NonNullHelper(Constify(arg0)), Constify(arg1), rv);
421 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
422 0 : return false;
423 : }
424 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
425 0 : args.rval().setUndefined();
426 0 : return true;
427 : }
428 :
429 : static const JSJitInfo setCutoutRectsForElement_methodinfo = {
430 : { (JSJitGetterOp)setCutoutRectsForElement },
431 : { prototypes::id::AnonymousContent },
432 : { PrototypeTraits<prototypes::id::AnonymousContent>::Depth },
433 : JSJitInfo::Method,
434 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
435 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
436 : false, /* isInfallible. False in setters. */
437 : false, /* isMovable. Not relevant for setters. */
438 : false, /* isEliminatable. Not relevant for setters. */
439 : false, /* isAlwaysInSlot. Only relevant for getters. */
440 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
441 : false, /* isTypedMethod. Only relevant for methods. */
442 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
443 : };
444 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
445 : static_assert(0 < 1, "There is no slot for us");
446 :
447 : static bool
448 0 : getComputedStylePropertyValue(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnonymousContent* self, const JSJitMethodCallArgs& args)
449 : {
450 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
451 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnonymousContent.getComputedStylePropertyValue");
452 : }
453 0 : binding_detail::FakeString arg0;
454 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
455 0 : return false;
456 : }
457 0 : binding_detail::FakeString arg1;
458 0 : if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
459 0 : return false;
460 : }
461 0 : binding_detail::FastErrorResult rv;
462 0 : DOMString result;
463 0 : self->GetComputedStylePropertyValue(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), result, rv);
464 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
465 0 : return false;
466 : }
467 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
468 0 : if (!xpc::StringToJsval(cx, result, args.rval())) {
469 0 : return false;
470 : }
471 0 : return true;
472 : }
473 :
474 : static const JSJitInfo getComputedStylePropertyValue_methodinfo = {
475 : { (JSJitGetterOp)getComputedStylePropertyValue },
476 : { prototypes::id::AnonymousContent },
477 : { PrototypeTraits<prototypes::id::AnonymousContent>::Depth },
478 : JSJitInfo::Method,
479 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
480 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
481 : false, /* isInfallible. False in setters. */
482 : false, /* isMovable. Not relevant for setters. */
483 : false, /* isEliminatable. Not relevant for setters. */
484 : false, /* isAlwaysInSlot. Only relevant for getters. */
485 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
486 : false, /* isTypedMethod. Only relevant for methods. */
487 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
488 : };
489 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
490 : static_assert(0 < 1, "There is no slot for us");
491 :
492 : static void
493 0 : _finalize(js::FreeOp* fop, JSObject* obj)
494 : {
495 0 : mozilla::dom::AnonymousContent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AnonymousContent>(obj);
496 0 : if (self) {
497 0 : AddForDeferredFinalization<mozilla::dom::AnonymousContent>(self);
498 : }
499 0 : }
500 :
501 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
502 : #if defined(__clang__)
503 : #pragma clang diagnostic push
504 : #pragma clang diagnostic ignored "-Wmissing-braces"
505 : #endif
506 : static const JSFunctionSpec sMethods_specs[] = {
507 : JS_FNSPEC("getTextContentForElement", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getTextContentForElement_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
508 : JS_FNSPEC("setTextContentForElement", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&setTextContentForElement_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
509 : JS_FNSPEC("getAttributeForElement", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getAttributeForElement_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
510 : JS_FNSPEC("setAttributeForElement", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&setAttributeForElement_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
511 : JS_FNSPEC("removeAttributeForElement", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&removeAttributeForElement_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
512 : JS_FNSPEC("getCanvasContext", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getCanvasContext_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
513 : JS_FS_END,
514 : JS_FNSPEC("setAnimationForElement", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&setAnimationForElement_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
515 : JS_FS_END,
516 : JS_FNSPEC("setCutoutRectsForElement", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&setCutoutRectsForElement_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
517 : JS_FNSPEC("getComputedStylePropertyValue", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getComputedStylePropertyValue_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
518 : JS_FS_END
519 : };
520 : #if defined(__clang__)
521 : #pragma clang diagnostic pop
522 : #endif
523 :
524 : static PrefableDisablers sMethods_disablers7 = {
525 : true, false, 0, &nsDocument::IsElementAnimateEnabled
526 : };
527 :
528 : // Can't be const because the pref-enabled boolean needs to be writable
529 : static Prefable<const JSFunctionSpec> sMethods[] = {
530 : { nullptr, &sMethods_specs[0] },
531 : { &sMethods_disablers7, &sMethods_specs[7] },
532 : { nullptr, &sMethods_specs[9] },
533 : { nullptr, nullptr }
534 : };
535 :
536 : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
537 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
538 : static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
539 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
540 :
541 :
542 : static uint16_t sNativeProperties_sortedPropertyIndices[9];
543 : static PropertyInfo sNativeProperties_propertyInfos[9];
544 :
545 : static const NativePropertiesN<1> sNativeProperties = {
546 : false, 0,
547 : false, 0,
548 : true, 0 /* sMethods */,
549 : false, 0,
550 : false, 0,
551 : false, 0,
552 : false, 0,
553 : -1,
554 : 9,
555 : sNativeProperties_sortedPropertyIndices,
556 : {
557 : { sMethods, &sNativeProperties_propertyInfos[0] }
558 : }
559 : };
560 : static_assert(9 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
561 : "We have a property info count that is oversized");
562 :
563 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
564 : {
565 : "Function",
566 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
567 : &sBoringInterfaceObjectClassClassOps,
568 : JS_NULL_CLASS_SPEC,
569 : JS_NULL_CLASS_EXT,
570 : &sInterfaceObjectClassObjectOps
571 : },
572 : eInterface,
573 : true,
574 : prototypes::id::AnonymousContent,
575 : PrototypeTraits<prototypes::id::AnonymousContent>::Depth,
576 : sNativePropertyHooks,
577 : "function AnonymousContent() {\n [native code]\n}",
578 : JS::GetRealmFunctionPrototype
579 : };
580 :
581 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
582 : {
583 : "AnonymousContentPrototype",
584 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
585 : JS_NULL_CLASS_OPS,
586 : JS_NULL_CLASS_SPEC,
587 : JS_NULL_CLASS_EXT,
588 : JS_NULL_OBJECT_OPS
589 : },
590 : eInterfacePrototype,
591 : false,
592 : prototypes::id::AnonymousContent,
593 : PrototypeTraits<prototypes::id::AnonymousContent>::Depth,
594 : sNativePropertyHooks,
595 : "[object AnonymousContentPrototype]",
596 : JS::GetRealmObjectPrototype
597 : };
598 :
599 : bool
600 0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
601 : {
602 0 : return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
603 : }
604 :
605 : JSObject*
606 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
607 : {
608 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
609 : }
610 :
611 : static const js::ClassOps sClassOps = {
612 : nullptr, /* addProperty */
613 : nullptr, /* delProperty */
614 : nullptr, /* getProperty */
615 : nullptr, /* setProperty */
616 : nullptr, /* enumerate */
617 : nullptr, /* newEnumerate */
618 : nullptr, /* resolve */
619 : nullptr, /* mayResolve */
620 : _finalize, /* finalize */
621 : nullptr, /* call */
622 : nullptr, /* hasInstance */
623 : nullptr, /* construct */
624 : nullptr, /* trace */
625 : };
626 :
627 : static const js::ClassExtension sClassExtension = {
628 : nullptr, /* weakmapKeyDelegateOp */
629 : nullptr /* objectMovedOp */
630 : };
631 :
632 : static const DOMJSClass sClass = {
633 : { "AnonymousContent",
634 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
635 : &sClassOps,
636 : JS_NULL_CLASS_SPEC,
637 : &sClassExtension,
638 : JS_NULL_OBJECT_OPS
639 : },
640 : { prototypes::id::AnonymousContent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
641 : IsBaseOf<nsISupports, mozilla::dom::AnonymousContent >::value,
642 : sNativePropertyHooks,
643 : FindAssociatedGlobalForNative<mozilla::dom::AnonymousContent>::Get,
644 : GetProtoObjectHandle,
645 : GetCCParticipant<mozilla::dom::AnonymousContent>::Get()
646 : };
647 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
648 : "Must have the right minimal number of reserved slots.");
649 : static_assert(1 >= 1,
650 : "Must have enough reserved slots.");
651 :
652 : const JSClass*
653 0 : GetJSClass()
654 : {
655 0 : return sClass.ToJSClass();
656 : }
657 :
658 : bool
659 0 : Wrap(JSContext* aCx, mozilla::dom::AnonymousContent* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
660 : {
661 : MOZ_ASSERT(static_cast<mozilla::dom::AnonymousContent*>(aObject) ==
662 : reinterpret_cast<mozilla::dom::AnonymousContent*>(aObject),
663 : "Multiple inheritance for mozilla::dom::AnonymousContent is broken.");
664 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
665 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
666 :
667 0 : JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
668 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
669 0 : if (!canonicalProto) {
670 0 : return false;
671 : }
672 0 : JS::Rooted<JSObject*> proto(aCx);
673 0 : if (aGivenProto) {
674 0 : proto = aGivenProto;
675 : // Unfortunately, while aGivenProto was in the compartment of aCx
676 : // coming in, we changed compartments to that of "parent" so may need
677 : // to wrap the proto here.
678 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
679 0 : if (!JS_WrapObject(aCx, &proto)) {
680 0 : return false;
681 : }
682 : }
683 : } else {
684 0 : proto = canonicalProto;
685 : }
686 :
687 0 : BindingJSObjectCreator<mozilla::dom::AnonymousContent> creator(aCx);
688 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
689 0 : if (!aReflector) {
690 0 : return false;
691 : }
692 :
693 :
694 :
695 0 : creator.InitializationSucceeded();
696 0 : return true;
697 : }
698 :
699 : const NativePropertyHooks sNativePropertyHooks[] = { {
700 : nullptr,
701 : nullptr,
702 : nullptr,
703 : { sNativeProperties.Upcast(), nullptr },
704 : prototypes::id::AnonymousContent,
705 : constructors::id::AnonymousContent,
706 : nullptr,
707 : &DefaultXrayExpandoObjectClass
708 : } };
709 :
710 : void
711 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
712 : {
713 0 : JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
714 0 : if (!parentProto) {
715 0 : return;
716 : }
717 :
718 0 : JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
719 0 : if (!constructorProto) {
720 0 : return;
721 : }
722 :
723 : static bool sIdsInited = false;
724 0 : if (!sIdsInited && NS_IsMainThread()) {
725 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
726 0 : return;
727 : }
728 0 : sIdsInited = true;
729 : }
730 :
731 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AnonymousContent);
732 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::AnonymousContent);
733 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
734 : &sPrototypeClass.mBase, protoCache,
735 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
736 : interfaceCache,
737 : sNativeProperties.Upcast(),
738 : nullptr,
739 : "AnonymousContent", aDefineOnGlobal,
740 : nullptr,
741 0 : false);
742 : }
743 :
744 : JS::Handle<JSObject*>
745 0 : GetProtoObjectHandle(JSContext* aCx)
746 : {
747 : /* Get the interface prototype object for this class. This will create the
748 : object as needed. */
749 0 : bool aDefineOnGlobal = true;
750 :
751 : /* Make sure our global is sane. Hopefully we can remove this sometime */
752 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
753 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
754 0 : return nullptr;
755 : }
756 :
757 : /* Check to see whether the interface objects are already installed */
758 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
759 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::AnonymousContent)) {
760 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
761 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
762 : }
763 :
764 : /*
765 : * The object might _still_ be null, but that's OK.
766 : *
767 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
768 : * traced by TraceProtoAndIfaceCache() and its contents are never
769 : * changed after they have been set.
770 : *
771 : * Calling address() avoids the read read barrier that does gray
772 : * unmarking, but it's not possible for the object to be gray here.
773 : */
774 :
775 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::AnonymousContent);
776 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
777 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
778 : }
779 :
780 : JS::Handle<JSObject*>
781 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
782 : {
783 : /* Get the interface object for this class. This will create the object as
784 : needed. */
785 :
786 : /* Make sure our global is sane. Hopefully we can remove this sometime */
787 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
788 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
789 0 : return nullptr;
790 : }
791 :
792 : /* Check to see whether the interface objects are already installed */
793 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
794 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::AnonymousContent)) {
795 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
796 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
797 : }
798 :
799 : /*
800 : * The object might _still_ be null, but that's OK.
801 : *
802 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
803 : * traced by TraceProtoAndIfaceCache() and its contents are never
804 : * changed after they have been set.
805 : *
806 : * Calling address() avoids the read read barrier that does gray
807 : * unmarking, but it's not possible for the object to be gray here.
808 : */
809 :
810 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::AnonymousContent);
811 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
812 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
813 : }
814 :
815 : JSObject*
816 0 : GetConstructorObject(JSContext* aCx)
817 : {
818 0 : return GetConstructorObjectHandle(aCx);
819 : }
820 :
821 : } // namespace AnonymousContentBinding
822 :
823 :
824 :
825 : } // namespace dom
826 : } // namespace mozilla
|