W3C home > Mailing lists > Public > www-style@w3.org > November 2012

[css3-fonts] CSSFontFaceLoadEvent / FontLoader

From: Ms2ger <ms2ger@gmail.com>
Date: Thu, 15 Nov 2012 11:08:35 +0100
Message-ID: <50A4BF23.6000708@gmail.com>
To: John Daggett <jdaggett@mozilla.com>
CC: www-style@w3.org
Hi John,

Looking at the specification for the CSSFontFaceLoadEvent event and the 
FontLoader interface [1], I noticed a number of issues.

First, the constructor should be

[Constructor(DOMString type, optional CSSFontFaceLoadEventInit 
eventInitDict)]

with CSSFontFaceLoadEventInitDict defined as

dictionary FontFaceLoadEventInit : EventInit {
   readonly attribute CSSFontFaceRule fontface;
   readonly attribute DOMString error;
};

as already reported in July. [2]

Second, the prose should clarify the initial values of the various 
attributes.


Third,

   [TreatNonCallableAsNull] attribute Function? onloadstart;

should now be

   attribute EventHandler onloadstart;

(EventHandler is defined in HTML, like Function [3]).


Fourth, I don't think

   callback FontsReadyCallback = void ();

can be defined within an interface, rather than at the top level.


Fifth, the value of the document.fontloader attribute is not formally 
defined.


Sixth, the prose lacks requirements–it contains only statements of 
facts, and no normative conformance requirement statements (as described 
by Hixie [4]). I've tried to rewrite the first paragraph to actually 
define what it needs to define:

(I used |foo| for <code/>, /foo/ for <var/>, *foo* for <dfn/>, _foo_ for 
<a/> and [] for my own comments.)

# To *fire a font load event* named /e/ with a given /font face/ and
# an /error/ at an object /target/ means to _fire an event named e_
# at /target/ with an _event_ using the |CSSFontFaceLoadEvent|
# interface that also meets these conditions:
#
# 1. The |fontface| attribute is initialized to the given /font
#    face/.
# 2. The |error| attribute is initialized to the given /error/.
#
# When the user agent determines that a font or a set of fonts
# defined via |@font-face| rules in a document /doc/ need to be
# loaded, it must run the following steps:
#
# 1. Let /font loader/ be the value of /doc/'s |fontloader| attribute
# 2. Set /font loader/'s |readyState| attribute to "loading".
# 3. _Fire a font load event_ named "loading" with /font face/ [a
#    random one?] and /error/ [something?] at /font loader/.
# 4. When the user agent begins loading each font, it must _fire a
#    font load event_ named "loadstart" with /font face/ the
#    |@font-face| rule that caused this load to start [what if
#    there's more than one or none?], and /error/ [something?] at
#    /font loader/.
#
# The term “font load” covers any of the resources listed in the
# ‘src’ descriptor, including local fonts.
#
# When the user agent completes each font load for a document /doc/,
# it must run the following steps:
# 1. Let /font loader/ be the value of /doc/'s |fontloader| attribute
# 2. If none of the resources listed for the ‘src’ descriptor contain
#    valid data, _fire a font load event_ named "error" with /font
#    face/ the |@font-face| rule that caused this load to start and
#    /error/ [something?] at /font loader/.
# 3. Otherwise, _fire a font load event_ named "load" with /font
#    face/ the |@font-face| rule that caused this load to start and
#    /error/ [something?] at /font loader/.
#
# When the user agent completes the final font load for document
# /doc/, it must run the following steps:
# 1. Let /font loader/ be the value of /doc/'s |fontloader| attribute
# 2. Set /font loader/'s |readyState| attribute to "idle".
# [Dropped the claim that yet another "load"/"error" event is to be
# fired.]
# 3. _Fire a font load event_ named "loadingdone" with /font face/
#    [a random one?] and /error/ [something?] at /font loader/.
#
# Note: For example, if three fonts are loaded at the same time, a
# "loading" event followed by three "loadstart" events and three
# "load" or "error" events, followed by a "loadingdone" event will
# occur.

This shows that rather much information is missing still. You'll 
probably also need to change those events to be asynchronous by 
referencing the "queue a task" algorithm [5].

Finally, I'll note that the syntax of the font argument to the loadFont 
method isn't specified.

HTH
Ms2ger

[1] http://dev.w3.org/csswg/css3-fonts/#fontloader-interface
[2] http://lists.w3.org/Archives/Public/www-style/2012Jul/0579.html
[3] http://www.whatwg.org/html/#eventhandler
[4] http://ln.hixie.ch/?start=1140242962&count=1
[5] http://www.whatwg.org/html/#queue-a-task
Received on Thursday, 15 November 2012 10:09:07 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:21:02 GMT