W3C home > Mailing lists > Public > www-style@w3.org > June 2014

[css-font-loading] the Set-like API on FontFaceSet

From: Cameron McCormack <cam@mcc.id.au>
Date: Mon, 30 Jun 2014 13:12:11 +1000
Message-ID: <53B0D58B.3030800@mcc.id.au>
To: "www-style@w3.org" <www-style@w3.org>
I'm uneasy about FontFaceSet including all of the things that are on 
Set.  I'm happy to keep some of them, and to have them be compatible 
with Set in case we ever work out how to really subclass Set.  I'm not 
keen about duplicating the entire Set API on every set-like interface we 
come up with until we figure that problem out.  So I feel like we should 
go with the absolute minimum to allow the inspection and manipulation of 
the FontFaceSet for now.

add and delete are obviously useful and necessary.  clear I am happy 
with too.  To be able to get to the items in the FontFaceSet, and not 
force the author to keep a parallel Set/Array, the iterator looks good.

I'm on the fence about has -- it's simple, and would let you avoid doing 
`[...document.fonts].indexOf(face) != -1`, but on the other hand I'm not 
really sure when you would need to know if a given FontFace has been 
inserted.  I guess it's simple enough to keep.

I don't think it's useful to have entries, keys and values in there.  I 
don't see how size is useful either.

forEach is a bit complicated.  The current definition is just to forward 
to the [[ContainedFonts]] Set, but that won't work if you expect the 
third argument to the callback to be the FontFaceSet rather than the 
[[ContainedFonts]] Set.  Why not just leave it to the author to do 
`[...document.fonts].forEach(...)` if they really want to iterate over 
the FontFaces?
Received on Monday, 30 June 2014 03:10:39 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:22 UTC