1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
6 * The origin of this IDL file is
7 * http://dev.w3.org/csswg/css-font-loading/#FontFaceSet-interface
9 * Copyright © 2014 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. W3C
10 * liability, trademark and document use rules apply.
13 // To implement FontFaceSet's iterator until we can use setlike.
14 dictionary FontFaceSetIteratorResult
17 required boolean done;
20 // To implement FontFaceSet's iterator until we can use setlike.
21 [LegacyNoInterfaceObject,
22 Exposed=(Window,Worker)]
23 interface FontFaceSetIterator {
24 [Throws] FontFaceSetIteratorResult next();
27 callback FontFaceSetForEachCallback = undefined (FontFace value, FontFace key, FontFaceSet set);
29 enum FontFaceSetLoadStatus { "loading", "loaded" };
31 [Func="FontFaceSet::IsEnabled",
32 Exposed=(Window,Worker)]
33 interface FontFaceSet : EventTarget {
34 // Bug 1072762 is for the FontFaceSet constructor.
35 // constructor(sequence<FontFace> initialFaces);
37 // Emulate setlike behavior until we can use that directly.
38 readonly attribute unsigned long size;
39 [Throws] undefined add(FontFace font);
40 boolean has(FontFace font);
41 boolean delete(FontFace font);
43 [NewObject] FontFaceSetIterator entries();
45 [NewObject, Alias=keys, Alias="@@iterator"] FontFaceSetIterator values();
46 [Throws] undefined forEach(FontFaceSetForEachCallback cb, optional any thisArg);
48 // -- events for when loading state changes
49 attribute EventHandler onloading;
50 attribute EventHandler onloadingdone;
51 attribute EventHandler onloadingerror;
53 // check and start loads if appropriate
54 // and fulfill promise when all loads complete
55 [NewObject] Promise<sequence<FontFace>> load(UTF8String font, optional DOMString text = " ");
57 // return whether all fonts in the fontlist are loaded
58 // (does not initiate load if not available)
59 [Throws] boolean check(UTF8String font, optional DOMString text = " ");
61 // async notification that font loading and layout operations are done
62 [Throws] readonly attribute Promise<undefined> ready;
64 // loading state, "loading" while one or more fonts loading, "loaded" otherwise
65 readonly attribute FontFaceSetLoadStatus status;