Skip to content

Commit

Permalink
[css-font-loading] Switch to using the new idl setlike declaration.
Browse files Browse the repository at this point in the history
--HG--
extra : rebase_source : 00f52c615020565d3e1537665e6fc08fa4e07d20
  • Loading branch information
tabatkins committed Nov 3, 2014
1 parent 98ffa44 commit a4fdf3e
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 172 deletions.
80 changes: 23 additions & 57 deletions css-font-loading/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -407,19 +407,10 @@ The <code>FontFaceSet</code> Interface</h2>
[Exposed=Window,Worker,
Constructor(sequence<FontFace> 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&lt;FontFace>;

// events for when loading state changes
attribute EventHandler onloading;
attribute EventHandler onloadingdone;
attribute EventHandler onloadingerror;
Expand All @@ -440,70 +431,48 @@ The <code>FontFaceSet</code> Interface</h2>
};
</pre>

<dl dfn-type=attribute dfn-for="FontFaceSet">
<dt><dfn>ready</dfn> <span attribute-info for=FontFaceSet/ready></span>
<dl dfn-for="FontFaceSet">
<dt><dfn attribute>ready</dfn> <span attribute-info for=FontFaceSet/ready></span>
<dd>
This attribute reflects the {{FontFaceSet}}'s {{[[ReadyPromise]]}} slot.

See [[#font-face-set-ready]] for more details on this {{Promise}} and its use.

<dt><dfn>size</dfn> <span attribute-info for=FontFaceSet/size></span>
<dd>
This attribute reflects the <code>size</code> attribute of the {{FontFaceSet}}'s {{[[ContainedFonts]]}} slot.

<dt><dfn attribute for="FontFaceSet">status</dfn> <span attribute-info for="FontFaceSet/status"></span>
<dd>
If there are <a>possibly pending font loads</a>,
the {{FontFaceSet/status}} attribute must have the value <code>"loading"</code>.
Otherwise, it must have the value <code>"loaded"</code>.
</dl>

<dl dfn-type=method dfn-for="FontFaceSet">
<dt><dfn title="FontFaceSet()" constructor>FontFaceSet</dfn>(sequence&lt;{{FontFace}}> <dfn argument for="FontFaceSet/FontFaceSet()">initialFaces</dfn>)
<dt><dfn constructor title="FontFaceSet()">FontFaceSet</dfn>(sequence&lt;{{FontFace}}> <dfn argument for="FontFaceSet/FontFaceSet()">initialFaces</dfn>)
<dd>
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.

<dt><dfn title=add()>add</dfn>({{FontFace}} font)
<dt><dfn title=has()>has</dfn>({{FontFace}} font)
<dt><dfn title=delete()>delete</dfn>({{FontFace}} font)
<dt><dfn title=entries()>entries</dfn>()
<dt><dfn title=keys()>keys</dfn>()
<dt><dfn title=values()>values</dfn>()
<dt><dfn title=forEach()>forEach</dfn>({{ForEachCallback}} cb, optional any thisArg)
<dd>
If {{add()}} or {{delete()}} are called
with an argument that is a <a>CSS-connected</a> {{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 <a>set entries</a>.

<dt><dfn title=clear()>clear</dfn>()
<dt><dfn>iteration order</dfn>
<dd>
This must remove all non-<a>CSS-connected</a> {{FontFace}} objects
from the {{FontFaceSet}}'s {{[[ContainedFonts]]}} slot.
When iterated over,
all <a>CSS-connected</a> {{FontFace}} objects must come first,
in document order of their connected ''@font-face'' rules,
followed by the non-<a>CSS-connected</a> {{FontFace}} objects,
in insertion order.

<dt><dfn iterator title="iterator">iterator behavior</dfn>
<dt><dfn>set entries</dfn>
<dd>
The <a spec=webidl>iterator behavior</a> is the iterator behavior of the {{FontFaceSet}}'s {{[[ContainedFonts]]}} slot.
If a {{FontFaceSet}} is a <a>font source</a>,
its <a spec=webidl for>set entries</a> are initialized as specified in [[#document-font-face-set]].

Otherwise, its <a spec=webidl for>set entries</a> are initially empty.
</dl>

{{FontFaceSet}} objects also have internal
<dfn attribute for=FontFaceSet>\[[LoadingFonts]]</dfn>,
<dfn attribute for=FontFaceSet>\[[LoadedFonts]]</dfn>,
and <dfn attribute for=FontFaceSet>\[[FailedFonts]]</dfn> slots,
all of which are initialized to the empty list,
a <dfn attribute for=FontFaceSet>\[[ReadyPromise]]</dfn> slot,
which is initialized to a fresh pending {{Promise}},
and a <dfn attribute for=FontFaceSet>\[[ContainedFonts]]</dfn> slot,
which is initialized by the <a constructor title="FontFaceSet()">FontFaceSet constructor</a> 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 <dfn attribute for=FontFaceSet>\[[ReadyPromise]]</dfn> 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.
Expand Down Expand Up @@ -976,9 +945,6 @@ Interaction with CSS’s ''@font-face'' Rule</h3>
As specified in [[#font-face-css-connection]], though,
the {{FontFace}} is no longer <a>CSS-connected</a> at that point.

All non-<a>CSS-connected</a> {{FontFace}} objects must be sorted after the <a>CSS-connected</a> 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.

Expand Down
Loading

0 comments on commit a4fdf3e

Please sign in to comment.