From a4fdf3e4853af40542a6bb3a9cebc8b76dc760a8 Mon Sep 17 00:00:00 2001 From: "Tab Atkins Jr." Date: Mon, 3 Nov 2014 09:54:10 -0800 Subject: [PATCH] [css-font-loading] Switch to using the new idl setlike declaration. --HG-- extra : rebase_source : 00f52c615020565d3e1537665e6fc08fa4e07d20 --- css-font-loading/Overview.bs | 80 ++++---------- css-font-loading/Overview.html | 187 +++++++++++++-------------------- 2 files changed, 95 insertions(+), 172 deletions(-) diff --git a/css-font-loading/Overview.bs b/css-font-loading/Overview.bs index 527a5b329ec..8732404b0aa 100644 --- a/css-font-loading/Overview.bs +++ b/css-font-loading/Overview.bs @@ -407,19 +407,10 @@ The FontFaceSet Interface [Exposed=Window,Worker, Constructor(sequence initialFaces)] interface FontFaceSet : EventTarget { - // Emulate the Set interface, until we can extend Set correctly. - readonly attribute unsigned long size; - void add(FontFace font); - boolean has(FontFace font); - 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 + // FontFaceSet is Set-like! + setlike<FontFace>; + + // events for when loading state changes attribute EventHandler onloading; attribute EventHandler onloadingdone; attribute EventHandler onloadingerror; @@ -440,70 +431,48 @@ The FontFaceSet Interface }; -
-
ready +
+
ready
This attribute reflects the {{FontFaceSet}}'s {{[[ReadyPromise]]}} slot. See [[#font-face-set-ready]] for more details on this {{Promise}} and its use. -
size -
- This attribute reflects the size attribute of the {{FontFaceSet}}'s {{[[ContainedFonts]]}} slot. -
status
If there are possibly pending font loads, the {{FontFaceSet/status}} attribute must have the value "loading". Otherwise, it must have the value "loaded". -
-
-
FontFaceSet(sequence<{{FontFace}}> initialFaces) +
FontFaceSet(sequence<{{FontFace}}> initialFaces)
The {{FontFaceSet}} constructor, when called, - must construct a new {{Set}} object - by passing its {{initialFaces}} argument - to the {{Set}} constructor, - then assigning that {{Set}} object to the {{FontFaceSet}}'s {{[[ContainedFonts]]}} slot. - -
add({{FontFace}} font) -
has({{FontFace}} font) -
delete({{FontFace}} font) -
entries() -
keys() -
values() -
forEach({{ForEachCallback}} cb, optional any thisArg) -
- If {{add()}} or {{delete()}} are called - with an argument that is a CSS-connected {{FontFace}} object, - they must throw an InvalidModificationError exception. - - All of these methods call the corresponding method of the {{FontFaceSet}}'s {{[[ContainedFonts]]}} slot - with the same arguments as were passed to them, - and return the value returned by the called method. + must iterate its {{initialFaces}} argument + and add each value to its set entries. -
clear() +
iteration order
- This must remove all non-CSS-connected {{FontFace}} objects - from the {{FontFaceSet}}'s {{[[ContainedFonts]]}} slot. + When iterated over, + all CSS-connected {{FontFace}} objects must come first, + in document order of their connected ''@font-face'' rules, + followed by the non-CSS-connected {{FontFace}} objects, + in insertion order. -
iterator behavior +
set entries
- The iterator behavior is the iterator behavior of the {{FontFaceSet}}'s {{[[ContainedFonts]]}} slot. + If a {{FontFaceSet}} is a font source, + its set entries are initialized as specified in [[#document-font-face-set]]. + + Otherwise, its set entries are initially empty.
{{FontFaceSet}} objects also have internal \[[LoadingFonts]], \[[LoadedFonts]], and \[[FailedFonts]] slots, - all of which are initialized to the empty list, - a \[[ReadyPromise]] slot, - which is initialized to a fresh pending {{Promise}}, - and a \[[ContainedFonts]] slot, - which is initialized by the FontFaceSet constructor to a {{Set}} object - (though see [[#document-font-face-set]] for information on how the Set may be pre-filled - for {{FontFaceSet}} objects created by the user agent). + all of which are initialized to empty lists, + and a \[[ReadyPromise]] slot, + which is initialized to a fresh pending {{Promise}}. Because font families are loaded only when they are used, content sometimes needs to understand when the loading of fonts occurs. @@ -976,9 +945,6 @@ Interaction with CSS’s ''@font-face'' Rule As specified in [[#font-face-css-connection]], though, the {{FontFace}} is no longer CSS-connected at that point. - All non-CSS-connected {{FontFace}} objects must be sorted after the CSS-connected ones, - in insertion order. - Note: It is expected that a future version of this specification will define ways of interacting with and querying local fonts as well. diff --git a/css-font-loading/Overview.html b/css-font-loading/Overview.html index 66891764345..64b66e0d56d 100644 --- a/css-font-loading/Overview.html +++ b/css-font-loading/Overview.html @@ -54,8 +54,8 @@

CSS Font Loading Module Level 3

Editor’s Draft, - 17 October 2014

-
This version:
http://dev.w3.org/csswg/css-font-loading/
Latest version:
http://w3.org/TR/css-font-loading/
Previous Versions:
http://www.w3.org/TR/2014/WD-css-font-loading-3-20140522/
Feedback:
www-style@w3.org with subject line “[css-font-loading] … message topic …” (archives)
Editor:
Former Editor:
(Mozilla)
+ 3 November 2014 +
This version:
http://dev.w3.org/csswg/css-font-loading/
Latest version:
http://w3.org/TR/css-font-loading/
Previous Versions:
http://www.w3.org/TR/2014/WD-css-font-loading-3-20140522/
Feedback:
www-style@w3.org with subject line “[css-font-loading] … message topic …” (archives)
Editor:
Former Editor:
(Mozilla)
@@ -183,7 +183,7 @@

@font-face rules implicitly define FontFace objects, or they can be constructed manually from a url or binary data.

-
typedef (ArrayBuffer or ArrayBufferView) BinaryData;
+	
typedef (ArrayBuffer or ArrayBufferView) BinaryData;
 
 dictionary FontFaceDescriptors {
   DOMString style = "normal";
@@ -196,8 +196,8 @@ 

FontFaceLoadStatus { "unloaded", "loading", "loaded", "error" }; -[Constructor(DOMString family, (DOMString or BinaryData) source, - optional FontFaceDescriptors descriptors), +[Constructor(DOMString family, (DOMString or BinaryData) source, + optional FontFaceDescriptors descriptors), Exposed=Window,Worker] interface FontFace { attribute DOMString family; @@ -208,10 +208,10 @@

variant; attribute DOMString featureSettings; - readonly attribute FontFaceLoadStatus status; + readonly attribute FontFaceLoadStatus status; - Promise<FontFace> load(); - readonly attribute Promise<FontFace> loaded; + Promise<FontFace> load(); + readonly attribute Promise<FontFace> loaded; };

@@ -475,57 +475,48 @@

3. The FontFaceSet Interface

-
dictionary FontFaceSetLoadEventInit : EventInit {
-  sequence<FontFace> fontfaces = [];
+	
dictionary FontFaceSetLoadEventInit : EventInit {
+  sequence<FontFace> fontfaces = [];
 };
 
-[Constructor(DOMString type, optional FontFaceSetLoadEventInit eventInitDict),
+[Constructor(DOMString type, optional FontFaceSetLoadEventInit eventInitDict),
  Exposed=Window,Worker]
-interface FontFaceSetLoadEvent : Event {
-  readonly attribute sequence<FontFace> fontfaces;
+interface FontFaceSetLoadEvent : Event {
+  readonly attribute sequence<FontFace> fontfaces;
 };
 
 enum FontFaceSetLoadStatus { "loading", "loaded" };
 
-callback ForEachCallback = void (FontFace font, long index, FontFaceSet self);
+callback ForEachCallback = void (FontFace font, long index, FontFaceSet self);
 
 [Exposed=Window,Worker,
  Constructor(sequence initialFaces)]
-interface FontFaceSet : EventTarget {
-  // Emulate the Set interface, until we can extend Set correctly.
-  readonly attribute unsigned long size;
-  void add(FontFace font);
-  boolean has(FontFace font);
-  boolean delete(FontFace font);
-  void clear();
-  Iterator entries();
-  Iterator keys();
-  Iterator values();
-  void forEach(ForEachCallback cb, optional anythisArg);
-  FontFace iterator;
-
-  // -- events for when loading state changes
-  attribute EventHandler onloading;
-  attribute EventHandler onloadingdone;
-  attribute EventHandler onloadingerror;
+interface FontFaceSet : EventTarget {
+  // FontFaceSet is Set-like!
+  setlike<FontFace>;
+
+  // 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
-  Promise<sequence<FontFace>> load(DOMString font, optional DOMString text = " ");
+  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;
+  readonly attribute Promise<FontFaceSet> ready;
 
   // loading state, "loading" while one or more fonts loading, "loaded" otherwise
-  readonly attribute FontFaceSetLoadStatus status;
+  readonly attribute FontFaceSetLoadStatus status;
 };
 
-
+
ready of type Promise<FontFaceSet>, readonly
This attribute reflects the FontFaceSet's [[ReadyPromise]] slot. @@ -533,64 +524,42 @@

See §3.4 The ready attribute for more details on this Promise and its use.

-
size of type unsigned long, readonly -
- This attribute reflects the size attribute of the FontFaceSet's [[ContainedFonts]] slot. -
status of type FontFaceSetLoadStatus, readonly
If there are possibly pending font loads, the status attribute must have the value "loading". Otherwise, it must have the value "loaded". -

-
FontFaceSet(sequence<FontFace> initialFaces)
The FontFaceSet constructor, when called, - must construct a new Set object - by passing its initialFaces argument - to the Set constructor, - then assigning that Set object to the FontFaceSet's [[ContainedFonts]] slot. - -
add(FontFace font) -
has(FontFace font) -
delete(FontFace font) -
entries() -
keys() -
values() -
forEach(ForEachCallback cb, optional any thisArg) -
- If add() or delete() are called - with an argument that is a CSS-connected FontFace object, - they must throw an InvalidModificationError exception. + must iterate its initialFaces argument + and add each value to its set entries. -

All of these methods call the corresponding method of the FontFaceSet's [[ContainedFonts]] slot - with the same arguments as were passed to them, - and return the value returned by the called method.

- -
clear() +
iteration order
- This must remove all non-CSS-connected FontFace objects - from the FontFaceSet's [[ContainedFonts]] slot. + When iterated over, + all CSS-connected FontFace objects must come first, + in document order of their connected @font-face rules, + followed by the non-CSS-connected FontFace objects, + in insertion order. -
iterator behavior +
set entries
- The iterator behavior is the iterator behavior of the FontFaceSet's [[ContainedFonts]] slot. + If a FontFaceSet is a font source, + its set entries are initialized as specified in §4.2 +Interaction with CSS’s @font-face Rule. + +

Otherwise, its set entries are initially empty.

FontFaceSet objects also have internal [[LoadingFonts]], [[LoadedFonts]], and [[FailedFonts]] slots, - all of which are initialized to the empty list, - a [[ReadyPromise]] slot, - which is initialized to a fresh pending Promise, - and a [[ContainedFonts]] slot, - which is initialized by the FontFaceSet constructor to a Set object - (though see §4.2 -Interaction with CSS’s @font-face Rule for information on how the Set may be pre-filled - for FontFaceSet objects created by the user agent).

+ all of which are initialized to empty lists, + and a [[ReadyPromise]] slot, + which is initialized to a fresh pending Promise.

Because font families are loaded only when they are used, content sometimes needs to understand when the loading of fonts occurs. @@ -975,11 +944,11 @@

4
[NoInterfaceObject]
 interface FontFaceSource {
-  readonly attribute FontFaceSet fonts;
+  readonly attribute FontFaceSet fonts;
 };
 
-Document implements FontFaceSource;
-WorkerGlobalScope implements FontFaceSource;
+Document implements FontFaceSource;
+WorkerGlobalScope implements FontFaceSource;
 

Any document, workers, or other context which can use fonts in some manner must implement the FontFaceSource interface. @@ -1019,9 +988,6 @@

, though, the FontFace is no longer CSS-connected at that point.

-

All non-CSS-connected FontFace objects must be sorted after the CSS-connected ones, - in insertion order.

-

Note: It is expected that a future version of this specification will define ways of interacting with and querying local fonts as well.

@@ -1258,7 +1224,7 @@

-

References

Normative References

[css3-fonts]
John Daggett. CSS Fonts Module Level 3. 11 December 2012. WD. URL: http://www.w3.org/TR/css3-fonts/
[rfc2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: http://www.ietf.org/rfc/rfc2119.txt

Index

  • add(), 3
  • available font faces, 4
  • BinaryData, 2
  • cb, 3
  • check(), 3.3
  • clear(), 3
  • [[ContainedFonts]], 3
  • CSS-connected, 2.3
  • [[Data]], 2
  • delete(), 3
  • descriptors, 2.1
  • entries(), 3
  • eventInitDict, 3
  • [[FailedFonts]], 3
  • family
    • attribute for FontFace, 2
    • argument for FontFace/FontFace(), 2.1
  • featureSettings
    • dict-member for FontFaceDescriptors, 2
    • attribute for FontFace, 2
  • find the matching font faces, 3.1
  • fire a font load event, 3.1
  • font
    • argument for ForEachCallback, 3
    • argument for FontFaceSet/add(), 3
    • argument for FontFaceSet/has(), 3
    • argument for FontFaceSet/delete(), 3
    • argument for FontFaceSet/load(), 3.2
    • argument for FontFaceSet/check(), 3.3
  • FontFace, 2
  • FontFace(), 2.1
  • FontFaceDescriptors, 2
  • FontFaceLoadStatus, 2
  • fontfaces
    • dict-member for FontFaceSetLoadEventInit, 3
    • attribute for FontFaceSetLoadEvent, 3
  • FontFaceSet, 3
  • FontFaceSet(), 3
  • FontFaceSetLoadEvent, 3
  • FontFaceSetLoadEventInit, 3
  • FontFaceSetLoadStatus, 3
  • FontFaceSource, 4
  • fonts, 4
  • font source, 4
  • [[FontStatusPromise]], 2
  • forEach(), 3
  • ForEachCallback, 3
  • has(), 3
  • index, 3
  • initialFaces, 3
  • iterator, 3
  • keys(), 3
  • load()
    • method for FontFace, 2.2
    • method for FontFaceSet, 3.2
  • loaded, 2
  • [[LoadedFonts]], 3
  • loading, 3.1
  • loadingdone, 3.1
  • loadingerror, 3.1
  • [[LoadingFonts]], 3
  • no pending font loads, 3
  • onloading, 3
  • onloadingdone, 3
  • onloadingerror, 3
  • possibly pending font loads, 3
  • Promise, 1.1
  • ready, 3
  • [[ReadyPromise]], 3
  • self, 3
  • size, 3
  • source, 2.1
  • status
    • attribute for FontFace, 2
    • attribute for FontFaceSet, 3
  • stretch
    • dict-member for FontFaceDescriptors, 2
    • attribute for FontFace, 2
  • style
    • dict-member for FontFaceDescriptors, 2
    • attribute for FontFace, 2
  • text
    • argument for FontFaceSet/load(), 3.2
    • argument for FontFaceSet/check(), 3.3
  • thisArg, 3
  • type, 3
  • unicodeRange
    • dict-member for FontFaceDescriptors, 2
    • attribute for FontFace, 2
  • [[Urls]], 2
  • values(), 3
  • variant
    • dict-member for FontFaceDescriptors, 2
    • attribute for FontFace, 2
  • weight
    • dict-member for FontFaceDescriptors, 2
    • attribute for FontFace, 2

IDL Index

typedef (ArrayBuffer or ArrayBufferView) BinaryData;
+

References

Normative References

[css3-fonts]
John Daggett. CSS Fonts Module Level 3. 11 December 2012. WD. URL: http://www.w3.org/TR/css3-fonts/
[rfc2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: http://www.ietf.org/rfc/rfc2119.txt

Index

  • available font faces, 4
  • BinaryData, 2
  • check(), 3.3
  • CSS-connected, 2.3
  • [[Data]], 2
  • descriptors, 2.1
  • eventInitDict, 3
  • [[FailedFonts]], 3
  • family
    • attribute for FontFace, 2
    • argument for FontFace/FontFace(), 2.1
  • featureSettings
    • dict-member for FontFaceDescriptors, 2
    • attribute for FontFace, 2
  • find the matching font faces, 3.1
  • fire a font load event, 3.1
  • font
    • argument for ForEachCallback, 3
    • argument for FontFaceSet/load(), 3.2
    • argument for FontFaceSet/check(), 3.3
  • FontFace, 2
  • FontFace(), 2.1
  • FontFaceDescriptors, 2
  • FontFaceLoadStatus, 2
  • fontfaces
    • dict-member for FontFaceSetLoadEventInit, 3
    • attribute for FontFaceSetLoadEvent, 3
  • FontFaceSet, 3
  • FontFaceSet(), 3
  • FontFaceSetLoadEvent, 3
  • FontFaceSetLoadEventInit, 3
  • FontFaceSetLoadStatus, 3
  • FontFaceSource, 4
  • fonts, 4
  • font source, 4
  • [[FontStatusPromise]], 2
  • ForEachCallback, 3
  • index, 3
  • initialFaces, 3
  • iteration order, 3
  • load()
    • method for FontFace, 2.2
    • method for FontFaceSet, 3.2
  • loaded, 2
  • [[LoadedFonts]], 3
  • loading, 3.1
  • loadingdone, 3.1
  • loadingerror, 3.1
  • [[LoadingFonts]], 3
  • no pending font loads, 3
  • onloading, 3
  • onloadingdone, 3
  • onloadingerror, 3
  • possibly pending font loads, 3
  • Promise, 1.1
  • ready, 3
  • [[ReadyPromise]], 3
  • self, 3
  • set entries, 3
  • source, 2.1
  • status
    • attribute for FontFace, 2
    • attribute for FontFaceSet, 3
  • stretch
    • dict-member for FontFaceDescriptors, 2
    • attribute for FontFace, 2
  • style
    • dict-member for FontFaceDescriptors, 2
    • attribute for FontFace, 2
  • text
    • argument for FontFaceSet/load(), 3.2
    • argument for FontFaceSet/check(), 3.3
  • type, 3
  • unicodeRange
    • dict-member for FontFaceDescriptors, 2
    • attribute for FontFace, 2
  • [[Urls]], 2
  • variant
    • dict-member for FontFaceDescriptors, 2
    • attribute for FontFace, 2
  • weight
    • dict-member for FontFaceDescriptors, 2
    • attribute for FontFace, 2

IDL Index

typedef (ArrayBuffer or ArrayBufferView) BinaryData;
 
 dictionary FontFaceDescriptors {
   DOMString style = "normal";
@@ -1271,8 +1237,8 @@ 

References< enum FontFaceLoadStatus { "unloaded", "loading", "loaded", "error" }; -[Constructor(DOMString family, (DOMString or BinaryData) source, - optional FontFaceDescriptors descriptors), +[Constructor(DOMString family, (DOMString or BinaryData) source, + optional FontFaceDescriptors descriptors), Exposed=Window,Worker] interface FontFace { attribute DOMString family; @@ -1283,68 +1249,59 @@

References< attribute DOMString variant; attribute DOMString featureSettings; - readonly attribute FontFaceLoadStatus status; + readonly attribute FontFaceLoadStatus status; - Promise<FontFace> load(); - readonly attribute Promise<FontFace> loaded; + Promise<FontFace> load(); + readonly attribute Promise<FontFace> loaded; }; -dictionary FontFaceSetLoadEventInit : EventInit { - sequence<FontFace> fontfaces = []; +dictionary FontFaceSetLoadEventInit : EventInit { + sequence<FontFace> fontfaces = []; }; -[Constructor(DOMString type, optional FontFaceSetLoadEventInit eventInitDict), +[Constructor(DOMString type, optional FontFaceSetLoadEventInit eventInitDict), Exposed=Window,Worker] -interface FontFaceSetLoadEvent : Event { - readonly attribute sequence<FontFace> fontfaces; +interface FontFaceSetLoadEvent : Event { + readonly attribute sequence<FontFace> fontfaces; }; enum FontFaceSetLoadStatus { "loading", "loaded" }; -callback ForEachCallback = void (FontFace font, long index, FontFaceSet self); +callback ForEachCallback = void (FontFace font, long index, FontFaceSet self); [Exposed=Window,Worker, Constructor(sequence initialFaces)] -interface FontFaceSet : EventTarget { - // Emulate the Set interface, until we can extend Set correctly. - readonly attribute unsigned long size; - void add(FontFace font); - boolean has(FontFace font); - boolean delete(FontFace font); - void clear(); - Iterator entries(); - Iterator keys(); - Iterator values(); - void forEach(ForEachCallback cb, optional anythisArg); - FontFace iterator; - - // -- events for when loading state changes - attribute EventHandler onloading; - attribute EventHandler onloadingdone; - attribute EventHandler onloadingerror; +interface FontFaceSet : EventTarget { + // FontFaceSet is Set-like! + setlike<FontFace>; + + // 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 - Promise<sequence<FontFace>> load(DOMString font, optional DOMString text = " "); + 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; + readonly attribute Promise<FontFaceSet> ready; // loading state, "loading" while one or more fonts loading, "loaded" otherwise - readonly attribute FontFaceSetLoadStatus status; + readonly attribute FontFaceSetLoadStatus status; }; [NoInterfaceObject] interface FontFaceSource { - readonly attribute FontFaceSet fonts; + readonly attribute FontFaceSet fonts; }; -Document implements FontFaceSource; -WorkerGlobalScope implements FontFaceSource; +Document implements FontFaceSource; +WorkerGlobalScope implements FontFaceSource;

Issues Index

Several things in this spec use normal ES objects to define behavior, such as various things using Promises internally,