/work/obj-fuzz/dom/bindings/FontFaceSetBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM FontFaceSet.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AtomList.h" |
4 | | #include "EventHandlerBinding.h" |
5 | | #include "EventTargetBinding.h" |
6 | | #include "FontFaceSetBinding.h" |
7 | | #include "WrapperFactory.h" |
8 | | #include "jsapi.h" |
9 | | #include "mozilla/OwningNonNull.h" |
10 | | #include "mozilla/Preferences.h" |
11 | | #include "mozilla/dom/BindingUtils.h" |
12 | | #include "mozilla/dom/DOMJSClass.h" |
13 | | #include "mozilla/dom/FontFace.h" |
14 | | #include "mozilla/dom/FontFaceSet.h" |
15 | | #include "mozilla/dom/FontFaceSetIterator.h" |
16 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
17 | | #include "mozilla/dom/Nullable.h" |
18 | | #include "mozilla/dom/PrimitiveConversions.h" |
19 | | #include "mozilla/dom/Promise.h" |
20 | | #include "mozilla/dom/ScriptSettings.h" |
21 | | #include "mozilla/dom/ToJSValue.h" |
22 | | #include "mozilla/dom/XrayExpandoClass.h" |
23 | | |
24 | | namespace mozilla { |
25 | | namespace dom { |
26 | | |
27 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
28 | | using namespace mozilla::dom::binding_detail; |
29 | | |
30 | | |
31 | | namespace FontFaceSetLoadStatusValues { |
32 | | extern const EnumEntry strings[3] = { |
33 | | {"loading", 7}, |
34 | | {"loaded", 6}, |
35 | | { nullptr, 0 } |
36 | | }; |
37 | | } // namespace FontFaceSetLoadStatusValues |
38 | | |
39 | | bool |
40 | | ToJSValue(JSContext* aCx, FontFaceSetLoadStatus aArgument, JS::MutableHandle<JS::Value> aValue) |
41 | 0 | { |
42 | 0 | MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(FontFaceSetLoadStatusValues::strings)); |
43 | 0 | JSString* resultStr = |
44 | 0 | JS_NewStringCopyN(aCx, FontFaceSetLoadStatusValues::strings[uint32_t(aArgument)].value, |
45 | 0 | FontFaceSetLoadStatusValues::strings[uint32_t(aArgument)].length); |
46 | 0 | if (!resultStr) { |
47 | 0 | return false; |
48 | 0 | } |
49 | 0 | aValue.setString(resultStr); |
50 | 0 | return true; |
51 | 0 | } |
52 | | |
53 | | |
54 | | |
55 | | FontFaceSetIteratorResult::FontFaceSetIteratorResult() |
56 | | : mValue(JS::UndefinedValue()) |
57 | 0 | { |
58 | 0 | // Safe to pass a null context if we pass a null value |
59 | 0 | Init(nullptr, JS::NullHandleValue); |
60 | 0 | } |
61 | | |
62 | | |
63 | | bool |
64 | | FontFaceSetIteratorResult::InitIds(JSContext* cx, FontFaceSetIteratorResultAtoms* atomsCache) |
65 | 0 | { |
66 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
67 | 0 |
|
68 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
69 | 0 | // uninitialized. |
70 | 0 | if (!atomsCache->value_id.init(cx, "value") || |
71 | 0 | !atomsCache->done_id.init(cx, "done")) { |
72 | 0 | return false; |
73 | 0 | } |
74 | 0 | return true; |
75 | 0 | } |
76 | | |
77 | | bool |
78 | | FontFaceSetIteratorResult::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
79 | 0 | { |
80 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
81 | 0 | // Since in that case we will not have to do any property gets |
82 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
83 | 0 | // checkers by static analysis tools |
84 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
85 | 0 | FontFaceSetIteratorResultAtoms* atomsCache = nullptr; |
86 | 0 | if (cx) { |
87 | 0 | atomsCache = GetAtomCache<FontFaceSetIteratorResultAtoms>(cx); |
88 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
89 | 0 | return false; |
90 | 0 | } |
91 | 0 | } |
92 | 0 | |
93 | 0 | if (!IsConvertibleToDictionary(val)) { |
94 | 0 | return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription); |
95 | 0 | } |
96 | 0 | |
97 | 0 | bool isNull = val.isNullOrUndefined(); |
98 | 0 | // We only need these if !isNull, in which case we have |cx|. |
99 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
100 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
101 | 0 | if (!isNull) { |
102 | 0 | MOZ_ASSERT(cx); |
103 | 0 | object.emplace(cx, &val.toObject()); |
104 | 0 | temp.emplace(cx); |
105 | 0 | } |
106 | 0 | if (!isNull) { |
107 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->done_id, temp.ptr())) { |
108 | 0 | return false; |
109 | 0 | } |
110 | 0 | } |
111 | 0 | if (!isNull && !temp->isUndefined()) { |
112 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mDone)) { |
113 | 0 | return false; |
114 | 0 | } |
115 | 0 | mIsAnyMemberPresent = true; |
116 | 0 | } else if (cx) { |
117 | 0 | // Don't error out if we have no cx. In that |
118 | 0 | // situation the caller is default-constructing us and we'll |
119 | 0 | // just assume they know what they're doing. |
120 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER, |
121 | 0 | "'done' member of FontFaceSetIteratorResult"); |
122 | 0 | } |
123 | 0 | |
124 | 0 | if (!isNull) { |
125 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->value_id, temp.ptr())) { |
126 | 0 | return false; |
127 | 0 | } |
128 | 0 | } |
129 | 0 | if (!isNull && !temp->isUndefined()) { |
130 | 0 | #ifdef __clang__ |
131 | 0 | #pragma clang diagnostic push |
132 | 0 | #pragma clang diagnostic ignored "-Wunreachable-code" |
133 | 0 | #pragma clang diagnostic ignored "-Wunreachable-code-return" |
134 | 0 | #endif // __clang__ |
135 | 0 | if ((passedToJSImpl) && !CallerSubsumes(temp.ref())) { |
136 | 0 | ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "'value' member of FontFaceSetIteratorResult"); |
137 | 0 | return false; |
138 | 0 | } |
139 | 0 | #ifdef __clang__ |
140 | 0 | #pragma clang diagnostic pop |
141 | 0 | #endif // __clang__ |
142 | 0 | mValue = temp.ref(); |
143 | 0 | mIsAnyMemberPresent = true; |
144 | 0 | } else if (cx) { |
145 | 0 | // Don't error out if we have no cx. In that |
146 | 0 | // situation the caller is default-constructing us and we'll |
147 | 0 | // just assume they know what they're doing. |
148 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER, |
149 | 0 | "'value' member of FontFaceSetIteratorResult"); |
150 | 0 | } |
151 | 0 | return true; |
152 | 0 | } |
153 | | |
154 | | bool |
155 | | FontFaceSetIteratorResult::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
156 | 0 | { |
157 | 0 | FontFaceSetIteratorResultAtoms* atomsCache = GetAtomCache<FontFaceSetIteratorResultAtoms>(cx); |
158 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
159 | 0 | return false; |
160 | 0 | } |
161 | 0 | |
162 | 0 | JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx)); |
163 | 0 | if (!obj) { |
164 | 0 | return false; |
165 | 0 | } |
166 | 0 | rval.set(JS::ObjectValue(*obj)); |
167 | 0 |
|
168 | 0 | do { |
169 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
170 | 0 | JS::Rooted<JS::Value> temp(cx); |
171 | 0 | bool const & currentValue = mDone; |
172 | 0 | temp.setBoolean(currentValue); |
173 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->done_id, temp, JSPROP_ENUMERATE)) { |
174 | 0 | return false; |
175 | 0 | } |
176 | 0 | break; |
177 | 0 | } while(false); |
178 | 0 |
|
179 | 0 | do { |
180 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
181 | 0 | JS::Rooted<JS::Value> temp(cx); |
182 | 0 | JS::Value const & currentValue = mValue; |
183 | 0 | JS::ExposeValueToActiveJS(currentValue); |
184 | 0 | temp.set(currentValue); |
185 | 0 | if (!MaybeWrapValue(cx, &temp)) { |
186 | 0 | return false; |
187 | 0 | } |
188 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->value_id, temp, JSPROP_ENUMERATE)) { |
189 | 0 | return false; |
190 | 0 | } |
191 | 0 | break; |
192 | 0 | } while(false); |
193 | 0 |
|
194 | 0 | return true; |
195 | 0 | } |
196 | | |
197 | | void |
198 | | FontFaceSetIteratorResult::TraceDictionary(JSTracer* trc) |
199 | 0 | { |
200 | 0 | JS::UnsafeTraceRoot(trc, &mValue, "FontFaceSetIteratorResult.mValue"); |
201 | 0 | } |
202 | | |
203 | | namespace binding_detail { |
204 | | } // namespace binding_detail |
205 | | |
206 | | |
207 | | void |
208 | | FontFaceSetForEachCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, FontFace& value, FontFace& key, FontFaceSet& set, ErrorResult& aRv) |
209 | 0 | { |
210 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
211 | 0 | JS::AutoValueVector argv(cx); |
212 | 0 | if (!argv.resize(3)) { |
213 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
214 | 0 | return; |
215 | 0 | } |
216 | 0 | unsigned argc = 3; |
217 | 0 |
|
218 | 0 | do { |
219 | 0 | if (!GetOrCreateDOMReflector(cx, set, argv[2])) { |
220 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
221 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
222 | 0 | return; |
223 | 0 | } |
224 | 0 | break; |
225 | 0 | } while (false); |
226 | 0 |
|
227 | 0 | do { |
228 | 0 | if (!GetOrCreateDOMReflector(cx, key, argv[1])) { |
229 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
230 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
231 | 0 | return; |
232 | 0 | } |
233 | 0 | break; |
234 | 0 | } while (false); |
235 | 0 |
|
236 | 0 | do { |
237 | 0 | if (!GetOrCreateDOMReflector(cx, value, argv[0])) { |
238 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
239 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
240 | 0 | return; |
241 | 0 | } |
242 | 0 | break; |
243 | 0 | } while (false); |
244 | 0 |
|
245 | 0 | JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback)); |
246 | 0 | if (!JS::Call(cx, aThisVal, callable, |
247 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
248 | 0 | aRv.NoteJSContextException(cx); |
249 | 0 | return; |
250 | 0 | } |
251 | 0 | } |
252 | | |
253 | | |
254 | | |
255 | | namespace binding_detail { |
256 | | } // namespace binding_detail |
257 | | |
258 | | |
259 | | namespace FontFaceSet_Binding { |
260 | | |
261 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTarget_Binding::NativeType>::value, |
262 | | "Can't inherit from an interface with a different ownership model."); |
263 | | |
264 | | MOZ_CAN_RUN_SCRIPT static bool |
265 | | get_size(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, JSJitGetterCallArgs args) |
266 | 0 | { |
267 | 0 | AUTO_PROFILER_LABEL_FAST("get FontFaceSet.size", DOM, cx); |
268 | 0 |
|
269 | 0 | uint32_t result(self->Size()); |
270 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
271 | 0 | args.rval().setNumber(result); |
272 | 0 | return true; |
273 | 0 | } |
274 | | |
275 | | static const JSJitInfo size_getterinfo = { |
276 | | { (JSJitGetterOp)get_size }, |
277 | | { prototypes::id::FontFaceSet }, |
278 | | { PrototypeTraits<prototypes::id::FontFaceSet>::Depth }, |
279 | | JSJitInfo::Getter, |
280 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
281 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
282 | | true, /* isInfallible. False in setters. */ |
283 | | false, /* isMovable. Not relevant for setters. */ |
284 | | false, /* isEliminatable. Not relevant for setters. */ |
285 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
286 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
287 | | false, /* isTypedMethod. Only relevant for methods. */ |
288 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
289 | | }; |
290 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
291 | | static_assert(0 < 1, "There is no slot for us"); |
292 | | |
293 | | MOZ_CAN_RUN_SCRIPT static bool |
294 | | add(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, const JSJitMethodCallArgs& args) |
295 | 0 | { |
296 | 0 | AUTO_PROFILER_LABEL_FAST("FontFaceSet.add", DOM, cx); |
297 | 0 |
|
298 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
299 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "FontFaceSet.add"); |
300 | 0 | } |
301 | 0 | NonNull<mozilla::dom::FontFace> arg0; |
302 | 0 | if (args[0].isObject()) { |
303 | 0 | { |
304 | 0 | nsresult rv = UnwrapObject<prototypes::id::FontFace, mozilla::dom::FontFace>(args[0], arg0); |
305 | 0 | if (NS_FAILED(rv)) { |
306 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of FontFaceSet.add", "FontFace"); |
307 | 0 | return false; |
308 | 0 | } |
309 | 0 | } |
310 | 0 | } else { |
311 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of FontFaceSet.add"); |
312 | 0 | return false; |
313 | 0 | } |
314 | 0 | FastErrorResult rv; |
315 | 0 | self->Add(MOZ_KnownLive(NonNullHelper(arg0)), rv); |
316 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
317 | 0 | return false; |
318 | 0 | } |
319 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
320 | 0 | args.rval().setUndefined(); |
321 | 0 | return true; |
322 | 0 | } |
323 | | |
324 | | static const JSJitInfo add_methodinfo = { |
325 | | { (JSJitGetterOp)add }, |
326 | | { prototypes::id::FontFaceSet }, |
327 | | { PrototypeTraits<prototypes::id::FontFaceSet>::Depth }, |
328 | | JSJitInfo::Method, |
329 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
330 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
331 | | false, /* isInfallible. False in setters. */ |
332 | | false, /* isMovable. Not relevant for setters. */ |
333 | | false, /* isEliminatable. Not relevant for setters. */ |
334 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
335 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
336 | | false, /* isTypedMethod. Only relevant for methods. */ |
337 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
338 | | }; |
339 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
340 | | static_assert(0 < 1, "There is no slot for us"); |
341 | | |
342 | | MOZ_CAN_RUN_SCRIPT static bool |
343 | | has(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, const JSJitMethodCallArgs& args) |
344 | 0 | { |
345 | 0 | AUTO_PROFILER_LABEL_FAST("FontFaceSet.has", DOM, cx); |
346 | 0 |
|
347 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
348 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "FontFaceSet.has"); |
349 | 0 | } |
350 | 0 | NonNull<mozilla::dom::FontFace> arg0; |
351 | 0 | if (args[0].isObject()) { |
352 | 0 | { |
353 | 0 | nsresult rv = UnwrapObject<prototypes::id::FontFace, mozilla::dom::FontFace>(args[0], arg0); |
354 | 0 | if (NS_FAILED(rv)) { |
355 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of FontFaceSet.has", "FontFace"); |
356 | 0 | return false; |
357 | 0 | } |
358 | 0 | } |
359 | 0 | } else { |
360 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of FontFaceSet.has"); |
361 | 0 | return false; |
362 | 0 | } |
363 | 0 | bool result(self->Has(MOZ_KnownLive(NonNullHelper(arg0)))); |
364 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
365 | 0 | args.rval().setBoolean(result); |
366 | 0 | return true; |
367 | 0 | } |
368 | | |
369 | | static const JSJitInfo has_methodinfo = { |
370 | | { (JSJitGetterOp)has }, |
371 | | { prototypes::id::FontFaceSet }, |
372 | | { PrototypeTraits<prototypes::id::FontFaceSet>::Depth }, |
373 | | JSJitInfo::Method, |
374 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
375 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
376 | | false, /* isInfallible. False in setters. */ |
377 | | false, /* isMovable. Not relevant for setters. */ |
378 | | false, /* isEliminatable. Not relevant for setters. */ |
379 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
380 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
381 | | false, /* isTypedMethod. Only relevant for methods. */ |
382 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
383 | | }; |
384 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
385 | | static_assert(0 < 1, "There is no slot for us"); |
386 | | |
387 | | MOZ_CAN_RUN_SCRIPT static bool |
388 | | _delete_(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, const JSJitMethodCallArgs& args) |
389 | 0 | { |
390 | 0 | AUTO_PROFILER_LABEL_FAST("FontFaceSet.delete", DOM, cx); |
391 | 0 |
|
392 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
393 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "FontFaceSet.delete"); |
394 | 0 | } |
395 | 0 | NonNull<mozilla::dom::FontFace> arg0; |
396 | 0 | if (args[0].isObject()) { |
397 | 0 | { |
398 | 0 | nsresult rv = UnwrapObject<prototypes::id::FontFace, mozilla::dom::FontFace>(args[0], arg0); |
399 | 0 | if (NS_FAILED(rv)) { |
400 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of FontFaceSet.delete", "FontFace"); |
401 | 0 | return false; |
402 | 0 | } |
403 | 0 | } |
404 | 0 | } else { |
405 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of FontFaceSet.delete"); |
406 | 0 | return false; |
407 | 0 | } |
408 | 0 | bool result(self->Delete(MOZ_KnownLive(NonNullHelper(arg0)))); |
409 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
410 | 0 | args.rval().setBoolean(result); |
411 | 0 | return true; |
412 | 0 | } |
413 | | |
414 | | static const JSJitInfo delete_methodinfo = { |
415 | | { (JSJitGetterOp)_delete_ }, |
416 | | { prototypes::id::FontFaceSet }, |
417 | | { PrototypeTraits<prototypes::id::FontFaceSet>::Depth }, |
418 | | JSJitInfo::Method, |
419 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
420 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
421 | | false, /* isInfallible. False in setters. */ |
422 | | false, /* isMovable. Not relevant for setters. */ |
423 | | false, /* isEliminatable. Not relevant for setters. */ |
424 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
425 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
426 | | false, /* isTypedMethod. Only relevant for methods. */ |
427 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
428 | | }; |
429 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
430 | | static_assert(0 < 1, "There is no slot for us"); |
431 | | |
432 | | MOZ_CAN_RUN_SCRIPT static bool |
433 | | clear(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, const JSJitMethodCallArgs& args) |
434 | 0 | { |
435 | 0 | AUTO_PROFILER_LABEL_FAST("FontFaceSet.clear", DOM, cx); |
436 | 0 |
|
437 | 0 | self->Clear(); |
438 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
439 | 0 | args.rval().setUndefined(); |
440 | 0 | return true; |
441 | 0 | } |
442 | | |
443 | | static const JSJitInfo clear_methodinfo = { |
444 | | { (JSJitGetterOp)clear }, |
445 | | { prototypes::id::FontFaceSet }, |
446 | | { PrototypeTraits<prototypes::id::FontFaceSet>::Depth }, |
447 | | JSJitInfo::Method, |
448 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
449 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
450 | | true, /* isInfallible. False in setters. */ |
451 | | false, /* isMovable. Not relevant for setters. */ |
452 | | false, /* isEliminatable. Not relevant for setters. */ |
453 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
454 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
455 | | false, /* isTypedMethod. Only relevant for methods. */ |
456 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
457 | | }; |
458 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
459 | | static_assert(0 < 1, "There is no slot for us"); |
460 | | |
461 | | MOZ_CAN_RUN_SCRIPT static bool |
462 | | entries(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, const JSJitMethodCallArgs& args) |
463 | 0 | { |
464 | 0 | AUTO_PROFILER_LABEL_FAST("FontFaceSet.entries", DOM, cx); |
465 | 0 |
|
466 | 0 | auto result(StrongOrRawPtr<mozilla::dom::FontFaceSetIterator>(self->Entries())); |
467 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
468 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
469 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
470 | 0 | if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) { |
471 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
472 | 0 | return false; |
473 | 0 | } |
474 | 0 | return true; |
475 | 0 | } |
476 | | |
477 | | static const JSJitInfo entries_methodinfo = { |
478 | | { (JSJitGetterOp)entries }, |
479 | | { prototypes::id::FontFaceSet }, |
480 | | { PrototypeTraits<prototypes::id::FontFaceSet>::Depth }, |
481 | | JSJitInfo::Method, |
482 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
483 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
484 | | false, /* isInfallible. False in setters. */ |
485 | | false, /* isMovable. Not relevant for setters. */ |
486 | | false, /* isEliminatable. Not relevant for setters. */ |
487 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
488 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
489 | | false, /* isTypedMethod. Only relevant for methods. */ |
490 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
491 | | }; |
492 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
493 | | static_assert(0 < 1, "There is no slot for us"); |
494 | | |
495 | | MOZ_CAN_RUN_SCRIPT static bool |
496 | | values(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, const JSJitMethodCallArgs& args) |
497 | 0 | { |
498 | 0 | AUTO_PROFILER_LABEL_FAST("FontFaceSet.values", DOM, cx); |
499 | 0 |
|
500 | 0 | auto result(StrongOrRawPtr<mozilla::dom::FontFaceSetIterator>(self->Values())); |
501 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
502 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
503 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
504 | 0 | if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) { |
505 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
506 | 0 | return false; |
507 | 0 | } |
508 | 0 | return true; |
509 | 0 | } |
510 | | |
511 | | static const JSJitInfo values_methodinfo = { |
512 | | { (JSJitGetterOp)values }, |
513 | | { prototypes::id::FontFaceSet }, |
514 | | { PrototypeTraits<prototypes::id::FontFaceSet>::Depth }, |
515 | | JSJitInfo::Method, |
516 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
517 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
518 | | false, /* isInfallible. False in setters. */ |
519 | | false, /* isMovable. Not relevant for setters. */ |
520 | | false, /* isEliminatable. Not relevant for setters. */ |
521 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
522 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
523 | | false, /* isTypedMethod. Only relevant for methods. */ |
524 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
525 | | }; |
526 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
527 | | static_assert(0 < 1, "There is no slot for us"); |
528 | | |
529 | | MOZ_CAN_RUN_SCRIPT static bool |
530 | | forEach(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, const JSJitMethodCallArgs& args) |
531 | 0 | { |
532 | 0 | AUTO_PROFILER_LABEL_FAST("FontFaceSet.forEach", DOM, cx); |
533 | 0 |
|
534 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
535 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "FontFaceSet.forEach"); |
536 | 0 | } |
537 | 0 | RootedCallback<OwningNonNull<binding_detail::FastFontFaceSetForEachCallback>> arg0(cx); |
538 | 0 | if (args[0].isObject()) { |
539 | 0 | if (JS::IsCallable(&args[0].toObject())) { |
540 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
541 | 0 | arg0 = new binding_detail::FastFontFaceSetForEachCallback(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
542 | 0 | } |
543 | 0 | } else { |
544 | 0 | ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 1 of FontFaceSet.forEach"); |
545 | 0 | return false; |
546 | 0 | } |
547 | 0 | } else { |
548 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of FontFaceSet.forEach"); |
549 | 0 | return false; |
550 | 0 | } |
551 | 0 | JS::Rooted<JS::Value> arg1(cx); |
552 | 0 | if (args.hasDefined(1)) { |
553 | 0 | arg1 = args[1]; |
554 | 0 | } else { |
555 | 0 | arg1 = JS::UndefinedValue(); |
556 | 0 | } |
557 | 0 | FastErrorResult rv; |
558 | 0 | self->ForEach(cx, NonNullHelper(arg0), arg1, rv); |
559 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
560 | 0 | return false; |
561 | 0 | } |
562 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
563 | 0 | args.rval().setUndefined(); |
564 | 0 | return true; |
565 | 0 | } |
566 | | |
567 | | static const JSJitInfo forEach_methodinfo = { |
568 | | { (JSJitGetterOp)forEach }, |
569 | | { prototypes::id::FontFaceSet }, |
570 | | { PrototypeTraits<prototypes::id::FontFaceSet>::Depth }, |
571 | | JSJitInfo::Method, |
572 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
573 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
574 | | false, /* isInfallible. False in setters. */ |
575 | | false, /* isMovable. Not relevant for setters. */ |
576 | | false, /* isEliminatable. Not relevant for setters. */ |
577 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
578 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
579 | | false, /* isTypedMethod. Only relevant for methods. */ |
580 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
581 | | }; |
582 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
583 | | static_assert(0 < 1, "There is no slot for us"); |
584 | | |
585 | | MOZ_CAN_RUN_SCRIPT static bool |
586 | | get_onloading(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, JSJitGetterCallArgs args) |
587 | 0 | { |
588 | 0 | AUTO_PROFILER_LABEL_FAST("get FontFaceSet.onloading", DOM, cx); |
589 | 0 |
|
590 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnloading()); |
591 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
592 | 0 | if (result) { |
593 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
594 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
595 | 0 | return false; |
596 | 0 | } |
597 | 0 | return true; |
598 | 0 | } else { |
599 | 0 | args.rval().setNull(); |
600 | 0 | return true; |
601 | 0 | } |
602 | 0 | } |
603 | | |
604 | | MOZ_CAN_RUN_SCRIPT static bool |
605 | | set_onloading(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, JSJitSetterCallArgs args) |
606 | 0 | { |
607 | 0 | AUTO_PROFILER_LABEL_FAST("set FontFaceSet.onloading", DOM, cx); |
608 | 0 |
|
609 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
610 | 0 | if (args[0].isObject()) { |
611 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
612 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
613 | 0 | } |
614 | 0 | } else { |
615 | 0 | arg0 = nullptr; |
616 | 0 | } |
617 | 0 | self->SetOnloading(Constify(arg0)); |
618 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
619 | 0 |
|
620 | 0 | return true; |
621 | 0 | } |
622 | | |
623 | | static const JSJitInfo onloading_getterinfo = { |
624 | | { (JSJitGetterOp)get_onloading }, |
625 | | { prototypes::id::FontFaceSet }, |
626 | | { PrototypeTraits<prototypes::id::FontFaceSet>::Depth }, |
627 | | JSJitInfo::Getter, |
628 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
629 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
630 | | false, /* isInfallible. False in setters. */ |
631 | | false, /* isMovable. Not relevant for setters. */ |
632 | | false, /* isEliminatable. Not relevant for setters. */ |
633 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
634 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
635 | | false, /* isTypedMethod. Only relevant for methods. */ |
636 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
637 | | }; |
638 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
639 | | static_assert(0 < 1, "There is no slot for us"); |
640 | | static const JSJitInfo onloading_setterinfo = { |
641 | | { (JSJitGetterOp)set_onloading }, |
642 | | { prototypes::id::FontFaceSet }, |
643 | | { PrototypeTraits<prototypes::id::FontFaceSet>::Depth }, |
644 | | JSJitInfo::Setter, |
645 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
646 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
647 | | false, /* isInfallible. False in setters. */ |
648 | | false, /* isMovable. Not relevant for setters. */ |
649 | | false, /* isEliminatable. Not relevant for setters. */ |
650 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
651 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
652 | | false, /* isTypedMethod. Only relevant for methods. */ |
653 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
654 | | }; |
655 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
656 | | static_assert(0 < 1, "There is no slot for us"); |
657 | | |
658 | | MOZ_CAN_RUN_SCRIPT static bool |
659 | | get_onloadingdone(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, JSJitGetterCallArgs args) |
660 | 0 | { |
661 | 0 | AUTO_PROFILER_LABEL_FAST("get FontFaceSet.onloadingdone", DOM, cx); |
662 | 0 |
|
663 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnloadingdone()); |
664 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
665 | 0 | if (result) { |
666 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
667 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
668 | 0 | return false; |
669 | 0 | } |
670 | 0 | return true; |
671 | 0 | } else { |
672 | 0 | args.rval().setNull(); |
673 | 0 | return true; |
674 | 0 | } |
675 | 0 | } |
676 | | |
677 | | MOZ_CAN_RUN_SCRIPT static bool |
678 | | set_onloadingdone(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, JSJitSetterCallArgs args) |
679 | 0 | { |
680 | 0 | AUTO_PROFILER_LABEL_FAST("set FontFaceSet.onloadingdone", DOM, cx); |
681 | 0 |
|
682 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
683 | 0 | if (args[0].isObject()) { |
684 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
685 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
686 | 0 | } |
687 | 0 | } else { |
688 | 0 | arg0 = nullptr; |
689 | 0 | } |
690 | 0 | self->SetOnloadingdone(Constify(arg0)); |
691 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
692 | 0 |
|
693 | 0 | return true; |
694 | 0 | } |
695 | | |
696 | | static const JSJitInfo onloadingdone_getterinfo = { |
697 | | { (JSJitGetterOp)get_onloadingdone }, |
698 | | { prototypes::id::FontFaceSet }, |
699 | | { PrototypeTraits<prototypes::id::FontFaceSet>::Depth }, |
700 | | JSJitInfo::Getter, |
701 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
702 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
703 | | false, /* isInfallible. False in setters. */ |
704 | | false, /* isMovable. Not relevant for setters. */ |
705 | | false, /* isEliminatable. Not relevant for setters. */ |
706 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
707 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
708 | | false, /* isTypedMethod. Only relevant for methods. */ |
709 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
710 | | }; |
711 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
712 | | static_assert(0 < 1, "There is no slot for us"); |
713 | | static const JSJitInfo onloadingdone_setterinfo = { |
714 | | { (JSJitGetterOp)set_onloadingdone }, |
715 | | { prototypes::id::FontFaceSet }, |
716 | | { PrototypeTraits<prototypes::id::FontFaceSet>::Depth }, |
717 | | JSJitInfo::Setter, |
718 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
719 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
720 | | false, /* isInfallible. False in setters. */ |
721 | | false, /* isMovable. Not relevant for setters. */ |
722 | | false, /* isEliminatable. Not relevant for setters. */ |
723 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
724 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
725 | | false, /* isTypedMethod. Only relevant for methods. */ |
726 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
727 | | }; |
728 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
729 | | static_assert(0 < 1, "There is no slot for us"); |
730 | | |
731 | | MOZ_CAN_RUN_SCRIPT static bool |
732 | | get_onloadingerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, JSJitGetterCallArgs args) |
733 | 0 | { |
734 | 0 | AUTO_PROFILER_LABEL_FAST("get FontFaceSet.onloadingerror", DOM, cx); |
735 | 0 |
|
736 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnloadingerror()); |
737 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
738 | 0 | if (result) { |
739 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
740 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
741 | 0 | return false; |
742 | 0 | } |
743 | 0 | return true; |
744 | 0 | } else { |
745 | 0 | args.rval().setNull(); |
746 | 0 | return true; |
747 | 0 | } |
748 | 0 | } |
749 | | |
750 | | MOZ_CAN_RUN_SCRIPT static bool |
751 | | set_onloadingerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, JSJitSetterCallArgs args) |
752 | 0 | { |
753 | 0 | AUTO_PROFILER_LABEL_FAST("set FontFaceSet.onloadingerror", DOM, cx); |
754 | 0 |
|
755 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
756 | 0 | if (args[0].isObject()) { |
757 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
758 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
759 | 0 | } |
760 | 0 | } else { |
761 | 0 | arg0 = nullptr; |
762 | 0 | } |
763 | 0 | self->SetOnloadingerror(Constify(arg0)); |
764 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
765 | 0 |
|
766 | 0 | return true; |
767 | 0 | } |
768 | | |
769 | | static const JSJitInfo onloadingerror_getterinfo = { |
770 | | { (JSJitGetterOp)get_onloadingerror }, |
771 | | { prototypes::id::FontFaceSet }, |
772 | | { PrototypeTraits<prototypes::id::FontFaceSet>::Depth }, |
773 | | JSJitInfo::Getter, |
774 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
775 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
776 | | false, /* isInfallible. False in setters. */ |
777 | | false, /* isMovable. Not relevant for setters. */ |
778 | | false, /* isEliminatable. Not relevant for setters. */ |
779 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
780 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
781 | | false, /* isTypedMethod. Only relevant for methods. */ |
782 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
783 | | }; |
784 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
785 | | static_assert(0 < 1, "There is no slot for us"); |
786 | | static const JSJitInfo onloadingerror_setterinfo = { |
787 | | { (JSJitGetterOp)set_onloadingerror }, |
788 | | { prototypes::id::FontFaceSet }, |
789 | | { PrototypeTraits<prototypes::id::FontFaceSet>::Depth }, |
790 | | JSJitInfo::Setter, |
791 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
792 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
793 | | false, /* isInfallible. False in setters. */ |
794 | | false, /* isMovable. Not relevant for setters. */ |
795 | | false, /* isEliminatable. Not relevant for setters. */ |
796 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
797 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
798 | | false, /* isTypedMethod. Only relevant for methods. */ |
799 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
800 | | }; |
801 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
802 | | static_assert(0 < 1, "There is no slot for us"); |
803 | | |
804 | | MOZ_CAN_RUN_SCRIPT static bool |
805 | | load(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, const JSJitMethodCallArgs& args) |
806 | 0 | { |
807 | 0 | AUTO_PROFILER_LABEL_FAST("FontFaceSet.load", DOM, cx); |
808 | 0 |
|
809 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
810 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "FontFaceSet.load"); |
811 | 0 | } |
812 | 0 | binding_detail::FakeString arg0; |
813 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
814 | 0 | return false; |
815 | 0 | } |
816 | 0 | binding_detail::FakeString arg1; |
817 | 0 | if (args.hasDefined(1)) { |
818 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
819 | 0 | return false; |
820 | 0 | } |
821 | 0 | } else { |
822 | 0 | static const char16_t data[] = { ' ', 0 }; |
823 | 0 | arg1.Rebind(data, ArrayLength(data) - 1); |
824 | 0 | } |
825 | 0 | FastErrorResult rv; |
826 | 0 | auto result(StrongOrRawPtr<Promise>(self->Load(cx, NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv))); |
827 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
828 | 0 | return false; |
829 | 0 | } |
830 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
831 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
832 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
833 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
834 | 0 | return false; |
835 | 0 | } |
836 | 0 | return true; |
837 | 0 | } |
838 | | |
839 | | MOZ_CAN_RUN_SCRIPT static bool |
840 | | load_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, const JSJitMethodCallArgs& args) |
841 | 0 | { |
842 | 0 | bool ok = load(cx, obj, self, args); |
843 | 0 | if (ok) { |
844 | 0 | return true; |
845 | 0 | } |
846 | 0 | return ConvertExceptionToPromise(cx, args.rval()); |
847 | 0 | } |
848 | | |
849 | | static const JSJitInfo load_methodinfo = { |
850 | | { (JSJitGetterOp)load_promiseWrapper }, |
851 | | { prototypes::id::FontFaceSet }, |
852 | | { PrototypeTraits<prototypes::id::FontFaceSet>::Depth }, |
853 | | JSJitInfo::Method, |
854 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
855 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
856 | | false, /* isInfallible. False in setters. */ |
857 | | false, /* isMovable. Not relevant for setters. */ |
858 | | false, /* isEliminatable. Not relevant for setters. */ |
859 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
860 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
861 | | false, /* isTypedMethod. Only relevant for methods. */ |
862 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
863 | | }; |
864 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
865 | | static_assert(0 < 1, "There is no slot for us"); |
866 | | |
867 | | MOZ_CAN_RUN_SCRIPT static bool |
868 | | check(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, const JSJitMethodCallArgs& args) |
869 | 0 | { |
870 | 0 | AUTO_PROFILER_LABEL_FAST("FontFaceSet.check", DOM, cx); |
871 | 0 |
|
872 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
873 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "FontFaceSet.check"); |
874 | 0 | } |
875 | 0 | binding_detail::FakeString arg0; |
876 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
877 | 0 | return false; |
878 | 0 | } |
879 | 0 | binding_detail::FakeString arg1; |
880 | 0 | if (args.hasDefined(1)) { |
881 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
882 | 0 | return false; |
883 | 0 | } |
884 | 0 | } else { |
885 | 0 | static const char16_t data[] = { ' ', 0 }; |
886 | 0 | arg1.Rebind(data, ArrayLength(data) - 1); |
887 | 0 | } |
888 | 0 | FastErrorResult rv; |
889 | 0 | bool result(self->Check(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv)); |
890 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
891 | 0 | return false; |
892 | 0 | } |
893 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
894 | 0 | args.rval().setBoolean(result); |
895 | 0 | return true; |
896 | 0 | } |
897 | | |
898 | | static const JSJitInfo check_methodinfo = { |
899 | | { (JSJitGetterOp)check }, |
900 | | { prototypes::id::FontFaceSet }, |
901 | | { PrototypeTraits<prototypes::id::FontFaceSet>::Depth }, |
902 | | JSJitInfo::Method, |
903 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
904 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
905 | | false, /* isInfallible. False in setters. */ |
906 | | false, /* isMovable. Not relevant for setters. */ |
907 | | false, /* isEliminatable. Not relevant for setters. */ |
908 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
909 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
910 | | false, /* isTypedMethod. Only relevant for methods. */ |
911 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
912 | | }; |
913 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
914 | | static_assert(0 < 1, "There is no slot for us"); |
915 | | |
916 | | MOZ_CAN_RUN_SCRIPT static bool |
917 | | get_ready(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, JSJitGetterCallArgs args) |
918 | 0 | { |
919 | 0 | AUTO_PROFILER_LABEL_FAST("get FontFaceSet.ready", DOM, cx); |
920 | 0 |
|
921 | 0 | FastErrorResult rv; |
922 | 0 | auto result(StrongOrRawPtr<Promise>(self->GetReady(rv))); |
923 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
924 | 0 | return false; |
925 | 0 | } |
926 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
927 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
928 | 0 | return false; |
929 | 0 | } |
930 | 0 | return true; |
931 | 0 | } |
932 | | |
933 | | MOZ_CAN_RUN_SCRIPT static bool |
934 | | get_ready_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, JSJitGetterCallArgs args) |
935 | 0 | { |
936 | 0 | bool ok = get_ready(cx, obj, self, args); |
937 | 0 | if (ok) { |
938 | 0 | return true; |
939 | 0 | } |
940 | 0 | return ConvertExceptionToPromise(cx, args.rval()); |
941 | 0 | } |
942 | | |
943 | | static const JSJitInfo ready_getterinfo = { |
944 | | { (JSJitGetterOp)get_ready_promiseWrapper }, |
945 | | { prototypes::id::FontFaceSet }, |
946 | | { PrototypeTraits<prototypes::id::FontFaceSet>::Depth }, |
947 | | JSJitInfo::Getter, |
948 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
949 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
950 | | false, /* isInfallible. False in setters. */ |
951 | | false, /* isMovable. Not relevant for setters. */ |
952 | | false, /* isEliminatable. Not relevant for setters. */ |
953 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
954 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
955 | | false, /* isTypedMethod. Only relevant for methods. */ |
956 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
957 | | }; |
958 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
959 | | static_assert(0 < 1, "There is no slot for us"); |
960 | | |
961 | | MOZ_CAN_RUN_SCRIPT static bool |
962 | | get_status(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSet* self, JSJitGetterCallArgs args) |
963 | 0 | { |
964 | 0 | AUTO_PROFILER_LABEL_FAST("get FontFaceSet.status", DOM, cx); |
965 | 0 |
|
966 | 0 | FontFaceSetLoadStatus result(self->Status()); |
967 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
968 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
969 | 0 | return false; |
970 | 0 | } |
971 | 0 | return true; |
972 | 0 | } |
973 | | |
974 | | static const JSJitInfo status_getterinfo = { |
975 | | { (JSJitGetterOp)get_status }, |
976 | | { prototypes::id::FontFaceSet }, |
977 | | { PrototypeTraits<prototypes::id::FontFaceSet>::Depth }, |
978 | | JSJitInfo::Getter, |
979 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
980 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
981 | | false, /* isInfallible. False in setters. */ |
982 | | false, /* isMovable. Not relevant for setters. */ |
983 | | false, /* isEliminatable. Not relevant for setters. */ |
984 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
985 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
986 | | false, /* isTypedMethod. Only relevant for methods. */ |
987 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
988 | | }; |
989 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
990 | | static_assert(0 < 1, "There is no slot for us"); |
991 | | |
992 | | static bool |
993 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
994 | 0 | { |
995 | 0 | mozilla::dom::FontFaceSet* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FontFaceSet>(obj); |
996 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
997 | 0 | // obviously can't preserve if we're not initialized. |
998 | 0 | if (self && self->GetWrapperPreserveColor()) { |
999 | 0 | PreserveWrapper(self); |
1000 | 0 | } |
1001 | 0 | return true; |
1002 | 0 | } |
1003 | | |
1004 | | static void |
1005 | | _finalize(js::FreeOp* fop, JSObject* obj) |
1006 | 0 | { |
1007 | 0 | mozilla::dom::FontFaceSet* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FontFaceSet>(obj); |
1008 | 0 | if (self) { |
1009 | 0 | ClearWrapper(self, self, obj); |
1010 | 0 | AddForDeferredFinalization<mozilla::dom::FontFaceSet>(self); |
1011 | 0 | } |
1012 | 0 | } |
1013 | | |
1014 | | static size_t |
1015 | | _objectMoved(JSObject* obj, JSObject* old) |
1016 | 0 | { |
1017 | 0 | mozilla::dom::FontFaceSet* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FontFaceSet>(obj); |
1018 | 0 | if (self) { |
1019 | 0 | UpdateWrapper(self, self, obj, old); |
1020 | 0 | } |
1021 | 0 |
|
1022 | 0 | return 0; |
1023 | 0 | } |
1024 | | |
1025 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1026 | | #if defined(__clang__) |
1027 | | #pragma clang diagnostic push |
1028 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1029 | | #endif |
1030 | | static const JSFunctionSpec sMethods_specs[] = { |
1031 | | JS_FNSPEC("add", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&add_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1032 | | JS_FNSPEC("has", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&has_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1033 | | JS_FNSPEC("delete", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&delete_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1034 | | JS_FNSPEC("clear", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&clear_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1035 | | JS_FNSPEC("entries", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&entries_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1036 | | JS_FNSPEC("values", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&values_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1037 | | JS_FNSPEC("forEach", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&forEach_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1038 | | JS_FNSPEC("load", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&load_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1039 | | JS_FNSPEC("check", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&check_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1040 | | JS_FS_END |
1041 | | }; |
1042 | | #if defined(__clang__) |
1043 | | #pragma clang diagnostic pop |
1044 | | #endif |
1045 | | |
1046 | | |
1047 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
1048 | | { nullptr, &sMethods_specs[0] }, |
1049 | | { nullptr, nullptr } |
1050 | | }; |
1051 | | |
1052 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1053 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1054 | | static_assert(9 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1055 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1056 | | |
1057 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1058 | | #if defined(__clang__) |
1059 | | #pragma clang diagnostic push |
1060 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1061 | | #endif |
1062 | | static const JSPropertySpec sAttributes_specs[] = { |
1063 | | { "size", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &size_getterinfo, nullptr, nullptr }, |
1064 | | { "onloading", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onloading_getterinfo, GenericSetter<NormalThisPolicy>, &onloading_setterinfo }, |
1065 | | { "onloadingdone", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onloadingdone_getterinfo, GenericSetter<NormalThisPolicy>, &onloadingdone_setterinfo }, |
1066 | | { "onloadingerror", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onloadingerror_getterinfo, GenericSetter<NormalThisPolicy>, &onloadingerror_setterinfo }, |
1067 | | { "ready", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ConvertExceptionsToPromises>, &ready_getterinfo, nullptr, nullptr }, |
1068 | | { "status", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &status_getterinfo, nullptr, nullptr }, |
1069 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
1070 | | }; |
1071 | | #if defined(__clang__) |
1072 | | #pragma clang diagnostic pop |
1073 | | #endif |
1074 | | |
1075 | | |
1076 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
1077 | | { nullptr, &sAttributes_specs[0] }, |
1078 | | { nullptr, nullptr } |
1079 | | }; |
1080 | | |
1081 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1082 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1083 | | static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1084 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1085 | | |
1086 | | |
1087 | | static uint16_t sNativeProperties_sortedPropertyIndices[15]; |
1088 | | static PropertyInfo sNativeProperties_propertyInfos[15]; |
1089 | | |
1090 | | static const NativePropertiesN<2> sNativeProperties = { |
1091 | | false, 0, |
1092 | | false, 0, |
1093 | | true, 0 /* sMethods */, |
1094 | | true, 1 /* sAttributes */, |
1095 | | false, 0, |
1096 | | false, 0, |
1097 | | false, 0, |
1098 | | 5, |
1099 | | 15, |
1100 | | sNativeProperties_sortedPropertyIndices, |
1101 | | { |
1102 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
1103 | | { sAttributes, &sNativeProperties_propertyInfos[9] } |
1104 | | } |
1105 | | }; |
1106 | | static_assert(5 < 1ull << (CHAR_BIT * sizeof(sNativeProperties.iteratorAliasMethodIndex) - 1), |
1107 | | "We have an iterator alias index that is oversized"); |
1108 | | static_assert(15 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
1109 | | "We have a property info count that is oversized"); |
1110 | | |
1111 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
1112 | | { |
1113 | | "Function", |
1114 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
1115 | | &sBoringInterfaceObjectClassClassOps, |
1116 | | JS_NULL_CLASS_SPEC, |
1117 | | JS_NULL_CLASS_EXT, |
1118 | | &sInterfaceObjectClassObjectOps |
1119 | | }, |
1120 | | eInterface, |
1121 | | true, |
1122 | | prototypes::id::FontFaceSet, |
1123 | | PrototypeTraits<prototypes::id::FontFaceSet>::Depth, |
1124 | | sNativePropertyHooks, |
1125 | | "function FontFaceSet() {\n [native code]\n}", |
1126 | | EventTarget_Binding::GetConstructorObject |
1127 | | }; |
1128 | | |
1129 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
1130 | | { |
1131 | | "FontFaceSetPrototype", |
1132 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
1133 | | JS_NULL_CLASS_OPS, |
1134 | | JS_NULL_CLASS_SPEC, |
1135 | | JS_NULL_CLASS_EXT, |
1136 | | JS_NULL_OBJECT_OPS |
1137 | | }, |
1138 | | eInterfacePrototype, |
1139 | | false, |
1140 | | prototypes::id::FontFaceSet, |
1141 | | PrototypeTraits<prototypes::id::FontFaceSet>::Depth, |
1142 | | sNativePropertyHooks, |
1143 | | "[object FontFaceSetPrototype]", |
1144 | | EventTarget_Binding::GetProtoObject |
1145 | | }; |
1146 | | |
1147 | | bool |
1148 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
1149 | 0 | { |
1150 | 0 | static bool sPrefValue; |
1151 | 0 | static bool sPrefCacheSetUp = false; |
1152 | 0 | if (!sPrefCacheSetUp) { |
1153 | 0 | sPrefCacheSetUp = true; |
1154 | 0 | Preferences::AddBoolVarCache(&sPrefValue, "layout.css.font-loading-api.enabled"); |
1155 | 0 | } |
1156 | 0 |
|
1157 | 0 | return sPrefValue; |
1158 | 0 | } |
1159 | | |
1160 | | static const js::ClassOps sClassOps = { |
1161 | | _addProperty, /* addProperty */ |
1162 | | nullptr, /* delProperty */ |
1163 | | nullptr, /* enumerate */ |
1164 | | nullptr, /* newEnumerate */ |
1165 | | nullptr, /* resolve */ |
1166 | | nullptr, /* mayResolve */ |
1167 | | _finalize, /* finalize */ |
1168 | | nullptr, /* call */ |
1169 | | nullptr, /* hasInstance */ |
1170 | | nullptr, /* construct */ |
1171 | | nullptr, /* trace */ |
1172 | | }; |
1173 | | |
1174 | | static const js::ClassExtension sClassExtension = { |
1175 | | nullptr, /* weakmapKeyDelegateOp */ |
1176 | | _objectMoved /* objectMovedOp */ |
1177 | | }; |
1178 | | |
1179 | | static const DOMJSClass sClass = { |
1180 | | { "FontFaceSet", |
1181 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
1182 | | &sClassOps, |
1183 | | JS_NULL_CLASS_SPEC, |
1184 | | &sClassExtension, |
1185 | | JS_NULL_OBJECT_OPS |
1186 | | }, |
1187 | | { prototypes::id::EventTarget, prototypes::id::FontFaceSet, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
1188 | | IsBaseOf<nsISupports, mozilla::dom::FontFaceSet >::value, |
1189 | | sNativePropertyHooks, |
1190 | | FindAssociatedGlobalForNative<mozilla::dom::FontFaceSet>::Get, |
1191 | | GetProtoObjectHandle, |
1192 | | GetCCParticipant<mozilla::dom::FontFaceSet>::Get() |
1193 | | }; |
1194 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
1195 | | "Must have the right minimal number of reserved slots."); |
1196 | | static_assert(1 >= 1, |
1197 | | "Must have enough reserved slots."); |
1198 | | |
1199 | | const JSClass* |
1200 | | GetJSClass() |
1201 | 0 | { |
1202 | 0 | return sClass.ToJSClass(); |
1203 | 0 | } |
1204 | | |
1205 | | bool |
1206 | | Wrap(JSContext* aCx, mozilla::dom::FontFaceSet* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
1207 | 0 | { |
1208 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::FontFaceSet>::value, |
1209 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
1210 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::FontFaceSet*>(aObject) == |
1211 | 0 | reinterpret_cast<mozilla::dom::FontFaceSet*>(aObject), |
1212 | 0 | "Multiple inheritance for mozilla::dom::FontFaceSet is broken."); |
1213 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
1214 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
1215 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
1216 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
1217 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
1218 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
1219 | 0 | "You should probably not be using Wrap() directly; use " |
1220 | 0 | "GetOrCreateDOMReflector instead"); |
1221 | 0 |
|
1222 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
1223 | 0 | "nsISupports must be on our primary inheritance chain"); |
1224 | 0 |
|
1225 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
1226 | 0 | if (!global) { |
1227 | 0 | return false; |
1228 | 0 | } |
1229 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
1230 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
1231 | 0 |
|
1232 | 0 | // That might have ended up wrapping us already, due to the wonders |
1233 | 0 | // of XBL. Check for that, and bail out as needed. |
1234 | 0 | aReflector.set(aCache->GetWrapper()); |
1235 | 0 | if (aReflector) { |
1236 | | #ifdef DEBUG |
1237 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
1238 | | #endif // DEBUG |
1239 | | return true; |
1240 | 0 | } |
1241 | 0 |
|
1242 | 0 | JSAutoRealm ar(aCx, global); |
1243 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
1244 | 0 | if (!canonicalProto) { |
1245 | 0 | return false; |
1246 | 0 | } |
1247 | 0 | JS::Rooted<JSObject*> proto(aCx); |
1248 | 0 | if (aGivenProto) { |
1249 | 0 | proto = aGivenProto; |
1250 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
1251 | 0 | // coming in, we changed compartments to that of "parent" so may need |
1252 | 0 | // to wrap the proto here. |
1253 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
1254 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
1255 | 0 | return false; |
1256 | 0 | } |
1257 | 0 | } |
1258 | 0 | } else { |
1259 | 0 | proto = canonicalProto; |
1260 | 0 | } |
1261 | 0 |
|
1262 | 0 | BindingJSObjectCreator<mozilla::dom::FontFaceSet> creator(aCx); |
1263 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
1264 | 0 | if (!aReflector) { |
1265 | 0 | return false; |
1266 | 0 | } |
1267 | 0 | |
1268 | 0 | aCache->SetWrapper(aReflector); |
1269 | 0 | creator.InitializationSucceeded(); |
1270 | 0 |
|
1271 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
1272 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
1273 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
1274 | 0 | // otherwise we won't be able to properly recreate it later, since |
1275 | 0 | // we won't know what proto to use. Note that we don't check |
1276 | 0 | // aGivenProto here, since it's entirely possible (and even |
1277 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
1278 | 0 | // same as canonicalProto. |
1279 | 0 | if (proto != canonicalProto) { |
1280 | 0 | PreserveWrapper(aObject); |
1281 | 0 | } |
1282 | 0 |
|
1283 | 0 | return true; |
1284 | 0 | } |
1285 | | |
1286 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
1287 | | nullptr, |
1288 | | nullptr, |
1289 | | nullptr, |
1290 | | { sNativeProperties.Upcast(), nullptr }, |
1291 | | prototypes::id::FontFaceSet, |
1292 | | constructors::id::FontFaceSet, |
1293 | | EventTarget_Binding::sNativePropertyHooks, |
1294 | | &DefaultXrayExpandoObjectClass |
1295 | | } }; |
1296 | | |
1297 | | void |
1298 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
1299 | 0 | { |
1300 | 0 | JS::Handle<JSObject*> parentProto(EventTarget_Binding::GetProtoObjectHandle(aCx)); |
1301 | 0 | if (!parentProto) { |
1302 | 0 | return; |
1303 | 0 | } |
1304 | 0 | |
1305 | 0 | JS::Handle<JSObject*> constructorProto(EventTarget_Binding::GetConstructorObjectHandle(aCx)); |
1306 | 0 | if (!constructorProto) { |
1307 | 0 | return; |
1308 | 0 | } |
1309 | 0 | |
1310 | 0 | static bool sIdsInited = false; |
1311 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
1312 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
1313 | 0 | return; |
1314 | 0 | } |
1315 | 0 | sIdsInited = true; |
1316 | 0 | } |
1317 | 0 |
|
1318 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::FontFaceSet); |
1319 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::FontFaceSet); |
1320 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
1321 | 0 | &sPrototypeClass.mBase, protoCache, |
1322 | 0 | nullptr, |
1323 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
1324 | 0 | interfaceCache, |
1325 | 0 | sNativeProperties.Upcast(), |
1326 | 0 | nullptr, |
1327 | 0 | "FontFaceSet", aDefineOnGlobal, |
1328 | 0 | nullptr, |
1329 | 0 | false); |
1330 | 0 |
|
1331 | 0 | // Set up aliases on the interface prototype object we just created. |
1332 | 0 | JS::Handle<JSObject*> proto = GetProtoObjectHandle(aCx); |
1333 | 0 | if (!proto) { |
1334 | 0 | *protoCache = nullptr; |
1335 | 0 | if (interfaceCache) { |
1336 | 0 | *interfaceCache = nullptr; |
1337 | 0 | } |
1338 | 0 | return; |
1339 | 0 | } |
1340 | 0 |
|
1341 | 0 | JS::Rooted<JS::Value> aliasedVal(aCx); |
1342 | 0 |
|
1343 | 0 | if (!JS_GetProperty(aCx, proto, "values", &aliasedVal)) { |
1344 | 0 | *protoCache = nullptr; |
1345 | 0 | if (interfaceCache) { |
1346 | 0 | *interfaceCache = nullptr; |
1347 | 0 | } |
1348 | 0 | return; |
1349 | 0 | } |
1350 | 0 | JS::Rooted<jsid> iteratorId(aCx, SYMBOL_TO_JSID(JS::GetWellKnownSymbol(aCx, JS::SymbolCode::iterator))); |
1351 | 0 | if (!JS_DefinePropertyById(aCx, proto, iteratorId, aliasedVal, 0)) { |
1352 | 0 | *protoCache = nullptr; |
1353 | 0 | if (interfaceCache) { |
1354 | 0 | *interfaceCache = nullptr; |
1355 | 0 | } |
1356 | 0 | return; |
1357 | 0 | } |
1358 | 0 | if (!JS_DefineProperty(aCx, proto, "keys", aliasedVal, JSPROP_ENUMERATE)) { |
1359 | 0 | *protoCache = nullptr; |
1360 | 0 | if (interfaceCache) { |
1361 | 0 | *interfaceCache = nullptr; |
1362 | 0 | } |
1363 | 0 | return; |
1364 | 0 | } |
1365 | 0 | } |
1366 | | |
1367 | | JSObject* |
1368 | | GetConstructorObject(JSContext* aCx) |
1369 | 0 | { |
1370 | 0 | return GetConstructorObjectHandle(aCx); |
1371 | 0 | } |
1372 | | |
1373 | | } // namespace FontFaceSet_Binding |
1374 | | |
1375 | | |
1376 | | |
1377 | | namespace FontFaceSetIterator_Binding { |
1378 | | |
1379 | | MOZ_CAN_RUN_SCRIPT static bool |
1380 | | next(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFaceSetIterator* self, const JSJitMethodCallArgs& args) |
1381 | 0 | { |
1382 | 0 | AUTO_PROFILER_LABEL_FAST("FontFaceSetIterator.next", DOM, cx); |
1383 | 0 |
|
1384 | 0 | FastErrorResult rv; |
1385 | 0 | RootedDictionary<FontFaceSetIteratorResult> result(cx); |
1386 | 0 | self->Next(cx, result, rv); |
1387 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1388 | 0 | return false; |
1389 | 0 | } |
1390 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1391 | 0 | if (!result.ToObjectInternal(cx, args.rval())) { |
1392 | 0 | return false; |
1393 | 0 | } |
1394 | 0 | return true; |
1395 | 0 | } |
1396 | | |
1397 | | static const JSJitInfo next_methodinfo = { |
1398 | | { (JSJitGetterOp)next }, |
1399 | | { prototypes::id::FontFaceSetIterator }, |
1400 | | { PrototypeTraits<prototypes::id::FontFaceSetIterator>::Depth }, |
1401 | | JSJitInfo::Method, |
1402 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1403 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1404 | | false, /* isInfallible. False in setters. */ |
1405 | | false, /* isMovable. Not relevant for setters. */ |
1406 | | false, /* isEliminatable. Not relevant for setters. */ |
1407 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1408 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1409 | | false, /* isTypedMethod. Only relevant for methods. */ |
1410 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1411 | | }; |
1412 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1413 | | static_assert(0 < 1, "There is no slot for us"); |
1414 | | |
1415 | | static void |
1416 | | _finalize(js::FreeOp* fop, JSObject* obj) |
1417 | 0 | { |
1418 | 0 | mozilla::dom::FontFaceSetIterator* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FontFaceSetIterator>(obj); |
1419 | 0 | if (self) { |
1420 | 0 | AddForDeferredFinalization<mozilla::dom::FontFaceSetIterator>(self); |
1421 | 0 | } |
1422 | 0 | } |
1423 | | |
1424 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1425 | | #if defined(__clang__) |
1426 | | #pragma clang diagnostic push |
1427 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1428 | | #endif |
1429 | | static const JSFunctionSpec sMethods_specs[] = { |
1430 | | JS_FNSPEC("next", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&next_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1431 | | JS_FS_END |
1432 | | }; |
1433 | | #if defined(__clang__) |
1434 | | #pragma clang diagnostic pop |
1435 | | #endif |
1436 | | |
1437 | | |
1438 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
1439 | | { nullptr, &sMethods_specs[0] }, |
1440 | | { nullptr, nullptr } |
1441 | | }; |
1442 | | |
1443 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1444 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1445 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1446 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1447 | | |
1448 | | |
1449 | | static uint16_t sNativeProperties_sortedPropertyIndices[1]; |
1450 | | static PropertyInfo sNativeProperties_propertyInfos[1]; |
1451 | | |
1452 | | static const NativePropertiesN<1> sNativeProperties = { |
1453 | | false, 0, |
1454 | | false, 0, |
1455 | | true, 0 /* sMethods */, |
1456 | | false, 0, |
1457 | | false, 0, |
1458 | | false, 0, |
1459 | | false, 0, |
1460 | | -1, |
1461 | | 1, |
1462 | | sNativeProperties_sortedPropertyIndices, |
1463 | | { |
1464 | | { sMethods, &sNativeProperties_propertyInfos[0] } |
1465 | | } |
1466 | | }; |
1467 | | static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
1468 | | "We have a property info count that is oversized"); |
1469 | | |
1470 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
1471 | | { |
1472 | | "FontFaceSetIteratorPrototype", |
1473 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
1474 | | JS_NULL_CLASS_OPS, |
1475 | | JS_NULL_CLASS_SPEC, |
1476 | | JS_NULL_CLASS_EXT, |
1477 | | JS_NULL_OBJECT_OPS |
1478 | | }, |
1479 | | eInterfacePrototype, |
1480 | | false, |
1481 | | prototypes::id::FontFaceSetIterator, |
1482 | | PrototypeTraits<prototypes::id::FontFaceSetIterator>::Depth, |
1483 | | sNativePropertyHooks, |
1484 | | "[object FontFaceSetIteratorPrototype]", |
1485 | | JS::GetRealmObjectPrototype |
1486 | | }; |
1487 | | |
1488 | | static const js::ClassOps sClassOps = { |
1489 | | nullptr, /* addProperty */ |
1490 | | nullptr, /* delProperty */ |
1491 | | nullptr, /* enumerate */ |
1492 | | nullptr, /* newEnumerate */ |
1493 | | nullptr, /* resolve */ |
1494 | | nullptr, /* mayResolve */ |
1495 | | _finalize, /* finalize */ |
1496 | | nullptr, /* call */ |
1497 | | nullptr, /* hasInstance */ |
1498 | | nullptr, /* construct */ |
1499 | | nullptr, /* trace */ |
1500 | | }; |
1501 | | |
1502 | | static const js::ClassExtension sClassExtension = { |
1503 | | nullptr, /* weakmapKeyDelegateOp */ |
1504 | | nullptr /* objectMovedOp */ |
1505 | | }; |
1506 | | |
1507 | | static const DOMJSClass sClass = { |
1508 | | { "FontFaceSetIterator", |
1509 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
1510 | | &sClassOps, |
1511 | | JS_NULL_CLASS_SPEC, |
1512 | | &sClassExtension, |
1513 | | JS_NULL_OBJECT_OPS |
1514 | | }, |
1515 | | { prototypes::id::FontFaceSetIterator, 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 }, |
1516 | | IsBaseOf<nsISupports, mozilla::dom::FontFaceSetIterator >::value, |
1517 | | sNativePropertyHooks, |
1518 | | FindAssociatedGlobalForNative<mozilla::dom::FontFaceSetIterator>::Get, |
1519 | | GetProtoObjectHandle, |
1520 | | GetCCParticipant<mozilla::dom::FontFaceSetIterator>::Get() |
1521 | | }; |
1522 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
1523 | | "Must have the right minimal number of reserved slots."); |
1524 | | static_assert(1 >= 1, |
1525 | | "Must have enough reserved slots."); |
1526 | | |
1527 | | const JSClass* |
1528 | | GetJSClass() |
1529 | 0 | { |
1530 | 0 | return sClass.ToJSClass(); |
1531 | 0 | } |
1532 | | |
1533 | | bool |
1534 | | Wrap(JSContext* aCx, mozilla::dom::FontFaceSetIterator* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
1535 | 0 | { |
1536 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::FontFaceSetIterator*>(aObject) == |
1537 | 0 | reinterpret_cast<mozilla::dom::FontFaceSetIterator*>(aObject), |
1538 | 0 | "Multiple inheritance for mozilla::dom::FontFaceSetIterator is broken."); |
1539 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
1540 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
1541 | 0 |
|
1542 | 0 | JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx)); |
1543 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
1544 | 0 | if (!canonicalProto) { |
1545 | 0 | return false; |
1546 | 0 | } |
1547 | 0 | JS::Rooted<JSObject*> proto(aCx); |
1548 | 0 | if (aGivenProto) { |
1549 | 0 | proto = aGivenProto; |
1550 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
1551 | 0 | // coming in, we changed compartments to that of "parent" so may need |
1552 | 0 | // to wrap the proto here. |
1553 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
1554 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
1555 | 0 | return false; |
1556 | 0 | } |
1557 | 0 | } |
1558 | 0 | } else { |
1559 | 0 | proto = canonicalProto; |
1560 | 0 | } |
1561 | 0 |
|
1562 | 0 | BindingJSObjectCreator<mozilla::dom::FontFaceSetIterator> creator(aCx); |
1563 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
1564 | 0 | if (!aReflector) { |
1565 | 0 | return false; |
1566 | 0 | } |
1567 | 0 | |
1568 | 0 | |
1569 | 0 | |
1570 | 0 | creator.InitializationSucceeded(); |
1571 | 0 | return true; |
1572 | 0 | } |
1573 | | |
1574 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
1575 | | nullptr, |
1576 | | nullptr, |
1577 | | nullptr, |
1578 | | { sNativeProperties.Upcast(), nullptr }, |
1579 | | prototypes::id::FontFaceSetIterator, |
1580 | | constructors::id::_ID_Count, |
1581 | | nullptr, |
1582 | | &DefaultXrayExpandoObjectClass |
1583 | | } }; |
1584 | | |
1585 | | void |
1586 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
1587 | 0 | { |
1588 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
1589 | 0 | if (!parentProto) { |
1590 | 0 | return; |
1591 | 0 | } |
1592 | 0 | |
1593 | 0 | static bool sIdsInited = false; |
1594 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
1595 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
1596 | 0 | return; |
1597 | 0 | } |
1598 | 0 | sIdsInited = true; |
1599 | 0 | } |
1600 | 0 |
|
1601 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::FontFaceSetIterator); |
1602 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
1603 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
1604 | 0 | &sPrototypeClass.mBase, protoCache, |
1605 | 0 | nullptr, |
1606 | 0 | nullptr, nullptr, 0, nullptr, |
1607 | 0 | interfaceCache, |
1608 | 0 | sNativeProperties.Upcast(), |
1609 | 0 | nullptr, |
1610 | 0 | nullptr, aDefineOnGlobal, |
1611 | 0 | nullptr, |
1612 | 0 | false); |
1613 | 0 | } |
1614 | | |
1615 | | } // namespace FontFaceSetIterator_Binding |
1616 | | |
1617 | | |
1618 | | |
1619 | | } // namespace dom |
1620 | | } // namespace mozilla |