[css-font-loading] tracking FontFace objects for loadingdone/loadingerror events

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]]?

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”?

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?

-- 
Cameron McCormack ≝ http://mcc.id.au/

Received on Wednesday, 18 March 2015 06:50:09 UTC