- From: Sebastian Zartner <sebastianzartner@gmail.com>
- Date: Thu, 6 Sep 2012 19:03:17 +0200
- To: "Tab Atkins Jr." <jackalmage@gmail.com>
- Cc: John Daggett <jdaggett@mozilla.com>, www-style list <www-style@w3.org>
> > // -- fires when all font loads have completed or failed > > [TreatNonCallableAsNull] attribute Function? onallcomplete; > > In discussion, my coworkers and I thought the "all" name would be > somewhat confusing. It's all the fonts *that the page has so far > requested*, which means that the "allcomplete" event can fire multiple > times in a page's lifecycle. I'm not sure what a better name is, > though. > > How about just onidle? You can complement that with onloading for the > opposite case. onidle and onloading sound fine to me. > > // -- fires when a single font load completes > > [TreatNonCallableAsNull] attribute Function? onload; > > > > // -- fires when a single font load fails > > [TreatNonCallableAsNull] attribute Function? onerror; > > I don't think I like errors to trigger a separate event. I used a > "usedSrc" attribute in the load event to indicate which source was > chosen, which was nulled in case of error. I agree with Tab as long as the event he described in his wiki page[1] contains all the other information to describe the font, which was tried to load. > > // notify completion, even if no fonts load > > void notifyAfterCompletion(); > > I'm fine with things like this (simplifies interaction/API usually), > but this is the reason promises are often better than events - you > could just hinge some code on the allloaded promise and it'll either > run immediately (well, in the next event loop cycle) or be held until > the promise actually fulfills. I wish tc39 would hurry up and decide > which flavor of promises they want to bless. :/ If I understand correctly notifyAfterCompletion() "arms" document.fontloader again. So the "allcomplete" / "idle" event is normally just fired once in the life cycle of a page, right? > > Bubbles: only in my champagne darling Haha, that's good! ;-) > Is that supposed to be the CSSFontFaceRule that actually kicked off > the load? Note that you can't expose that cross-origin. This also > means that to identify the font, you have to write > "event.fontface.style.foo". This is why I flattened the @font-face > descriptors onto the event object - much shorter, and no cross-origin > issues. But it also means when the CSSFontFaceRule descriptors get extended the event will also have to be adjusted, no? > This also lacks the ability to tell which source was chosen in the > load, which seemed useful in discussion with coworkers. My proposal > had a 'usedSrc' attribute for that. Yes. That information is important for my use case. [2] Sebastian [1] http://wiki.csswg.org/spec/font-load-events [2] http://code.google.com/p/fbug/issues/detail?id=4966
Received on Thursday, 6 September 2012 17:03:49 UTC