servo/components/script_bindings/webidls/FontFaceSet.webidl
Mukilan Thiyagarajan 56840e0a35
script: add skeleton implementation of FontFace API (#35262)
This patch implements the `FontFace` interface, but with some caveats

1. The interface is only exposed on `Window`. Support for Workers will
   be handled in the future.
2. The concept of `css-connected` `FontFace` is not implemented, so
   `@font-face` rules in stylesheets will not be represented in the DOM.
3. The constructor only supports using `url()` strings as source
   and `ArrayBuffer` and `ArrayBufferView` are not supported yet.

A skeleton implementation of the `load` method of `FontFaceSet` is also
implemented in this patch. The intention is to support some web pages
that don't load without this method.

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-02-19 05:50:01 +00:00

51 lines
1.8 KiB
Text

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
/*
dictionary FontFaceSetLoadEventInit : EventInit {
sequence<FontFace> fontfaces = [];
};
[Exposed=(Window,Worker)]
interface FontFaceSetLoadEvent : Event {
constructor(DOMString type, optional FontFaceSetLoadEventInit eventInitDict = {});
// WebIDL needs to support FrozenArray & SameObject
// [SameObject] readonly attribute FrozenArray<FontFace> fontfaces;
readonly attribute any fontfaces;
};
enum FontFaceSetLoadStatus { "loading" , "loaded" };
*/
// https://drafts.csswg.org/css-font-loading/#FontFaceSet-interface
[Exposed=(Window /*, Worker */)]
interface FontFaceSet : EventTarget {
// constructor(sequence<FontFace> initialFaces);
// setlike<FontFace>;
[Pref="dom_fontface_enabled"]
FontFaceSet add(FontFace font);
// boolean delete(FontFace font);
// undefined clear();
// events for when loading state changes
// attribute EventHandler onloading;
// attribute EventHandler onloadingdone;
// attribute EventHandler onloadingerror;
// check and start loads if appropriate
// and fulfill promise when all loads complete
[Pref="dom_fontface_enabled"]
Promise<sequence<FontFace>> load(DOMString font, optional DOMString text = " ");
// return whether all fonts in the fontlist are loaded
// (does not initiate load if not available)
// boolean check(DOMString font, optional DOMString text = " ");
// async notification that font loading and layout operations are done
readonly attribute Promise<FontFaceSet> ready;
// loading state, "loading" while one or more fonts loading, "loaded" otherwise
// readonly attribute FontFaceSetLoadStatus status;
};