[Webkit-unassigned] [Bug 225790] document.fonts.ready is sometimes still resolved too quickly

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu May 13 17:34:12 PDT 2021


https://bugs.webkit.org/show_bug.cgi?id=225790

--- Comment #8 from Cameron McCormack (:heycam) <heycam at apple.com> ---
(In reply to Ryosuke Niwa from comment #7)
> Right. It looks like the current spec seems to suggest that any @font-face
> rule which appears in a CSS will automatically adds a new entry to
> FontFaceSet of the document:
> https://drafts.csswg.org/css-font-loading/#font-face-css-connection
> 
> This might be problematic given that this will end up loading all fonts
> regardless of whether they're used or not.

I don't think that's what would happen.  CSS connected FontFace objects should only start loading when the UA decides it needs them per https://drafts.csswg.org/css-font-loading/#font-face-set-css.

> It still makes it ambiguous as to when @font-face rule will be added to
> FontFaceSet and what "status" should say in the intervening period. Namely,
> if all @font-face rules are defined in an external CSS resource, then there
> is no CSS-connected FontFace object at the time of accessing document.fonts
> above, which means that document.fonts.status will say loaded. Only when the
> stylesheet gets loaded, then do we find @font-face rules and therefore adds
> more entries to the font source.

I agree it's underdefined when exactly the FontFace object should start loading.  But I think, implicitly (like all other APIs), inspecting the contents of the FontFaceSet should reflect all style sheets currently loaded (which means inspecting the FontFaceSet should flush style sheets).

The loading of the external style sheets in my test should block the load event, so by the time we inspect document.fonts I think it's guaranteed that the FontFace is in there (even if it's not clear what its loading state should be).

> Given that a new stylesheet content might be loaded at any moment while the
> document in question is loading, I don't think there is any reason to
> believe document.fonts.status will return a reliable information until load
> event is fired on the global object.

Agreed.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20210514/b396906f/attachment.htm>


More information about the webkit-unassigned mailing list