Bug 1028497 - Part 2: Add Web IDL interfaces for CSS Font Loading API. r=bzbarsky

This commit is contained in:
Cameron McCormack 2014-10-02 12:32:05 +10:00
Родитель c8458aea7b
Коммит 8c4dd6fb24
10 изменённых файлов: 169 добавлений и 0 удалений

Просмотреть файл

@ -102,6 +102,10 @@ const kEventConstructors = {
return e;
},
},
CSSFontFaceLoadEvent: { create: function (aName, aProps) {
return new CSSFontFaceLoadEvent(aName, aProps);
},
},
CustomEvent: { create: function (aName, aProps) {
return new CustomEvent(aName, aProps);
},

Просмотреть файл

@ -254,6 +254,8 @@ var interfaceNamesInGlobalScope =
"CSSConditionRule",
// IMPORTANT: Do not change this list without review from a DOM peer!
"CSSCounterStyleRule",
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "CSSFontFaceLoadEvent", pref: "layout.css.font-loading-api.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!
"CSSFontFaceRule",
// IMPORTANT: Do not change this list without review from a DOM peer!
@ -398,6 +400,10 @@ var interfaceNamesInGlobalScope =
"FocusEvent",
// IMPORTANT: Do not change this list without review from a DOM peer!
"FormData",
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "FontFace", pref: "layout.css.font-loading-api.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "FontFaceSet", pref: "layout.css.font-loading-api.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!
"GainNode",
// IMPORTANT: Do not change this list without review from a DOM peer!

Просмотреть файл

@ -0,0 +1,21 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* http://dev.w3.org/csswg/css-font-loading/#FontFaceSet-interface
*
* Copyright © 2014 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
dictionary CSSFontFaceLoadEventInit : EventInit {
sequence<FontFace> fontfaces = [];
};
[Constructor(DOMString type, optional CSSFontFaceLoadEventInit eventInitDict),
Pref="layout.css.font-loading-api.enabled"]
interface CSSFontFaceLoadEvent : Event {
[Cached, Constant] readonly attribute sequence<FontFace> fontfaces;
};

Просмотреть файл

@ -361,3 +361,4 @@ Document implements TouchEventHandlers;
Document implements ParentNode;
Document implements OnErrorEventHandlerForNodes;
Document implements GeometryUtils;
Document implements FontFaceSource;

Просмотреть файл

@ -0,0 +1,46 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* http://dev.w3.org/csswg/css-font-loading/#fontface-interface
*
* Copyright © 2014 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
typedef (ArrayBuffer or ArrayBufferView) BinaryData;
dictionary FontFaceDescriptors {
DOMString style = "normal";
DOMString weight = "normal";
DOMString stretch = "normal";
DOMString unicodeRange = "U+0-10FFFF";
DOMString variant = "normal";
DOMString featureSettings = "normal";
};
enum FontFaceLoadStatus { "unloaded", "loading", "loaded", "error" };
// Bug 1072107 is for exposing this in workers.
// [Exposed=(Window,Worker)]
[Constructor(DOMString family,
(DOMString or BinaryData) source,
optional FontFaceDescriptors descriptors),
Pref="layout.css.font-loading-api.enabled"]
interface FontFace {
[SetterThrows] attribute DOMString family;
[SetterThrows] attribute DOMString style;
[SetterThrows] attribute DOMString weight;
[SetterThrows] attribute DOMString stretch;
[SetterThrows] attribute DOMString unicodeRange;
[SetterThrows] attribute DOMString variant;
[SetterThrows] attribute DOMString featureSettings;
readonly attribute FontFaceLoadStatus status;
Promise<FontFace> load();
readonly attribute Promise<FontFace> loaded;
};

Просмотреть файл

@ -0,0 +1,63 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* http://dev.w3.org/csswg/css-font-loading/#FontFaceSet-interface
*
* Copyright © 2014 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
enum FontFaceSetLoadStatus { "loading", "loaded" };
// Bug 1072762 is for the FontFaceSet constructor.
// [Constructor(sequence<FontFace> initialFaces)]
[Pref="layout.css.font-loading-api.enabled"]
interface FontFaceSet : EventTarget {
// Emulate the Set interface, until we can extend Set correctly.
// Implementing these commented out operations and the iterator is
// bug 1072101.
// readonly attribute unsigned long size;
[Throws] void add(FontFace font);
boolean has(FontFace font);
[Throws] boolean delete(FontFace font);
void clear();
// Iterator entries();
// Iterator keys();
// Iterator values();
// void forEach(ForEachCallback cb, optional any thisArg);
// FontFace iterator;
// -- 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
// Not implemented yet: bug 1072102.
[Throws] 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)
// Not implemented yet: bug 1072102.
// [Throws] boolean check(DOMString font, optional DOMString text = " ");
// async notification that font loading and layout operations are done
[Throws] readonly attribute Promise<void> ready;
// loading state, "loading" while one or more fonts loading, "loaded" otherwise
readonly attribute FontFaceSetLoadStatus status;
};
// This provides access to the FontFace objects in the FontFaceSet until we
// get iterators working (bug 1072101). Don't enable the pref for the CSS Font
// Loading API until the iterator is available, as we don't want to expose more
// indexed properties on the Web.
partial interface FontFaceSet {
getter FontFace (unsigned long index);
readonly attribute unsigned long length;
};

Просмотреть файл

@ -0,0 +1,18 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* http://dev.w3.org/csswg/css-font-loading/#font-face-source
*
* Copyright © 2014 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
[NoInterfaceObject]
interface FontFaceSource {
[Throws, Pref="layout.css.font-loading-api.enabled"]
readonly attribute FontFaceSet fonts;
};

Просмотреть файл

@ -39,6 +39,9 @@ partial interface WorkerGlobalScope {
WorkerGlobalScope implements WindowTimers;
WorkerGlobalScope implements WindowBase64;
// Not implemented yet: bug 1072107.
// WorkerGlobalScope implements FontFaceSource;
// Mozilla extensions
partial interface WorkerGlobalScope {
attribute EventHandler onclose;

Просмотреть файл

@ -130,6 +130,9 @@ WEBIDL_FILES = [
'FileReader.webidl',
'FileReaderSync.webidl',
'FocusEvent.webidl',
'FontFace.webidl',
'FontFaceSet.webidl',
'FontFaceSource.webidl',
'FormData.webidl',
'Function.webidl',
'GainNode.webidl',
@ -648,6 +651,7 @@ GENERATED_EVENTS_WEBIDL_FILES = [
'CallGroupErrorEvent.webidl',
'CFStateChangeEvent.webidl',
'CloseEvent.webidl',
'CSSFontFaceLoadEvent.webidl',
'DataErrorEvent.webidl',
'DataStoreChangeEvent.webidl',
'DeviceLightEvent.webidl',

Просмотреть файл

@ -2119,6 +2119,9 @@ pref("layout.css.scroll-behavior.spring-constant", "250.0");
pref("layout.css.scroll-behavior.damping-ratio", "1.0");
// Is support for document.fonts enabled?
//
// Don't enable the pref for the CSS Font Loading API until bug 1072101 is
// fixed, as we don't want to expose more indexed properties on the Web.
pref("layout.css.font-loading-api.enabled", false);
// pref for which side vertical scrollbars should be on