- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Tue, 16 Feb 2016 12:49:04 -0800
- To: "Myles C. Maxfield" <mmaxfield@apple.com>
- Cc: Cameron McCormack <cam@mcc.id.au>, www-style list <www-style@w3.org>
[please don't top-post https://wiki.csswg.org/tools/www-style ] On Tue, Feb 9, 2016 at 11:33 PM, Myles C. Maxfield <mmaxfield@apple.com> wrote: >> On Feb 5, 2016, at 8:45 PM, Cameron McCormack <cam@mcc.id.au> wrote: >> Myles C. Maxfield: >>> FontFaceSet exposes a "ready" promise attribute, which can therefore >>> only be resolved once. However, fonts may start and end loading at >>> any time. Therefore, this promise will give unintuitive and incorrect >>> information much of the time. Instead, the mechanism used to notify >>> script when all fonts in the set have finished loading should be >>> achieved via sending events. >> >> That particular Promise object will, but a new Promise object is created >> and exposed through FontFaceSet.ready when a loading starts again (after >> a period of loading being complete). >> >> At any point, if you write >> >> document.fonts.ready.then(…) >> >> you’ll be guaranteed to have your callback invoked either immediately, >> if there are no loads happening currently, or when the current loads >> complete. Storing away the document.fonts.ready Promise to call then() >> on at a later point wouldn’t be useful. > > The spec text doesn't seem to indicate this. <https://drafts.csswg.org/css-font-loading/#switch-the-fontfaceset-to-loading> defines the behavior around replacing the promise, and <https://drafts.csswg.org/css-font-loading/#font-face-set-ready>'s first note talks about "a given ready promise". I don't *explicitly* say in the non-normative text "hey, don't store this promise, we might replace it with a more accurate one at any time", but it's implied. I can add something to that effect if you want, tho. > This is a case where the engine may change an attribute of an object at an arbitrary time. This is undesirable behavior; instead, I'd like to change my proposal to be that the ready attribute should be a method instead. I don't have a strong opinion on this, but I'm weakly inclined to leave it as an attribute, because other similar specs do so. (In particular, Service Workers uses a .ready attribute, and there's a thread <https://github.com/whatwg/html/issues/127> on adding .ready to window, document, and images. (Disclaimer: consistency with FontFaceSet is one of the reasons given for using the name "ready" in that thread.) I don't want to special-snowflake this API. Changing an attribute of an object arbitrarily already happens *literally everywhere* - every single attribute whose type is a non-primitive and who doesn't have the [SameObject] extended attribute will return a new object every time by default. ~TJ
Received on Tuesday, 16 February 2016 20:49:59 UTC