Closed Bug 1466431 Opened 6 years ago Closed 6 years ago

Fix resolving of the document.fonts.ready Promise for documents that never load fonts

Categories

(Core :: Layout, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla62
Tracking Status
firefox62 --- fixed

People

(Reporter: jwatt, Assigned: jwatt)

References

Details

Attachments

(1 file)

Bug 1465983 changes the document.fonts.ready Promise so that it is no longer resolved as soon as it's created.

Currently our code in FontFaceSet::CheckLoadingFinished() -- the code that resolves the Promise -- checks for |mStatus == FontFaceSetLoadStatus::Loaded| to see if we've already resolved the Promise. That's fine if we load a (any) FontFace, since doing so switches mStatus from the initial value Loaded to Loading. However, if a document never loads a font, the Promise will be left pending for ever, because mStatus will never be anything except Loaded, and CheckLoadingFinished will think it has resolved the Promise and return early.

Basically it's wrong to be equating |mStatus == FontFaceSetLoadStatus::Loaded| with "the Promise is resolved". mStatus is an indication of whether any FontFaces are in the process of being downloaded. Whether the Promise is resolved or not depends on more than just that though. Specifically, it cannot be resolved while style sheets are "stuck on the environment" in spec parlance. I.e. while style sheets are loading/parsing, or layout is pending.

We need to change this |mStatus == FontFaceSetLoadStatus::Loaded| check to an explicit check for the state of the Promise.
Attached patch patchSplinter Review
Attachment #8982941 - Flags: review?(cam)
Comment on attachment 8982941 [details] [diff] [review]
patch

Review of attachment 8982941 [details] [diff] [review]:
-----------------------------------------------------------------

Test? :)
Attachment #8982941 - Flags: review?(cam) → review+
(In reply to Cameron McCormack (:heycam) from comment #2)
> Test? :)

Many tests in layout/style/test/test_font_loading_api.html fail without this.
Pushed by jwatt@jwatt.org:
https://hg.mozilla.org/integration/mozilla-inbound/rev/19de16bae96c
Fix resolving of the document.fonts.ready Promise for documents that never load fonts. r=heycam
Priority: -- → P2
https://hg.mozilla.org/mozilla-central/rev/19de16bae96c
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla62
Blocks: 1465983
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: