Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM FontFace.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "AtomList.h"
4 : #include "FontFaceBinding.h"
5 : #include "WrapperFactory.h"
6 : #include "jsapi.h"
7 : #include "mozilla/OwningNonNull.h"
8 : #include "mozilla/Preferences.h"
9 : #include "mozilla/dom/BindingUtils.h"
10 : #include "mozilla/dom/DOMJSClass.h"
11 : #include "mozilla/dom/FontFace.h"
12 : #include "mozilla/dom/NonRefcountedDOMObject.h"
13 : #include "mozilla/dom/Promise.h"
14 : #include "mozilla/dom/ScriptSettings.h"
15 : #include "mozilla/dom/SimpleGlobalObject.h"
16 : #include "mozilla/dom/ToJSValue.h"
17 : #include "mozilla/dom/UnionConversions.h"
18 : #include "mozilla/dom/XrayExpandoClass.h"
19 :
20 : namespace mozilla {
21 : namespace dom {
22 :
23 : namespace FontFaceLoadStatusValues {
24 : extern const EnumEntry strings[5] = {
25 : {"unloaded", 8},
26 : {"loading", 7},
27 : {"loaded", 6},
28 : {"error", 5},
29 : { nullptr, 0 }
30 : };
31 : } // namespace FontFaceLoadStatusValues
32 :
33 : bool
34 0 : ToJSValue(JSContext* aCx, FontFaceLoadStatus aArgument, JS::MutableHandle<JS::Value> aValue)
35 : {
36 0 : MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(FontFaceLoadStatusValues::strings));
37 : JSString* resultStr =
38 0 : JS_NewStringCopyN(aCx, FontFaceLoadStatusValues::strings[uint32_t(aArgument)].value,
39 0 : FontFaceLoadStatusValues::strings[uint32_t(aArgument)].length);
40 0 : if (!resultStr) {
41 0 : return false;
42 : }
43 0 : aValue.setString(resultStr);
44 0 : return true;
45 : }
46 :
47 :
48 :
49 0 : FontFaceDescriptors::FontFaceDescriptors()
50 : {
51 : // Safe to pass a null context if we pass a null value
52 0 : Init(nullptr, JS::NullHandleValue);
53 0 : }
54 :
55 :
56 :
57 : bool
58 0 : FontFaceDescriptors::InitIds(JSContext* cx, FontFaceDescriptorsAtoms* atomsCache)
59 : {
60 0 : MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
61 :
62 : // Initialize these in reverse order so that any failure leaves the first one
63 : // uninitialized.
64 0 : if (!atomsCache->weight_id.init(cx, "weight") ||
65 0 : !atomsCache->variant_id.init(cx, "variant") ||
66 0 : !atomsCache->unicodeRange_id.init(cx, "unicodeRange") ||
67 0 : !atomsCache->style_id.init(cx, "style") ||
68 0 : !atomsCache->stretch_id.init(cx, "stretch") ||
69 0 : !atomsCache->featureSettings_id.init(cx, "featureSettings") ||
70 0 : !atomsCache->display_id.init(cx, "display")) {
71 0 : return false;
72 : }
73 0 : return true;
74 : }
75 :
76 : bool
77 0 : FontFaceDescriptors::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
78 : {
79 : // Passing a null JSContext is OK only if we're initing from null,
80 : // Since in that case we will not have to do any property gets
81 : // Also evaluate isNullOrUndefined in order to avoid false-positive
82 : // checkers by static analysis tools
83 0 : MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
84 0 : FontFaceDescriptorsAtoms* atomsCache = nullptr;
85 0 : if (cx) {
86 0 : atomsCache = GetAtomCache<FontFaceDescriptorsAtoms>(cx);
87 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
88 0 : return false;
89 : }
90 : }
91 :
92 0 : if (!IsConvertibleToDictionary(val)) {
93 0 : return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
94 : }
95 :
96 0 : bool isNull = val.isNullOrUndefined();
97 : // We only need these if !isNull, in which case we have |cx|.
98 0 : Maybe<JS::Rooted<JSObject *> > object;
99 0 : Maybe<JS::Rooted<JS::Value> > temp;
100 0 : if (!isNull) {
101 0 : MOZ_ASSERT(cx);
102 0 : object.emplace(cx, &val.toObject());
103 0 : temp.emplace(cx);
104 : }
105 0 : if (!isNull) {
106 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->display_id, temp.ptr())) {
107 0 : return false;
108 : }
109 : }
110 0 : if (!isNull && !temp->isUndefined()) {
111 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mDisplay)) {
112 0 : return false;
113 : }
114 : } else {
115 : static const char16_t data[] = { 'a', 'u', 't', 'o', 0 };
116 0 : mDisplay.Rebind(data, ArrayLength(data) - 1);
117 : }
118 0 : mIsAnyMemberPresent = true;
119 :
120 0 : if (!isNull) {
121 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->featureSettings_id, temp.ptr())) {
122 0 : return false;
123 : }
124 : }
125 0 : if (!isNull && !temp->isUndefined()) {
126 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mFeatureSettings)) {
127 0 : return false;
128 : }
129 : } else {
130 : static const char16_t data[] = { 'n', 'o', 'r', 'm', 'a', 'l', 0 };
131 0 : mFeatureSettings.Rebind(data, ArrayLength(data) - 1);
132 : }
133 0 : mIsAnyMemberPresent = true;
134 :
135 0 : if (!isNull) {
136 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->stretch_id, temp.ptr())) {
137 0 : return false;
138 : }
139 : }
140 0 : if (!isNull && !temp->isUndefined()) {
141 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mStretch)) {
142 0 : return false;
143 : }
144 : } else {
145 : static const char16_t data[] = { 'n', 'o', 'r', 'm', 'a', 'l', 0 };
146 0 : mStretch.Rebind(data, ArrayLength(data) - 1);
147 : }
148 0 : mIsAnyMemberPresent = true;
149 :
150 0 : if (!isNull) {
151 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->style_id, temp.ptr())) {
152 0 : return false;
153 : }
154 : }
155 0 : if (!isNull && !temp->isUndefined()) {
156 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mStyle)) {
157 0 : return false;
158 : }
159 : } else {
160 : static const char16_t data[] = { 'n', 'o', 'r', 'm', 'a', 'l', 0 };
161 0 : mStyle.Rebind(data, ArrayLength(data) - 1);
162 : }
163 0 : mIsAnyMemberPresent = true;
164 :
165 0 : if (!isNull) {
166 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->unicodeRange_id, temp.ptr())) {
167 0 : return false;
168 : }
169 : }
170 0 : if (!isNull && !temp->isUndefined()) {
171 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mUnicodeRange)) {
172 0 : return false;
173 : }
174 : } else {
175 : static const char16_t data[] = { 'U', '+', '0', '-', '1', '0', 'F', 'F', 'F', 'F', 0 };
176 0 : mUnicodeRange.Rebind(data, ArrayLength(data) - 1);
177 : }
178 0 : mIsAnyMemberPresent = true;
179 :
180 0 : if (!isNull) {
181 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->variant_id, temp.ptr())) {
182 0 : return false;
183 : }
184 : }
185 0 : if (!isNull && !temp->isUndefined()) {
186 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mVariant)) {
187 0 : return false;
188 : }
189 : } else {
190 : static const char16_t data[] = { 'n', 'o', 'r', 'm', 'a', 'l', 0 };
191 0 : mVariant.Rebind(data, ArrayLength(data) - 1);
192 : }
193 0 : mIsAnyMemberPresent = true;
194 :
195 0 : if (!isNull) {
196 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->weight_id, temp.ptr())) {
197 0 : return false;
198 : }
199 : }
200 0 : if (!isNull && !temp->isUndefined()) {
201 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mWeight)) {
202 0 : return false;
203 : }
204 : } else {
205 : static const char16_t data[] = { 'n', 'o', 'r', 'm', 'a', 'l', 0 };
206 0 : mWeight.Rebind(data, ArrayLength(data) - 1);
207 : }
208 0 : mIsAnyMemberPresent = true;
209 0 : return true;
210 : }
211 :
212 : bool
213 0 : FontFaceDescriptors::Init(const nsAString& aJSON)
214 : {
215 0 : AutoJSAPI jsapi;
216 0 : JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
217 0 : if (!cleanGlobal) {
218 0 : return false;
219 : }
220 0 : if (!jsapi.Init(cleanGlobal)) {
221 0 : return false;
222 : }
223 0 : JSContext* cx = jsapi.cx();
224 0 : JS::Rooted<JS::Value> json(cx);
225 0 : bool ok = ParseJSON(cx, aJSON, &json);
226 0 : NS_ENSURE_TRUE(ok, false);
227 0 : return Init(cx, json);
228 : }
229 :
230 : bool
231 0 : FontFaceDescriptors::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
232 : {
233 0 : FontFaceDescriptorsAtoms* atomsCache = GetAtomCache<FontFaceDescriptorsAtoms>(cx);
234 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
235 0 : return false;
236 : }
237 :
238 0 : JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
239 0 : if (!obj) {
240 0 : return false;
241 : }
242 0 : rval.set(JS::ObjectValue(*obj));
243 :
244 : do {
245 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
246 0 : JS::Rooted<JS::Value> temp(cx);
247 0 : nsString const & currentValue = mDisplay;
248 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
249 0 : return false;
250 : }
251 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->display_id, temp, JSPROP_ENUMERATE)) {
252 0 : return false;
253 : }
254 0 : break;
255 : } while(0);
256 :
257 : do {
258 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
259 0 : JS::Rooted<JS::Value> temp(cx);
260 0 : nsString const & currentValue = mFeatureSettings;
261 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
262 0 : return false;
263 : }
264 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->featureSettings_id, temp, JSPROP_ENUMERATE)) {
265 0 : return false;
266 : }
267 0 : break;
268 : } while(0);
269 :
270 : do {
271 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
272 0 : JS::Rooted<JS::Value> temp(cx);
273 0 : nsString const & currentValue = mStretch;
274 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
275 0 : return false;
276 : }
277 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->stretch_id, temp, JSPROP_ENUMERATE)) {
278 0 : return false;
279 : }
280 0 : break;
281 : } while(0);
282 :
283 : do {
284 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
285 0 : JS::Rooted<JS::Value> temp(cx);
286 0 : nsString const & currentValue = mStyle;
287 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
288 0 : return false;
289 : }
290 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->style_id, temp, JSPROP_ENUMERATE)) {
291 0 : return false;
292 : }
293 0 : break;
294 : } while(0);
295 :
296 : do {
297 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
298 0 : JS::Rooted<JS::Value> temp(cx);
299 0 : nsString const & currentValue = mUnicodeRange;
300 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
301 0 : return false;
302 : }
303 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->unicodeRange_id, temp, JSPROP_ENUMERATE)) {
304 0 : return false;
305 : }
306 0 : break;
307 : } while(0);
308 :
309 : do {
310 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
311 0 : JS::Rooted<JS::Value> temp(cx);
312 0 : nsString const & currentValue = mVariant;
313 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
314 0 : return false;
315 : }
316 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->variant_id, temp, JSPROP_ENUMERATE)) {
317 0 : return false;
318 : }
319 0 : break;
320 : } while(0);
321 :
322 : do {
323 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
324 0 : JS::Rooted<JS::Value> temp(cx);
325 0 : nsString const & currentValue = mWeight;
326 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
327 0 : return false;
328 : }
329 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->weight_id, temp, JSPROP_ENUMERATE)) {
330 0 : return false;
331 : }
332 0 : break;
333 : } while(0);
334 :
335 0 : return true;
336 : }
337 :
338 : bool
339 0 : FontFaceDescriptors::ToJSON(nsAString& aJSON) const
340 : {
341 0 : AutoJSAPI jsapi;
342 0 : jsapi.Init();
343 0 : JSContext *cx = jsapi.cx();
344 : // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
345 : // because we'll only be creating objects, in ways that have no
346 : // side-effects, followed by a call to JS::ToJSONMaybeSafely,
347 : // which likewise guarantees no side-effects for the sorts of
348 : // things we will pass it.
349 0 : JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
350 0 : JS::Rooted<JS::Value> val(cx);
351 0 : if (!ToObjectInternal(cx, &val)) {
352 0 : return false;
353 : }
354 0 : JS::Rooted<JSObject*> obj(cx, &val.toObject());
355 0 : return StringifyToJSON(cx, obj, aJSON);
356 : }
357 :
358 : void
359 0 : FontFaceDescriptors::TraceDictionary(JSTracer* trc)
360 : {
361 0 : }
362 :
363 : FontFaceDescriptors&
364 0 : FontFaceDescriptors::operator=(const FontFaceDescriptors& aOther)
365 : {
366 0 : mDisplay = aOther.mDisplay;
367 0 : mFeatureSettings = aOther.mFeatureSettings;
368 0 : mStretch = aOther.mStretch;
369 0 : mStyle = aOther.mStyle;
370 0 : mUnicodeRange = aOther.mUnicodeRange;
371 0 : mVariant = aOther.mVariant;
372 0 : mWeight = aOther.mWeight;
373 0 : return *this;
374 : }
375 :
376 : namespace binding_detail {
377 : } // namespace binding_detail
378 :
379 :
380 : bool
381 0 : StringOrArrayBufferOrArrayBufferView::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
382 : {
383 0 : switch (mType) {
384 : case eUninitialized: {
385 0 : return false;
386 : break;
387 : }
388 : case eString: {
389 0 : if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) {
390 0 : return false;
391 : }
392 0 : return true;
393 : break;
394 : }
395 : case eArrayBuffer: {
396 0 : rval.setObject(*mValue.mArrayBuffer.Value().Obj());
397 0 : if (!MaybeWrapNonDOMObjectValue(cx, rval)) {
398 0 : return false;
399 : }
400 0 : return true;
401 : break;
402 : }
403 : case eArrayBufferView: {
404 0 : rval.setObject(*mValue.mArrayBufferView.Value().Obj());
405 0 : if (!MaybeWrapNonDOMObjectValue(cx, rval)) {
406 0 : return false;
407 : }
408 0 : return true;
409 : break;
410 : }
411 : default: {
412 0 : return false;
413 : break;
414 : }
415 : }
416 :
417 : return false;
418 : }
419 :
420 :
421 : nsString&
422 0 : OwningStringOrArrayBufferOrArrayBufferView::RawSetAsString()
423 : {
424 0 : if (mType == eString) {
425 0 : return mValue.mString.Value();
426 : }
427 0 : MOZ_ASSERT(mType == eUninitialized);
428 0 : mType = eString;
429 0 : return mValue.mString.SetValue();
430 : }
431 :
432 : nsString&
433 0 : OwningStringOrArrayBufferOrArrayBufferView::SetAsString()
434 : {
435 0 : if (mType == eString) {
436 0 : return mValue.mString.Value();
437 : }
438 0 : Uninit();
439 0 : mType = eString;
440 0 : return mValue.mString.SetValue();
441 : }
442 :
443 : bool
444 0 : OwningStringOrArrayBufferOrArrayBufferView::TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
445 : {
446 0 : tryNext = false;
447 : { // scope for memberSlot
448 0 : nsString& memberSlot = RawSetAsString();
449 0 : if (!ConvertJSValueToString(cx, value, eStringify, eStringify, memberSlot)) {
450 0 : return false;
451 : }
452 : }
453 0 : return true;
454 : }
455 :
456 :
457 : void
458 0 : OwningStringOrArrayBufferOrArrayBufferView::DestroyString()
459 : {
460 0 : MOZ_ASSERT(IsString(), "Wrong type!");
461 0 : mValue.mString.Destroy();
462 0 : mType = eUninitialized;
463 0 : }
464 :
465 :
466 :
467 :
468 : ArrayBuffer&
469 0 : OwningStringOrArrayBufferOrArrayBufferView::RawSetAsArrayBuffer()
470 : {
471 0 : if (mType == eArrayBuffer) {
472 0 : return mValue.mArrayBuffer.Value();
473 : }
474 0 : MOZ_ASSERT(mType == eUninitialized);
475 0 : mType = eArrayBuffer;
476 0 : return mValue.mArrayBuffer.SetValue();
477 : }
478 :
479 : ArrayBuffer&
480 0 : OwningStringOrArrayBufferOrArrayBufferView::SetAsArrayBuffer()
481 : {
482 0 : if (mType == eArrayBuffer) {
483 0 : return mValue.mArrayBuffer.Value();
484 : }
485 0 : Uninit();
486 0 : mType = eArrayBuffer;
487 0 : return mValue.mArrayBuffer.SetValue();
488 : }
489 :
490 : bool
491 0 : OwningStringOrArrayBufferOrArrayBufferView::TrySetToArrayBuffer(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
492 : {
493 0 : tryNext = false;
494 : { // scope for memberSlot
495 0 : ArrayBuffer& memberSlot = RawSetAsArrayBuffer();
496 0 : if (!memberSlot.Init(&value.toObject())) {
497 0 : DestroyArrayBuffer();
498 0 : tryNext = true;
499 0 : return true;
500 : }
501 : }
502 0 : return true;
503 : }
504 :
505 : void
506 0 : OwningStringOrArrayBufferOrArrayBufferView::DestroyArrayBuffer()
507 : {
508 0 : MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
509 0 : mValue.mArrayBuffer.Destroy();
510 0 : mType = eUninitialized;
511 0 : }
512 :
513 :
514 :
515 :
516 : ArrayBufferView&
517 0 : OwningStringOrArrayBufferOrArrayBufferView::RawSetAsArrayBufferView()
518 : {
519 0 : if (mType == eArrayBufferView) {
520 0 : return mValue.mArrayBufferView.Value();
521 : }
522 0 : MOZ_ASSERT(mType == eUninitialized);
523 0 : mType = eArrayBufferView;
524 0 : return mValue.mArrayBufferView.SetValue();
525 : }
526 :
527 : ArrayBufferView&
528 0 : OwningStringOrArrayBufferOrArrayBufferView::SetAsArrayBufferView()
529 : {
530 0 : if (mType == eArrayBufferView) {
531 0 : return mValue.mArrayBufferView.Value();
532 : }
533 0 : Uninit();
534 0 : mType = eArrayBufferView;
535 0 : return mValue.mArrayBufferView.SetValue();
536 : }
537 :
538 : bool
539 0 : OwningStringOrArrayBufferOrArrayBufferView::TrySetToArrayBufferView(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
540 : {
541 0 : tryNext = false;
542 : { // scope for memberSlot
543 0 : ArrayBufferView& memberSlot = RawSetAsArrayBufferView();
544 0 : if (!memberSlot.Init(&value.toObject())) {
545 0 : DestroyArrayBufferView();
546 0 : tryNext = true;
547 0 : return true;
548 : }
549 : }
550 0 : return true;
551 : }
552 :
553 : void
554 0 : OwningStringOrArrayBufferOrArrayBufferView::DestroyArrayBufferView()
555 : {
556 0 : MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
557 0 : mValue.mArrayBufferView.Destroy();
558 0 : mType = eUninitialized;
559 0 : }
560 :
561 :
562 :
563 :
564 : void
565 0 : OwningStringOrArrayBufferOrArrayBufferView::Uninit()
566 : {
567 0 : switch (mType) {
568 : case eUninitialized: {
569 0 : break;
570 : }
571 : case eString: {
572 0 : DestroyString();
573 0 : break;
574 : }
575 : case eArrayBuffer: {
576 0 : DestroyArrayBuffer();
577 0 : break;
578 : }
579 : case eArrayBufferView: {
580 0 : DestroyArrayBufferView();
581 0 : break;
582 : }
583 : }
584 0 : }
585 :
586 : bool
587 0 : OwningStringOrArrayBufferOrArrayBufferView::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
588 : {
589 0 : switch (mType) {
590 : case eUninitialized: {
591 0 : return false;
592 : break;
593 : }
594 : case eString: {
595 0 : if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) {
596 0 : return false;
597 : }
598 0 : return true;
599 : break;
600 : }
601 : case eArrayBuffer: {
602 0 : rval.setObject(*mValue.mArrayBuffer.Value().Obj());
603 0 : if (!MaybeWrapNonDOMObjectValue(cx, rval)) {
604 0 : return false;
605 : }
606 0 : return true;
607 : break;
608 : }
609 : case eArrayBufferView: {
610 0 : rval.setObject(*mValue.mArrayBufferView.Value().Obj());
611 0 : if (!MaybeWrapNonDOMObjectValue(cx, rval)) {
612 0 : return false;
613 : }
614 0 : return true;
615 : break;
616 : }
617 : default: {
618 0 : return false;
619 : break;
620 : }
621 : }
622 :
623 : return false;
624 : }
625 :
626 : void
627 0 : OwningStringOrArrayBufferOrArrayBufferView::TraceUnion(JSTracer* trc)
628 : {
629 0 : switch (mType) {
630 : case eArrayBuffer: {
631 0 : mValue.mArrayBuffer.Value().TraceSelf(trc);
632 0 : break;
633 : }
634 : case eArrayBufferView: {
635 0 : mValue.mArrayBufferView.Value().TraceSelf(trc);
636 0 : break;
637 : }
638 : default: {
639 0 : break;
640 : }
641 : }
642 0 : }
643 :
644 :
645 : namespace FontFaceBinding {
646 :
647 : static bool
648 0 : get_family(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
649 : {
650 0 : DOMString result;
651 0 : self->GetFamily(result);
652 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
653 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
654 0 : return false;
655 : }
656 0 : return true;
657 : }
658 :
659 : static bool
660 0 : set_family(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitSetterCallArgs args)
661 : {
662 0 : binding_detail::FakeString arg0;
663 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
664 0 : return false;
665 : }
666 0 : binding_detail::FastErrorResult rv;
667 0 : self->SetFamily(NonNullHelper(Constify(arg0)), rv);
668 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
669 0 : return false;
670 : }
671 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
672 :
673 0 : return true;
674 : }
675 :
676 : static const JSJitInfo family_getterinfo = {
677 : { (JSJitGetterOp)get_family },
678 : { prototypes::id::FontFace },
679 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
680 : JSJitInfo::Getter,
681 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
682 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
683 : false, /* isInfallible. False in setters. */
684 : false, /* isMovable. Not relevant for setters. */
685 : false, /* isEliminatable. Not relevant for setters. */
686 : false, /* isAlwaysInSlot. Only relevant for getters. */
687 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
688 : false, /* isTypedMethod. Only relevant for methods. */
689 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
690 : };
691 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
692 : static_assert(0 < 1, "There is no slot for us");
693 : static const JSJitInfo family_setterinfo = {
694 : { (JSJitGetterOp)set_family },
695 : { prototypes::id::FontFace },
696 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
697 : JSJitInfo::Setter,
698 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
699 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
700 : false, /* isInfallible. False in setters. */
701 : false, /* isMovable. Not relevant for setters. */
702 : false, /* isEliminatable. Not relevant for setters. */
703 : false, /* isAlwaysInSlot. Only relevant for getters. */
704 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
705 : false, /* isTypedMethod. Only relevant for methods. */
706 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
707 : };
708 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
709 : static_assert(0 < 1, "There is no slot for us");
710 :
711 : static bool
712 0 : get_style(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
713 : {
714 0 : DOMString result;
715 0 : self->GetStyle(result);
716 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
717 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
718 0 : return false;
719 : }
720 0 : return true;
721 : }
722 :
723 : static bool
724 0 : set_style(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitSetterCallArgs args)
725 : {
726 0 : binding_detail::FakeString arg0;
727 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
728 0 : return false;
729 : }
730 0 : binding_detail::FastErrorResult rv;
731 0 : self->SetStyle(NonNullHelper(Constify(arg0)), rv);
732 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
733 0 : return false;
734 : }
735 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
736 :
737 0 : return true;
738 : }
739 :
740 : static const JSJitInfo style_getterinfo = {
741 : { (JSJitGetterOp)get_style },
742 : { prototypes::id::FontFace },
743 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
744 : JSJitInfo::Getter,
745 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
746 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
747 : false, /* isInfallible. False in setters. */
748 : false, /* isMovable. Not relevant for setters. */
749 : false, /* isEliminatable. Not relevant for setters. */
750 : false, /* isAlwaysInSlot. Only relevant for getters. */
751 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
752 : false, /* isTypedMethod. Only relevant for methods. */
753 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
754 : };
755 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
756 : static_assert(0 < 1, "There is no slot for us");
757 : static const JSJitInfo style_setterinfo = {
758 : { (JSJitGetterOp)set_style },
759 : { prototypes::id::FontFace },
760 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
761 : JSJitInfo::Setter,
762 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
763 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
764 : false, /* isInfallible. False in setters. */
765 : false, /* isMovable. Not relevant for setters. */
766 : false, /* isEliminatable. Not relevant for setters. */
767 : false, /* isAlwaysInSlot. Only relevant for getters. */
768 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
769 : false, /* isTypedMethod. Only relevant for methods. */
770 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
771 : };
772 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
773 : static_assert(0 < 1, "There is no slot for us");
774 :
775 : static bool
776 0 : get_weight(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
777 : {
778 0 : DOMString result;
779 0 : self->GetWeight(result);
780 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
781 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
782 0 : return false;
783 : }
784 0 : return true;
785 : }
786 :
787 : static bool
788 0 : set_weight(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitSetterCallArgs args)
789 : {
790 0 : binding_detail::FakeString arg0;
791 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
792 0 : return false;
793 : }
794 0 : binding_detail::FastErrorResult rv;
795 0 : self->SetWeight(NonNullHelper(Constify(arg0)), rv);
796 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
797 0 : return false;
798 : }
799 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
800 :
801 0 : return true;
802 : }
803 :
804 : static const JSJitInfo weight_getterinfo = {
805 : { (JSJitGetterOp)get_weight },
806 : { prototypes::id::FontFace },
807 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
808 : JSJitInfo::Getter,
809 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
810 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
811 : false, /* isInfallible. False in setters. */
812 : false, /* isMovable. Not relevant for setters. */
813 : false, /* isEliminatable. Not relevant for setters. */
814 : false, /* isAlwaysInSlot. Only relevant for getters. */
815 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
816 : false, /* isTypedMethod. Only relevant for methods. */
817 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
818 : };
819 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
820 : static_assert(0 < 1, "There is no slot for us");
821 : static const JSJitInfo weight_setterinfo = {
822 : { (JSJitGetterOp)set_weight },
823 : { prototypes::id::FontFace },
824 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
825 : JSJitInfo::Setter,
826 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
827 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
828 : false, /* isInfallible. False in setters. */
829 : false, /* isMovable. Not relevant for setters. */
830 : false, /* isEliminatable. Not relevant for setters. */
831 : false, /* isAlwaysInSlot. Only relevant for getters. */
832 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
833 : false, /* isTypedMethod. Only relevant for methods. */
834 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
835 : };
836 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
837 : static_assert(0 < 1, "There is no slot for us");
838 :
839 : static bool
840 0 : get_stretch(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
841 : {
842 0 : DOMString result;
843 0 : self->GetStretch(result);
844 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
845 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
846 0 : return false;
847 : }
848 0 : return true;
849 : }
850 :
851 : static bool
852 0 : set_stretch(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitSetterCallArgs args)
853 : {
854 0 : binding_detail::FakeString arg0;
855 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
856 0 : return false;
857 : }
858 0 : binding_detail::FastErrorResult rv;
859 0 : self->SetStretch(NonNullHelper(Constify(arg0)), rv);
860 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
861 0 : return false;
862 : }
863 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
864 :
865 0 : return true;
866 : }
867 :
868 : static const JSJitInfo stretch_getterinfo = {
869 : { (JSJitGetterOp)get_stretch },
870 : { prototypes::id::FontFace },
871 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
872 : JSJitInfo::Getter,
873 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
874 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
875 : false, /* isInfallible. False in setters. */
876 : false, /* isMovable. Not relevant for setters. */
877 : false, /* isEliminatable. Not relevant for setters. */
878 : false, /* isAlwaysInSlot. Only relevant for getters. */
879 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
880 : false, /* isTypedMethod. Only relevant for methods. */
881 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
882 : };
883 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
884 : static_assert(0 < 1, "There is no slot for us");
885 : static const JSJitInfo stretch_setterinfo = {
886 : { (JSJitGetterOp)set_stretch },
887 : { prototypes::id::FontFace },
888 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
889 : JSJitInfo::Setter,
890 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
891 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
892 : false, /* isInfallible. False in setters. */
893 : false, /* isMovable. Not relevant for setters. */
894 : false, /* isEliminatable. Not relevant for setters. */
895 : false, /* isAlwaysInSlot. Only relevant for getters. */
896 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
897 : false, /* isTypedMethod. Only relevant for methods. */
898 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
899 : };
900 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
901 : static_assert(0 < 1, "There is no slot for us");
902 :
903 : static bool
904 0 : get_unicodeRange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
905 : {
906 0 : DOMString result;
907 0 : self->GetUnicodeRange(result);
908 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
909 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
910 0 : return false;
911 : }
912 0 : return true;
913 : }
914 :
915 : static bool
916 0 : set_unicodeRange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitSetterCallArgs args)
917 : {
918 0 : binding_detail::FakeString arg0;
919 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
920 0 : return false;
921 : }
922 0 : binding_detail::FastErrorResult rv;
923 0 : self->SetUnicodeRange(NonNullHelper(Constify(arg0)), rv);
924 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
925 0 : return false;
926 : }
927 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
928 :
929 0 : return true;
930 : }
931 :
932 : static const JSJitInfo unicodeRange_getterinfo = {
933 : { (JSJitGetterOp)get_unicodeRange },
934 : { prototypes::id::FontFace },
935 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
936 : JSJitInfo::Getter,
937 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
938 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
939 : false, /* isInfallible. False in setters. */
940 : false, /* isMovable. Not relevant for setters. */
941 : false, /* isEliminatable. Not relevant for setters. */
942 : false, /* isAlwaysInSlot. Only relevant for getters. */
943 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
944 : false, /* isTypedMethod. Only relevant for methods. */
945 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
946 : };
947 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
948 : static_assert(0 < 1, "There is no slot for us");
949 : static const JSJitInfo unicodeRange_setterinfo = {
950 : { (JSJitGetterOp)set_unicodeRange },
951 : { prototypes::id::FontFace },
952 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
953 : JSJitInfo::Setter,
954 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
955 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
956 : false, /* isInfallible. False in setters. */
957 : false, /* isMovable. Not relevant for setters. */
958 : false, /* isEliminatable. Not relevant for setters. */
959 : false, /* isAlwaysInSlot. Only relevant for getters. */
960 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
961 : false, /* isTypedMethod. Only relevant for methods. */
962 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
963 : };
964 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
965 : static_assert(0 < 1, "There is no slot for us");
966 :
967 : static bool
968 0 : get_variant(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
969 : {
970 0 : DOMString result;
971 0 : self->GetVariant(result);
972 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
973 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
974 0 : return false;
975 : }
976 0 : return true;
977 : }
978 :
979 : static bool
980 0 : set_variant(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitSetterCallArgs args)
981 : {
982 0 : binding_detail::FakeString arg0;
983 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
984 0 : return false;
985 : }
986 0 : binding_detail::FastErrorResult rv;
987 0 : self->SetVariant(NonNullHelper(Constify(arg0)), rv);
988 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
989 0 : return false;
990 : }
991 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
992 :
993 0 : return true;
994 : }
995 :
996 : static const JSJitInfo variant_getterinfo = {
997 : { (JSJitGetterOp)get_variant },
998 : { prototypes::id::FontFace },
999 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
1000 : JSJitInfo::Getter,
1001 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1002 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
1003 : false, /* isInfallible. False in setters. */
1004 : false, /* isMovable. Not relevant for setters. */
1005 : false, /* isEliminatable. Not relevant for setters. */
1006 : false, /* isAlwaysInSlot. Only relevant for getters. */
1007 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1008 : false, /* isTypedMethod. Only relevant for methods. */
1009 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1010 : };
1011 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1012 : static_assert(0 < 1, "There is no slot for us");
1013 : static const JSJitInfo variant_setterinfo = {
1014 : { (JSJitGetterOp)set_variant },
1015 : { prototypes::id::FontFace },
1016 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
1017 : JSJitInfo::Setter,
1018 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1019 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1020 : false, /* isInfallible. False in setters. */
1021 : false, /* isMovable. Not relevant for setters. */
1022 : false, /* isEliminatable. Not relevant for setters. */
1023 : false, /* isAlwaysInSlot. Only relevant for getters. */
1024 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1025 : false, /* isTypedMethod. Only relevant for methods. */
1026 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1027 : };
1028 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1029 : static_assert(0 < 1, "There is no slot for us");
1030 :
1031 : static bool
1032 0 : get_featureSettings(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
1033 : {
1034 0 : DOMString result;
1035 0 : self->GetFeatureSettings(result);
1036 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1037 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1038 0 : return false;
1039 : }
1040 0 : return true;
1041 : }
1042 :
1043 : static bool
1044 0 : set_featureSettings(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitSetterCallArgs args)
1045 : {
1046 0 : binding_detail::FakeString arg0;
1047 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1048 0 : return false;
1049 : }
1050 0 : binding_detail::FastErrorResult rv;
1051 0 : self->SetFeatureSettings(NonNullHelper(Constify(arg0)), rv);
1052 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1053 0 : return false;
1054 : }
1055 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1056 :
1057 0 : return true;
1058 : }
1059 :
1060 : static const JSJitInfo featureSettings_getterinfo = {
1061 : { (JSJitGetterOp)get_featureSettings },
1062 : { prototypes::id::FontFace },
1063 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
1064 : JSJitInfo::Getter,
1065 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1066 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
1067 : false, /* isInfallible. False in setters. */
1068 : false, /* isMovable. Not relevant for setters. */
1069 : false, /* isEliminatable. Not relevant for setters. */
1070 : false, /* isAlwaysInSlot. Only relevant for getters. */
1071 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1072 : false, /* isTypedMethod. Only relevant for methods. */
1073 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1074 : };
1075 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1076 : static_assert(0 < 1, "There is no slot for us");
1077 : static const JSJitInfo featureSettings_setterinfo = {
1078 : { (JSJitGetterOp)set_featureSettings },
1079 : { prototypes::id::FontFace },
1080 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
1081 : JSJitInfo::Setter,
1082 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1083 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1084 : false, /* isInfallible. False in setters. */
1085 : false, /* isMovable. Not relevant for setters. */
1086 : false, /* isEliminatable. Not relevant for setters. */
1087 : false, /* isAlwaysInSlot. Only relevant for getters. */
1088 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1089 : false, /* isTypedMethod. Only relevant for methods. */
1090 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1091 : };
1092 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1093 : static_assert(0 < 1, "There is no slot for us");
1094 :
1095 : static bool
1096 0 : get_display(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
1097 : {
1098 0 : DOMString result;
1099 0 : self->GetDisplay(result);
1100 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1101 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1102 0 : return false;
1103 : }
1104 0 : return true;
1105 : }
1106 :
1107 : static bool
1108 0 : set_display(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitSetterCallArgs args)
1109 : {
1110 0 : binding_detail::FakeString arg0;
1111 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1112 0 : return false;
1113 : }
1114 0 : binding_detail::FastErrorResult rv;
1115 0 : self->SetDisplay(NonNullHelper(Constify(arg0)), rv);
1116 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1117 0 : return false;
1118 : }
1119 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1120 :
1121 0 : return true;
1122 : }
1123 :
1124 : static const JSJitInfo display_getterinfo = {
1125 : { (JSJitGetterOp)get_display },
1126 : { prototypes::id::FontFace },
1127 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
1128 : JSJitInfo::Getter,
1129 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1130 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
1131 : false, /* isInfallible. False in setters. */
1132 : false, /* isMovable. Not relevant for setters. */
1133 : false, /* isEliminatable. Not relevant for setters. */
1134 : false, /* isAlwaysInSlot. Only relevant for getters. */
1135 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1136 : false, /* isTypedMethod. Only relevant for methods. */
1137 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1138 : };
1139 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1140 : static_assert(0 < 1, "There is no slot for us");
1141 : static const JSJitInfo display_setterinfo = {
1142 : { (JSJitGetterOp)set_display },
1143 : { prototypes::id::FontFace },
1144 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
1145 : JSJitInfo::Setter,
1146 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1147 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1148 : false, /* isInfallible. False in setters. */
1149 : false, /* isMovable. Not relevant for setters. */
1150 : false, /* isEliminatable. Not relevant for setters. */
1151 : false, /* isAlwaysInSlot. Only relevant for getters. */
1152 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1153 : false, /* isTypedMethod. Only relevant for methods. */
1154 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1155 : };
1156 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1157 : static_assert(0 < 1, "There is no slot for us");
1158 :
1159 : static bool
1160 0 : get_status(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
1161 : {
1162 0 : FontFaceLoadStatus result(self->Status());
1163 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1164 0 : if (!ToJSValue(cx, result, args.rval())) {
1165 0 : return false;
1166 : }
1167 0 : return true;
1168 : }
1169 :
1170 : static const JSJitInfo status_getterinfo = {
1171 : { (JSJitGetterOp)get_status },
1172 : { prototypes::id::FontFace },
1173 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
1174 : JSJitInfo::Getter,
1175 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1176 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
1177 : false, /* isInfallible. False in setters. */
1178 : false, /* isMovable. Not relevant for setters. */
1179 : false, /* isEliminatable. Not relevant for setters. */
1180 : false, /* isAlwaysInSlot. Only relevant for getters. */
1181 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1182 : false, /* isTypedMethod. Only relevant for methods. */
1183 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1184 : };
1185 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1186 : static_assert(0 < 1, "There is no slot for us");
1187 :
1188 : static bool
1189 0 : load(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, const JSJitMethodCallArgs& args)
1190 : {
1191 0 : binding_detail::FastErrorResult rv;
1192 0 : auto result(StrongOrRawPtr<Promise>(self->Load(rv)));
1193 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1194 0 : return false;
1195 : }
1196 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1197 0 : if (!ToJSValue(cx, result, args.rval())) {
1198 0 : return false;
1199 : }
1200 0 : return true;
1201 : }
1202 :
1203 : static bool
1204 0 : load_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, const JSJitMethodCallArgs& args)
1205 : {
1206 : // Make sure to save the callee before someone maybe messes
1207 : // with rval().
1208 0 : JS::Rooted<JSObject*> callee(cx, &args.callee());
1209 0 : bool ok = load(cx, obj, self, args);
1210 0 : if (ok) {
1211 0 : return true;
1212 : }
1213 0 : return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
1214 0 : args.rval());
1215 : }
1216 :
1217 : static const JSJitInfo load_methodinfo = {
1218 : { (JSJitGetterOp)load_promiseWrapper },
1219 : { prototypes::id::FontFace },
1220 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
1221 : JSJitInfo::Method,
1222 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1223 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
1224 : false, /* isInfallible. False in setters. */
1225 : false, /* isMovable. Not relevant for setters. */
1226 : false, /* isEliminatable. Not relevant for setters. */
1227 : false, /* isAlwaysInSlot. Only relevant for getters. */
1228 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1229 : false, /* isTypedMethod. Only relevant for methods. */
1230 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1231 : };
1232 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1233 : static_assert(0 < 1, "There is no slot for us");
1234 :
1235 : static bool
1236 0 : get_loaded(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
1237 : {
1238 0 : binding_detail::FastErrorResult rv;
1239 0 : auto result(StrongOrRawPtr<Promise>(self->GetLoaded(rv)));
1240 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1241 0 : return false;
1242 : }
1243 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1244 0 : if (!ToJSValue(cx, result, args.rval())) {
1245 0 : return false;
1246 : }
1247 0 : return true;
1248 : }
1249 :
1250 : static bool
1251 0 : get_loaded_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
1252 : {
1253 0 : bool ok = get_loaded(cx, obj, self, args);
1254 0 : if (ok) {
1255 0 : return true;
1256 : }
1257 0 : JS::Rooted<JSObject*> globalForPromise(cx);
1258 : // We can't use xpc::XrayAwareCalleeGlobal here because we have no
1259 : // callee. Use our hacky version instead.
1260 0 : if (!xpc::XrayAwareCalleeGlobalForSpecializedGetters(cx, obj,
1261 : &globalForPromise)) {
1262 0 : return false;
1263 : }
1264 0 : return ConvertExceptionToPromise(cx, globalForPromise, args.rval());
1265 : }
1266 :
1267 : static const JSJitInfo loaded_getterinfo = {
1268 : { (JSJitGetterOp)get_loaded_promiseWrapper },
1269 : { prototypes::id::FontFace },
1270 : { PrototypeTraits<prototypes::id::FontFace>::Depth },
1271 : JSJitInfo::Getter,
1272 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1273 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
1274 : false, /* isInfallible. False in setters. */
1275 : false, /* isMovable. Not relevant for setters. */
1276 : false, /* isEliminatable. Not relevant for setters. */
1277 : false, /* isAlwaysInSlot. Only relevant for getters. */
1278 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1279 : false, /* isTypedMethod. Only relevant for methods. */
1280 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1281 : };
1282 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1283 : static_assert(0 < 1, "There is no slot for us");
1284 :
1285 : static bool
1286 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1287 : {
1288 0 : mozilla::dom::FontFace* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FontFace>(obj);
1289 : // We don't want to preserve if we don't have a wrapper, and we
1290 : // obviously can't preserve if we're not initialized.
1291 0 : if (self && self->GetWrapperPreserveColor()) {
1292 0 : PreserveWrapper(self);
1293 : }
1294 0 : return true;
1295 : }
1296 :
1297 : static void
1298 0 : _finalize(js::FreeOp* fop, JSObject* obj)
1299 : {
1300 0 : mozilla::dom::FontFace* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FontFace>(obj);
1301 0 : if (self) {
1302 0 : ClearWrapper(self, self, obj);
1303 0 : AddForDeferredFinalization<mozilla::dom::FontFace>(self);
1304 : }
1305 0 : }
1306 :
1307 : static void
1308 0 : _objectMoved(JSObject* obj, const JSObject* old)
1309 : {
1310 0 : mozilla::dom::FontFace* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FontFace>(obj);
1311 0 : if (self) {
1312 0 : UpdateWrapper(self, self, obj, old);
1313 : }
1314 0 : }
1315 :
1316 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1317 : #if defined(__clang__)
1318 : #pragma clang diagnostic push
1319 : #pragma clang diagnostic ignored "-Wmissing-braces"
1320 : #endif
1321 : static const JSFunctionSpec sMethods_specs[] = {
1322 : JS_FNSPEC("load", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&load_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1323 : JS_FS_END
1324 : };
1325 : #if defined(__clang__)
1326 : #pragma clang diagnostic pop
1327 : #endif
1328 :
1329 :
1330 : // Can't be const because the pref-enabled boolean needs to be writable
1331 : static Prefable<const JSFunctionSpec> sMethods[] = {
1332 : { nullptr, &sMethods_specs[0] },
1333 : { nullptr, nullptr }
1334 : };
1335 :
1336 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1337 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1338 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1339 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1340 :
1341 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1342 : #if defined(__clang__)
1343 : #pragma clang diagnostic push
1344 : #pragma clang diagnostic ignored "-Wmissing-braces"
1345 : #endif
1346 : static const JSPropertySpec sAttributes_specs[] = {
1347 : { "family", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &family_getterinfo, GenericBindingSetter, &family_setterinfo },
1348 : { "style", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &style_getterinfo, GenericBindingSetter, &style_setterinfo },
1349 : { "weight", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &weight_getterinfo, GenericBindingSetter, &weight_setterinfo },
1350 : { "stretch", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &stretch_getterinfo, GenericBindingSetter, &stretch_setterinfo },
1351 : { "unicodeRange", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &unicodeRange_getterinfo, GenericBindingSetter, &unicodeRange_setterinfo },
1352 : { "variant", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &variant_getterinfo, GenericBindingSetter, &variant_setterinfo },
1353 : { "featureSettings", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &featureSettings_getterinfo, GenericBindingSetter, &featureSettings_setterinfo },
1354 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
1355 : { "display", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &display_getterinfo, GenericBindingSetter, &display_setterinfo },
1356 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
1357 : { "status", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &status_getterinfo, nullptr, nullptr },
1358 : { "loaded", JSPROP_SHARED | JSPROP_ENUMERATE, GenericPromiseReturningBindingGetter, &loaded_getterinfo, nullptr, nullptr },
1359 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1360 : };
1361 : #if defined(__clang__)
1362 : #pragma clang diagnostic pop
1363 : #endif
1364 :
1365 : static PrefableDisablers sAttributes_disablers8 = {
1366 : true, false, 0, nullptr
1367 : };
1368 :
1369 : // Can't be const because the pref-enabled boolean needs to be writable
1370 : static Prefable<const JSPropertySpec> sAttributes[] = {
1371 : { nullptr, &sAttributes_specs[0] },
1372 : { &sAttributes_disablers8, &sAttributes_specs[8] },
1373 : { nullptr, &sAttributes_specs[10] },
1374 : { nullptr, nullptr }
1375 : };
1376 :
1377 : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1378 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1379 : static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1380 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1381 :
1382 :
1383 : static uint16_t sNativeProperties_sortedPropertyIndices[11];
1384 : static PropertyInfo sNativeProperties_propertyInfos[11];
1385 :
1386 : static const NativePropertiesN<2> sNativeProperties = {
1387 : false, 0,
1388 : false, 0,
1389 : true, 0 /* sMethods */,
1390 : true, 1 /* sAttributes */,
1391 : false, 0,
1392 : false, 0,
1393 : false, 0,
1394 : -1,
1395 : 11,
1396 : sNativeProperties_sortedPropertyIndices,
1397 : {
1398 : { sMethods, &sNativeProperties_propertyInfos[0] },
1399 : { sAttributes, &sNativeProperties_propertyInfos[1] }
1400 : }
1401 : };
1402 : static_assert(11 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1403 : "We have a property info count that is oversized");
1404 :
1405 : static bool
1406 0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
1407 : {
1408 0 : JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
1409 0 : JS::Rooted<JSObject*> obj(cx, &args.callee());
1410 0 : if (!args.isConstructing()) {
1411 : // XXXbz wish I could get the name from the callee instead of
1412 : // Adding more relocations
1413 0 : return ThrowConstructorWithoutNew(cx, "FontFace");
1414 : }
1415 :
1416 0 : GlobalObject global(cx, obj);
1417 0 : if (global.Failed()) {
1418 0 : return false;
1419 : }
1420 :
1421 0 : JS::Rooted<JSObject*> desiredProto(cx);
1422 0 : if (!GetDesiredProto(cx, args, &desiredProto)) {
1423 0 : return false;
1424 : }
1425 :
1426 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
1427 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "FontFace");
1428 : }
1429 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
1430 0 : binding_detail::FakeString arg0;
1431 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1432 0 : return false;
1433 : }
1434 0 : StringOrArrayBufferOrArrayBufferView arg1;
1435 0 : StringOrArrayBufferOrArrayBufferViewArgument arg1_holder(arg1);
1436 : {
1437 0 : bool done = false, failed = false, tryNext;
1438 0 : if (args[1].isObject()) {
1439 0 : done = (failed = !arg1_holder.TrySetToArrayBuffer(cx, args[1], tryNext, false)) || !tryNext ||
1440 0 : (failed = !arg1_holder.TrySetToArrayBufferView(cx, args[1], tryNext, false)) || !tryNext;
1441 :
1442 : }
1443 0 : if (!done) {
1444 : do {
1445 0 : done = (failed = !arg1_holder.TrySetToString(cx, args[1], tryNext)) || !tryNext;
1446 0 : break;
1447 : } while (0);
1448 : }
1449 0 : if (failed) {
1450 0 : return false;
1451 : }
1452 0 : if (!done) {
1453 0 : ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of FontFace.constructor", "ArrayBuffer, ArrayBufferView");
1454 0 : return false;
1455 : }
1456 : }
1457 0 : binding_detail::FastFontFaceDescriptors arg2;
1458 0 : if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue, "Argument 3 of FontFace.constructor", false)) {
1459 0 : return false;
1460 : }
1461 0 : Maybe<JSAutoCompartment> ac;
1462 0 : if (objIsXray) {
1463 0 : obj = js::CheckedUnwrap(obj);
1464 0 : if (!obj) {
1465 0 : return false;
1466 : }
1467 0 : ac.emplace(cx, obj);
1468 0 : if (!JS_WrapObject(cx, &desiredProto)) {
1469 0 : return false;
1470 : }
1471 0 : if (arg1.IsArrayBuffer()) {
1472 0 : if (!arg1.GetAsArrayBuffer().WrapIntoNewCompartment(cx)) {
1473 0 : return false;
1474 : }
1475 : }
1476 0 : else if (arg1.IsArrayBufferView()) {
1477 0 : if (!arg1.GetAsArrayBufferView().WrapIntoNewCompartment(cx)) {
1478 0 : return false;
1479 : }
1480 : }
1481 : }
1482 0 : binding_detail::FastErrorResult rv;
1483 0 : auto result(StrongOrRawPtr<mozilla::dom::FontFace>(mozilla::dom::FontFace::Constructor(global, NonNullHelper(Constify(arg0)), Constify(arg1), Constify(arg2), rv)));
1484 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1485 0 : return false;
1486 : }
1487 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1488 : static_assert(!IsPointer<decltype(result)>::value,
1489 : "NewObject implies that we need to keep the object alive with a strong reference.");
1490 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
1491 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1492 0 : return false;
1493 : }
1494 0 : return true;
1495 : }
1496 :
1497 : static const js::ClassOps sInterfaceObjectClassOps = {
1498 : nullptr, /* addProperty */
1499 : nullptr, /* delProperty */
1500 : nullptr, /* getProperty */
1501 : nullptr, /* setProperty */
1502 : nullptr, /* enumerate */
1503 : nullptr, /* newEnumerate */
1504 : nullptr, /* resolve */
1505 : nullptr, /* mayResolve */
1506 : nullptr, /* finalize */
1507 : _constructor, /* call */
1508 : nullptr, /* hasInstance */
1509 : _constructor, /* construct */
1510 : nullptr, /* trace */
1511 : };
1512 :
1513 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1514 : {
1515 : "Function",
1516 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1517 : &sInterfaceObjectClassOps,
1518 : JS_NULL_CLASS_SPEC,
1519 : JS_NULL_CLASS_EXT,
1520 : &sInterfaceObjectClassObjectOps
1521 : },
1522 : eInterface,
1523 : true,
1524 : prototypes::id::FontFace,
1525 : PrototypeTraits<prototypes::id::FontFace>::Depth,
1526 : sNativePropertyHooks,
1527 : "function FontFace() {\n [native code]\n}",
1528 : JS::GetRealmFunctionPrototype
1529 : };
1530 :
1531 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1532 : {
1533 : "FontFacePrototype",
1534 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1535 : JS_NULL_CLASS_OPS,
1536 : JS_NULL_CLASS_SPEC,
1537 : JS_NULL_CLASS_EXT,
1538 : JS_NULL_OBJECT_OPS
1539 : },
1540 : eInterfacePrototype,
1541 : false,
1542 : prototypes::id::FontFace,
1543 : PrototypeTraits<prototypes::id::FontFace>::Depth,
1544 : sNativePropertyHooks,
1545 : "[object FontFacePrototype]",
1546 : JS::GetRealmObjectPrototype
1547 : };
1548 :
1549 : bool
1550 0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
1551 : {
1552 : static bool sPrefValue;
1553 : static bool sPrefCacheSetUp = false;
1554 0 : if (!sPrefCacheSetUp) {
1555 0 : sPrefCacheSetUp = true;
1556 0 : Preferences::AddBoolVarCache(&sPrefValue, "layout.css.font-loading-api.enabled");
1557 : }
1558 :
1559 0 : return sPrefValue;
1560 : }
1561 :
1562 : JSObject*
1563 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
1564 : {
1565 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
1566 : }
1567 :
1568 : static const js::ClassOps sClassOps = {
1569 : _addProperty, /* addProperty */
1570 : nullptr, /* delProperty */
1571 : nullptr, /* getProperty */
1572 : nullptr, /* setProperty */
1573 : nullptr, /* enumerate */
1574 : nullptr, /* newEnumerate */
1575 : nullptr, /* resolve */
1576 : nullptr, /* mayResolve */
1577 : _finalize, /* finalize */
1578 : nullptr, /* call */
1579 : nullptr, /* hasInstance */
1580 : nullptr, /* construct */
1581 : nullptr, /* trace */
1582 : };
1583 :
1584 : static const js::ClassExtension sClassExtension = {
1585 : nullptr, /* weakmapKeyDelegateOp */
1586 : _objectMoved /* objectMovedOp */
1587 : };
1588 :
1589 : static const DOMJSClass sClass = {
1590 : { "FontFace",
1591 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1592 : &sClassOps,
1593 : JS_NULL_CLASS_SPEC,
1594 : &sClassExtension,
1595 : JS_NULL_OBJECT_OPS
1596 : },
1597 : { prototypes::id::FontFace, 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 },
1598 : IsBaseOf<nsISupports, mozilla::dom::FontFace >::value,
1599 : sNativePropertyHooks,
1600 : FindAssociatedGlobalForNative<mozilla::dom::FontFace>::Get,
1601 : GetProtoObjectHandle,
1602 : GetCCParticipant<mozilla::dom::FontFace>::Get()
1603 : };
1604 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1605 : "Must have the right minimal number of reserved slots.");
1606 : static_assert(1 >= 1,
1607 : "Must have enough reserved slots.");
1608 :
1609 : const JSClass*
1610 0 : GetJSClass()
1611 : {
1612 0 : return sClass.ToJSClass();
1613 : }
1614 :
1615 : bool
1616 0 : Wrap(JSContext* aCx, mozilla::dom::FontFace* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1617 : {
1618 : MOZ_ASSERT(static_cast<mozilla::dom::FontFace*>(aObject) ==
1619 : reinterpret_cast<mozilla::dom::FontFace*>(aObject),
1620 : "Multiple inheritance for mozilla::dom::FontFace is broken.");
1621 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1622 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1623 0 : MOZ_ASSERT(!aCache->GetWrapper(),
1624 : "You should probably not be using Wrap() directly; use "
1625 : "GetOrCreateDOMReflector instead");
1626 :
1627 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1628 : "nsISupports must be on our primary inheritance chain");
1629 :
1630 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1631 0 : if (!global) {
1632 0 : return false;
1633 : }
1634 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
1635 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
1636 :
1637 : // That might have ended up wrapping us already, due to the wonders
1638 : // of XBL. Check for that, and bail out as needed.
1639 0 : aReflector.set(aCache->GetWrapper());
1640 0 : if (aReflector) {
1641 : #ifdef DEBUG
1642 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1643 : #endif // DEBUG
1644 0 : return true;
1645 : }
1646 :
1647 0 : JSAutoCompartment ac(aCx, global);
1648 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1649 0 : if (!canonicalProto) {
1650 0 : return false;
1651 : }
1652 0 : JS::Rooted<JSObject*> proto(aCx);
1653 0 : if (aGivenProto) {
1654 0 : proto = aGivenProto;
1655 : // Unfortunately, while aGivenProto was in the compartment of aCx
1656 : // coming in, we changed compartments to that of "parent" so may need
1657 : // to wrap the proto here.
1658 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1659 0 : if (!JS_WrapObject(aCx, &proto)) {
1660 0 : return false;
1661 : }
1662 : }
1663 : } else {
1664 0 : proto = canonicalProto;
1665 : }
1666 :
1667 0 : BindingJSObjectCreator<mozilla::dom::FontFace> creator(aCx);
1668 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1669 0 : if (!aReflector) {
1670 0 : return false;
1671 : }
1672 :
1673 0 : aCache->SetWrapper(aReflector);
1674 0 : creator.InitializationSucceeded();
1675 :
1676 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1677 : aCache->GetWrapperPreserveColor() == aReflector);
1678 : // If proto != canonicalProto, we have to preserve our wrapper;
1679 : // otherwise we won't be able to properly recreate it later, since
1680 : // we won't know what proto to use. Note that we don't check
1681 : // aGivenProto here, since it's entirely possible (and even
1682 : // somewhat common) to have a non-null aGivenProto which is the
1683 : // same as canonicalProto.
1684 0 : if (proto != canonicalProto) {
1685 0 : PreserveWrapper(aObject);
1686 : }
1687 :
1688 0 : return true;
1689 : }
1690 :
1691 : const NativePropertyHooks sNativePropertyHooks[] = { {
1692 : nullptr,
1693 : nullptr,
1694 : nullptr,
1695 : { sNativeProperties.Upcast(), nullptr },
1696 : prototypes::id::FontFace,
1697 : constructors::id::FontFace,
1698 : nullptr,
1699 : &DefaultXrayExpandoObjectClass
1700 : } };
1701 :
1702 : void
1703 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1704 : {
1705 0 : JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
1706 0 : if (!parentProto) {
1707 0 : return;
1708 : }
1709 :
1710 0 : JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
1711 0 : if (!constructorProto) {
1712 0 : return;
1713 : }
1714 :
1715 : static bool sIdsInited = false;
1716 0 : if (!sIdsInited && NS_IsMainThread()) {
1717 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
1718 0 : return;
1719 : }
1720 0 : sIdsInited = true;
1721 : }
1722 :
1723 : static bool sPrefCachesInited = false;
1724 0 : if (!sPrefCachesInited && NS_IsMainThread()) {
1725 0 : sPrefCachesInited = true;
1726 0 : Preferences::AddBoolVarCache(&sAttributes[1].disablers->enabled, "layout.css.font-display.enabled");
1727 : }
1728 :
1729 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::FontFace);
1730 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::FontFace);
1731 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1732 : &sPrototypeClass.mBase, protoCache,
1733 : constructorProto, &sInterfaceObjectClass.mBase, 2, nullptr,
1734 : interfaceCache,
1735 : sNativeProperties.Upcast(),
1736 : nullptr,
1737 : "FontFace", aDefineOnGlobal,
1738 : nullptr,
1739 0 : false);
1740 : }
1741 :
1742 : JS::Handle<JSObject*>
1743 0 : GetProtoObjectHandle(JSContext* aCx)
1744 : {
1745 : /* Get the interface prototype object for this class. This will create the
1746 : object as needed. */
1747 0 : bool aDefineOnGlobal = true;
1748 :
1749 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1750 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1751 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1752 0 : return nullptr;
1753 : }
1754 :
1755 : /* Check to see whether the interface objects are already installed */
1756 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1757 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::FontFace)) {
1758 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1759 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1760 : }
1761 :
1762 : /*
1763 : * The object might _still_ be null, but that's OK.
1764 : *
1765 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1766 : * traced by TraceProtoAndIfaceCache() and its contents are never
1767 : * changed after they have been set.
1768 : *
1769 : * Calling address() avoids the read read barrier that does gray
1770 : * unmarking, but it's not possible for the object to be gray here.
1771 : */
1772 :
1773 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::FontFace);
1774 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1775 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1776 : }
1777 :
1778 : JS::Handle<JSObject*>
1779 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
1780 : {
1781 : /* Get the interface object for this class. This will create the object as
1782 : needed. */
1783 :
1784 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1785 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1786 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1787 0 : return nullptr;
1788 : }
1789 :
1790 : /* Check to see whether the interface objects are already installed */
1791 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1792 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::FontFace)) {
1793 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1794 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1795 : }
1796 :
1797 : /*
1798 : * The object might _still_ be null, but that's OK.
1799 : *
1800 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1801 : * traced by TraceProtoAndIfaceCache() and its contents are never
1802 : * changed after they have been set.
1803 : *
1804 : * Calling address() avoids the read read barrier that does gray
1805 : * unmarking, but it's not possible for the object to be gray here.
1806 : */
1807 :
1808 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::FontFace);
1809 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1810 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1811 : }
1812 :
1813 : JSObject*
1814 0 : GetConstructorObject(JSContext* aCx)
1815 : {
1816 0 : return GetConstructorObjectHandle(aCx);
1817 : }
1818 :
1819 : } // namespace FontFaceBinding
1820 :
1821 :
1822 :
1823 : } // namespace dom
1824 : } // namespace mozilla
|