Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM FontFace.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #ifndef mozilla_dom_FontFaceBinding_h
4 : #define mozilla_dom_FontFaceBinding_h
5 :
6 : #include "js/RootingAPI.h"
7 : #include "jsfriendapi.h"
8 : #include "jspubtd.h"
9 : #include "mozilla/ErrorResult.h"
10 : #include "mozilla/dom/BindingDeclarations.h"
11 : #include "mozilla/dom/FakeString.h"
12 : #include "mozilla/dom/Nullable.h"
13 : #include "mozilla/dom/TypedArray.h"
14 : #include "mozilla/dom/UnionMember.h"
15 :
16 : namespace mozilla {
17 : namespace dom {
18 :
19 : class FontFace;
20 : struct FontFaceAtoms;
21 : struct FontFaceDescriptorsAtoms;
22 : struct NativePropertyHooks;
23 : class ProtoAndIfaceCache;
24 :
25 : } // namespace dom
26 : } // namespace mozilla
27 :
28 : namespace mozilla {
29 : namespace dom {
30 :
31 : enum class FontFaceLoadStatus : uint8_t {
32 : Unloaded,
33 : Loading,
34 : Loaded,
35 : Error,
36 : EndGuard_
37 : };
38 :
39 : namespace FontFaceLoadStatusValues {
40 : extern const EnumEntry strings[5];
41 : } // namespace FontFaceLoadStatusValues
42 :
43 : bool
44 : ToJSValue(JSContext* aCx, FontFaceLoadStatus aArgument, JS::MutableHandle<JS::Value> aValue);
45 :
46 :
47 0 : struct FontFaceDescriptors : public DictionaryBase
48 : {
49 : MOZ_INIT_OUTSIDE_CTOR nsString mDisplay;
50 : MOZ_INIT_OUTSIDE_CTOR nsString mFeatureSettings;
51 : MOZ_INIT_OUTSIDE_CTOR nsString mStretch;
52 : MOZ_INIT_OUTSIDE_CTOR nsString mStyle;
53 : MOZ_INIT_OUTSIDE_CTOR nsString mUnicodeRange;
54 : MOZ_INIT_OUTSIDE_CTOR nsString mVariant;
55 : MOZ_INIT_OUTSIDE_CTOR nsString mWeight;
56 :
57 : FontFaceDescriptors();
58 :
59 0 : explicit inline FontFaceDescriptors(const FastDictionaryInitializer& )
60 0 : {
61 : // Do nothing here; this is used by our "Fast" subclass
62 0 : }
63 :
64 : explicit inline FontFaceDescriptors(const FontFaceDescriptors& aOther)
65 : {
66 : *this = aOther;
67 : }
68 :
69 : bool
70 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
71 :
72 : bool
73 : Init(const nsAString& aJSON);
74 :
75 : bool
76 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
77 :
78 : bool
79 : ToJSON(nsAString& aJSON) const;
80 :
81 : void
82 : TraceDictionary(JSTracer* trc);
83 :
84 : FontFaceDescriptors&
85 : operator=(const FontFaceDescriptors& aOther);
86 :
87 : private:
88 : static bool
89 : InitIds(JSContext* cx, FontFaceDescriptorsAtoms* atomsCache);
90 : };
91 :
92 : namespace binding_detail {
93 0 : struct FastFontFaceDescriptors : public FontFaceDescriptors
94 : {
95 0 : inline FastFontFaceDescriptors()
96 0 : : FontFaceDescriptors(FastDictionaryInitializer())
97 : {
98 : // Doesn't matter what int we pass to the parent constructor
99 0 : }
100 : };
101 : } // namespace binding_detail
102 :
103 :
104 : class StringOrArrayBufferOrArrayBufferView
105 : {
106 : friend class StringOrArrayBufferOrArrayBufferViewArgument;
107 : enum Type
108 : {
109 : eUninitialized,
110 : eString,
111 : eArrayBuffer,
112 : eArrayBufferView
113 : };
114 :
115 0 : union Value
116 : {
117 : UnionMember<binding_detail::FakeString > mString;
118 : UnionMember<RootedTypedArray<ArrayBuffer> > mArrayBuffer;
119 : UnionMember<RootedTypedArray<ArrayBufferView> > mArrayBufferView;
120 :
121 : };
122 :
123 : Type mType;
124 : Value mValue;
125 :
126 : StringOrArrayBufferOrArrayBufferView(const StringOrArrayBufferOrArrayBufferView&) = delete;
127 : StringOrArrayBufferOrArrayBufferView& operator=(const StringOrArrayBufferOrArrayBufferView&) = delete;
128 : public:
129 0 : explicit inline StringOrArrayBufferOrArrayBufferView()
130 0 : : mType(eUninitialized)
131 : {
132 0 : }
133 :
134 0 : inline ~StringOrArrayBufferOrArrayBufferView()
135 0 : {
136 0 : Uninit();
137 0 : }
138 :
139 : inline binding_detail::FakeString&
140 : RawSetAsString()
141 : {
142 : if (mType == eString) {
143 : return mValue.mString.Value();
144 : }
145 : MOZ_ASSERT(mType == eUninitialized);
146 : mType = eString;
147 : return mValue.mString.SetValue();
148 : }
149 :
150 : inline binding_detail::FakeString&
151 : SetAsString()
152 : {
153 : if (mType == eString) {
154 : return mValue.mString.Value();
155 : }
156 : Uninit();
157 : mType = eString;
158 : return mValue.mString.SetValue();
159 : }
160 :
161 : inline bool
162 0 : IsString() const
163 : {
164 0 : return mType == eString;
165 : }
166 :
167 : inline binding_detail::FakeString&
168 : GetAsString()
169 : {
170 : MOZ_ASSERT(IsString(), "Wrong type!");
171 : return mValue.mString.Value();
172 : }
173 :
174 : inline const nsAString&
175 0 : GetAsString() const
176 : {
177 0 : MOZ_ASSERT(IsString(), "Wrong type!");
178 0 : return mValue.mString.Value();
179 : }
180 :
181 : inline RootedTypedArray<ArrayBuffer>&
182 : RawSetAsArrayBuffer(JSContext* cx)
183 : {
184 : if (mType == eArrayBuffer) {
185 : return mValue.mArrayBuffer.Value();
186 : }
187 : MOZ_ASSERT(mType == eUninitialized);
188 : mType = eArrayBuffer;
189 : return mValue.mArrayBuffer.SetValue(cx);
190 : }
191 :
192 : inline RootedTypedArray<ArrayBuffer>&
193 : SetAsArrayBuffer(JSContext* cx)
194 : {
195 : if (mType == eArrayBuffer) {
196 : return mValue.mArrayBuffer.Value();
197 : }
198 : Uninit();
199 : mType = eArrayBuffer;
200 : return mValue.mArrayBuffer.SetValue(cx);
201 : }
202 :
203 : inline bool
204 0 : IsArrayBuffer() const
205 : {
206 0 : return mType == eArrayBuffer;
207 : }
208 :
209 : inline RootedTypedArray<ArrayBuffer>&
210 0 : GetAsArrayBuffer()
211 : {
212 0 : MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
213 0 : return mValue.mArrayBuffer.Value();
214 : }
215 :
216 : inline ArrayBuffer const &
217 0 : GetAsArrayBuffer() const
218 : {
219 0 : MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
220 0 : return mValue.mArrayBuffer.Value();
221 : }
222 :
223 : inline RootedTypedArray<ArrayBufferView>&
224 : RawSetAsArrayBufferView(JSContext* cx)
225 : {
226 : if (mType == eArrayBufferView) {
227 : return mValue.mArrayBufferView.Value();
228 : }
229 : MOZ_ASSERT(mType == eUninitialized);
230 : mType = eArrayBufferView;
231 : return mValue.mArrayBufferView.SetValue(cx);
232 : }
233 :
234 : inline RootedTypedArray<ArrayBufferView>&
235 : SetAsArrayBufferView(JSContext* cx)
236 : {
237 : if (mType == eArrayBufferView) {
238 : return mValue.mArrayBufferView.Value();
239 : }
240 : Uninit();
241 : mType = eArrayBufferView;
242 : return mValue.mArrayBufferView.SetValue(cx);
243 : }
244 :
245 : inline bool
246 0 : IsArrayBufferView() const
247 : {
248 0 : return mType == eArrayBufferView;
249 : }
250 :
251 : inline RootedTypedArray<ArrayBufferView>&
252 0 : GetAsArrayBufferView()
253 : {
254 0 : MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
255 0 : return mValue.mArrayBufferView.Value();
256 : }
257 :
258 : inline ArrayBufferView const &
259 0 : GetAsArrayBufferView() const
260 : {
261 0 : MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
262 0 : return mValue.mArrayBufferView.Value();
263 : }
264 :
265 : inline void
266 0 : Uninit()
267 : {
268 0 : switch (mType) {
269 : case eUninitialized: {
270 0 : break;
271 : }
272 : case eString: {
273 0 : DestroyString();
274 0 : break;
275 : }
276 : case eArrayBuffer: {
277 0 : DestroyArrayBuffer();
278 0 : break;
279 : }
280 : case eArrayBufferView: {
281 0 : DestroyArrayBufferView();
282 0 : break;
283 : }
284 : }
285 0 : }
286 :
287 : bool
288 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
289 :
290 : private:
291 : inline void
292 0 : DestroyString()
293 : {
294 0 : MOZ_ASSERT(IsString(), "Wrong type!");
295 0 : mValue.mString.Destroy();
296 0 : mType = eUninitialized;
297 0 : }
298 :
299 : inline void
300 0 : DestroyArrayBuffer()
301 : {
302 0 : MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
303 0 : mValue.mArrayBuffer.Destroy();
304 0 : mType = eUninitialized;
305 0 : }
306 :
307 : inline void
308 0 : DestroyArrayBufferView()
309 : {
310 0 : MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
311 0 : mValue.mArrayBufferView.Destroy();
312 0 : mType = eUninitialized;
313 0 : }
314 : };
315 :
316 :
317 : class OwningStringOrArrayBufferOrArrayBufferView : public AllOwningUnionBase
318 : {
319 : friend void ImplCycleCollectionUnlink(OwningStringOrArrayBufferOrArrayBufferView& aUnion);
320 : enum Type
321 : {
322 : eUninitialized,
323 : eString,
324 : eArrayBuffer,
325 : eArrayBufferView
326 : };
327 :
328 : union Value
329 : {
330 : UnionMember<nsString > mString;
331 : UnionMember<ArrayBuffer > mArrayBuffer;
332 : UnionMember<ArrayBufferView > mArrayBufferView;
333 :
334 : };
335 :
336 : Type mType;
337 : Value mValue;
338 :
339 : OwningStringOrArrayBufferOrArrayBufferView(const OwningStringOrArrayBufferOrArrayBufferView&) = delete;
340 : OwningStringOrArrayBufferOrArrayBufferView& operator=(const OwningStringOrArrayBufferOrArrayBufferView&) = delete;
341 : public:
342 : explicit inline OwningStringOrArrayBufferOrArrayBufferView()
343 : : mType(eUninitialized)
344 : {
345 : }
346 :
347 : inline ~OwningStringOrArrayBufferOrArrayBufferView()
348 : {
349 : Uninit();
350 : }
351 :
352 : nsString&
353 : RawSetAsString();
354 :
355 : nsString&
356 : SetAsString();
357 :
358 : bool
359 : TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
360 :
361 : inline void
362 : SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
363 : {
364 : RawSetAsString().Assign(aData, aLength);
365 : }
366 :
367 : inline bool
368 0 : IsString() const
369 : {
370 0 : return mType == eString;
371 : }
372 :
373 : inline nsString&
374 : GetAsString()
375 : {
376 : MOZ_ASSERT(IsString(), "Wrong type!");
377 : return mValue.mString.Value();
378 : }
379 :
380 : inline nsString const &
381 : GetAsString() const
382 : {
383 : MOZ_ASSERT(IsString(), "Wrong type!");
384 : return mValue.mString.Value();
385 : }
386 :
387 : ArrayBuffer&
388 : RawSetAsArrayBuffer();
389 :
390 : ArrayBuffer&
391 : SetAsArrayBuffer();
392 :
393 : bool
394 : TrySetToArrayBuffer(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
395 :
396 : inline bool
397 0 : IsArrayBuffer() const
398 : {
399 0 : return mType == eArrayBuffer;
400 : }
401 :
402 : inline ArrayBuffer&
403 : GetAsArrayBuffer()
404 : {
405 : MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
406 : return mValue.mArrayBuffer.Value();
407 : }
408 :
409 : inline ArrayBuffer const &
410 : GetAsArrayBuffer() const
411 : {
412 : MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
413 : return mValue.mArrayBuffer.Value();
414 : }
415 :
416 : ArrayBufferView&
417 : RawSetAsArrayBufferView();
418 :
419 : ArrayBufferView&
420 : SetAsArrayBufferView();
421 :
422 : bool
423 : TrySetToArrayBufferView(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
424 :
425 : inline bool
426 0 : IsArrayBufferView() const
427 : {
428 0 : return mType == eArrayBufferView;
429 : }
430 :
431 : inline ArrayBufferView&
432 : GetAsArrayBufferView()
433 : {
434 : MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
435 : return mValue.mArrayBufferView.Value();
436 : }
437 :
438 : inline ArrayBufferView const &
439 : GetAsArrayBufferView() const
440 : {
441 : MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
442 : return mValue.mArrayBufferView.Value();
443 : }
444 :
445 : void
446 : Uninit();
447 :
448 : bool
449 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
450 :
451 : void
452 : TraceUnion(JSTracer* trc);
453 :
454 : private:
455 : void
456 : DestroyString();
457 :
458 : void
459 : DestroyArrayBuffer();
460 :
461 : void
462 : DestroyArrayBufferView();
463 : };
464 :
465 :
466 : namespace FontFaceBinding {
467 :
468 : typedef mozilla::dom::FontFace NativeType;
469 :
470 : bool
471 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
472 :
473 : JSObject*
474 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
475 :
476 : const JSClass*
477 : GetJSClass();
478 :
479 : bool
480 : Wrap(JSContext* aCx, mozilla::dom::FontFace* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
481 :
482 : template <class T>
483 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
484 : {
485 0 : JS::Rooted<JSObject*> reflector(aCx);
486 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
487 : }
488 :
489 : // We declare this as an array so that retrieving a pointer to this
490 : // binding's property hooks only requires compile/link-time resolvable
491 : // address arithmetic. Declaring it as a pointer instead would require
492 : // doing a run-time load to fetch a pointer to this binding's property
493 : // hooks. And then structures which embedded a pointer to this structure
494 : // would require a run-time load for proper initialization, which would
495 : // then induce static constructors. Lots of static constructors.
496 : extern const NativePropertyHooks sNativePropertyHooks[];
497 :
498 : void
499 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
500 :
501 : JS::Handle<JSObject*>
502 : GetProtoObjectHandle(JSContext* aCx);
503 :
504 : JS::Handle<JSObject*>
505 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
506 :
507 : JSObject*
508 : GetConstructorObject(JSContext* aCx);
509 :
510 : } // namespace FontFaceBinding
511 :
512 :
513 :
514 : } // namespace dom
515 : } // namespace mozilla
516 :
517 : #endif // mozilla_dom_FontFaceBinding_h
|