mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
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>
This commit is contained in:
parent
29e0fad21e
commit
56840e0a35
52 changed files with 1160 additions and 551 deletions
|
@ -175,6 +175,10 @@ DOMInterfaces = {
|
|||
'canGc': ['Abort'],
|
||||
},
|
||||
|
||||
'FontFaceSet': {
|
||||
'canGc': ['Load'],
|
||||
},
|
||||
|
||||
'GamepadHapticActuator': {
|
||||
'inRealms': ['PlayEffect', 'Reset'],
|
||||
'canGc': ['PlayEffect', 'Reset'],
|
||||
|
@ -577,6 +581,10 @@ DOMInterfaces = {
|
|||
}
|
||||
|
||||
Dictionaries = {
|
||||
'FontFaceDescriptors': {
|
||||
'derives': ['Clone', 'MallocSizeOf']
|
||||
},
|
||||
|
||||
'GPUCanvasConfiguration': {
|
||||
'derives': ['Clone']
|
||||
},
|
||||
|
|
54
components/script_bindings/webidls/FontFace.webidl
Normal file
54
components/script_bindings/webidls/FontFace.webidl
Normal file
|
@ -0,0 +1,54 @@
|
|||
/* 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/. */
|
||||
|
||||
typedef DOMString CSSOMString;
|
||||
|
||||
dictionary FontFaceDescriptors {
|
||||
CSSOMString style = "normal";
|
||||
CSSOMString weight = "normal";
|
||||
CSSOMString stretch = "normal";
|
||||
CSSOMString unicodeRange = "U+0-10FFFF";
|
||||
CSSOMString featureSettings = "normal";
|
||||
CSSOMString variationSettings = "normal";
|
||||
CSSOMString display = "auto";
|
||||
CSSOMString ascentOverride = "normal";
|
||||
CSSOMString descentOverride = "normal";
|
||||
CSSOMString lineGapOverride = "normal";
|
||||
};
|
||||
|
||||
enum FontFaceLoadStatus { "unloaded", "loading", "loaded", "error" };
|
||||
|
||||
// https://drafts.csswg.org/css-font-loading/#fontface-interface
|
||||
[Exposed=(Window /*, Worker */), Pref="dom_fontface_enabled"] // TODO: Add support for FontFace in Workers.
|
||||
interface FontFace {
|
||||
constructor(CSSOMString family, (CSSOMString or BufferSource) source,
|
||||
optional FontFaceDescriptors descriptors = {});
|
||||
[SetterThrows]
|
||||
attribute CSSOMString family;
|
||||
[SetterThrows]
|
||||
attribute CSSOMString style;
|
||||
[SetterThrows]
|
||||
attribute CSSOMString weight;
|
||||
[SetterThrows]
|
||||
attribute CSSOMString stretch;
|
||||
[SetterThrows]
|
||||
attribute CSSOMString unicodeRange;
|
||||
[SetterThrows]
|
||||
attribute CSSOMString featureSettings;
|
||||
[SetterThrows]
|
||||
attribute CSSOMString variationSettings;
|
||||
[SetterThrows]
|
||||
attribute CSSOMString display;
|
||||
[SetterThrows]
|
||||
attribute CSSOMString ascentOverride;
|
||||
[SetterThrows]
|
||||
attribute CSSOMString descentOverride;
|
||||
[SetterThrows]
|
||||
attribute CSSOMString lineGapOverride;
|
||||
|
||||
readonly attribute FontFaceLoadStatus status;
|
||||
|
||||
Promise<FontFace> load();
|
||||
readonly attribute Promise<FontFace> loaded;
|
||||
};
|
|
@ -19,12 +19,13 @@ enum FontFaceSetLoadStatus { "loading" , "loaded" };
|
|||
*/
|
||||
|
||||
// https://drafts.csswg.org/css-font-loading/#FontFaceSet-interface
|
||||
[Exposed=(Window,Worker)]
|
||||
[Exposed=(Window /*, Worker */)]
|
||||
interface FontFaceSet : EventTarget {
|
||||
// constructor(sequence<FontFace> initialFaces);
|
||||
|
||||
// setlike<FontFace>;
|
||||
// FontFaceSet add(FontFace font);
|
||||
[Pref="dom_fontface_enabled"]
|
||||
FontFaceSet add(FontFace font);
|
||||
// boolean delete(FontFace font);
|
||||
// undefined clear();
|
||||
|
||||
|
@ -35,7 +36,8 @@ interface FontFaceSet : EventTarget {
|
|||
|
||||
// check and start loads if appropriate
|
||||
// and fulfill promise when all loads complete
|
||||
// Promise<sequence<FontFace>> load(DOMString font, optional DOMString text = " ");
|
||||
[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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue