W3C home > Mailing lists > Public > www-style@w3.org > February 2016

Re: [Font Loading] FontFaceSet's Ready Promise

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 16 Feb 2016 12:49:04 -0800
Message-ID: <CAAWBYDBeMgUz9xF+NqgYbhjK+_pjvZJ1SfboAoeR8h5q4U=F4Q@mail.gmail.com>
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.

defines the behavior around replacing the promise, and
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.

Received on Tuesday, 16 February 2016 20:49:59 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:09:00 UTC