- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Wed, 18 Mar 2015 15:42:53 -0700
- To: www-style list <www-style@w3.org>
On Tue, Mar 17, 2015 at 11:49 PM, Cameron McCormack <cam@mcc.id.au> wrote:
> The spec uses [[LoadingFonts]], [[LoadedFonts]] and [[FailedFonts]]
> internal slots to track when loading, loadingdone and loadingerror
> events are fired and with what details.
>
> Q1
>
> The only time that a “loading” event is fired at a FontFaceSet is when
> one of the FontFaces in it has its status change to “loading”. This
> means that an event won’t be fired if a FontFace that is already
> “loading” is added to the FontFaceSet. For example:
>
> assert(document.fonts.status == "loaded");
> var f = new FontFace("test", "url(very-long-loading-font)");
> f.load();
> setTimeout(function() {
> assert(f.status == "loading");
> document.fonts.add(f);
> assert(document.fonts.status == "loaded"); // ?
> }, 1000);
>
> Is this intended, or should adding the FontFace cause
> document.fonts.status to become “loading” and f to be added to
> [[LoadingFonts]]?
Unintended. Fixed now.
(There's a parallel issue with loaded or errored fonts; I think we
want to keep that as it is. Firing an error event because you added
an already-errored font to the set seems like a bad idea.)
> Q2
>
> When a FontFace that is in a FontFaceSet has its status updated to
> “loaded”, it is added to the [[LoadedFonts]] slot. Later, the contents
> of that [[LoadedFonts]] slot are used as a value on the “loadingdone”
> event. The FontFaces in [[LoadedFonts]] are exposed on the
> “loadingdone” event even if they have been subsequently removed from the
> FontFaceSet. For example:
>
> assert(document.fonts.status == "loaded");
> var f1 = new FontFace("test", "url(takes-5s-to-load)");
> var f2 = new FontFace("test", "url(takes-10s-to-load)");
> document.fonts.add(f1);
> document.fonts.add(f2);
> f1.load();
> f2.load();
> f1.loaded.then(function() {
> assert(f1.status == "loaded");
> assert(f2.status == "loading”);
> assert(document.fonts.status == "loading");
> document.fonts.remove(f1);
> assert(document.fonts.status == "loading");
> document.fonts.onloadingdone = function(e) {
> assert(e.fontfaces[0] == f1); // ?
> };
> document.fonts.clear();
> assert(document.fonts.status == "loaded");
> });
>
> Is that intended? Or should the FontFaces exposed on the event object
> only be the ones that were in the FontFaceSet at the time its status
> became “loaded”?
Unintended. Fixed.
> Q3
>
> What is meant to happen when you add an already-“loaded” FontFace to a
> “loaded” FontFaceSet? My reading of the spec is that no events are
> fired. Is this correct, and intended?
That's intended, though I could be convinced otherwise by a use-case.
~TJ
Received on Wednesday, 18 March 2015 23:10:48 UTC