document.fonts.ready is resolved too quickly
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Aug 2019 22:01:53 +0000 (22:01 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Aug 2019 22:01:53 +0000 (22:01 +0000)
commit89774a57bf2d81a0a66f361cb66f2084add35cba
tree3786daa2f9710c99d26d42149d148a7fc232ebbb
parent8bdb631195ddecfbcac26f30036da9d9f24360e6
document.fonts.ready is resolved too quickly
https://bugs.webkit.org/show_bug.cgi?id=174030
<rdar://problem/33083550>

Reviewed by Frédéric Wang.

LayoutTests/imported/w3c:

Test from https://github.com/web-platform-tests/wpt/pull/18489.

* web-platform-tests/fonts/ahem.css: Added.
(@font-face):
* web-platform-tests/infrastructure/assumptions/document-fonts-ready-expected.txt: Added.
* web-platform-tests/infrastructure/assumptions/document-fonts-ready.html: Added.

Source/WebCore:

As described in https://drafts.csswg.org/css-font-loading/#font-face-set-ready, the ready promise
is only fulfilled after layout operations complete and no additional font loads are necessary.

This patch implements this by notifying the FontFaceSet created for the document when the document
is finished loading. At that time, the promise will be resolved as soon as fonts are finished loading if any.

Test: imported/w3c/web-platform-tests/infrastructure/assumptions/document-fonts-ready.html

* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::optionalFontFaceSet):
* css/CSSFontSelector.h:
* css/FontFaceSet.cpp:
(WebCore::FontFaceSet::FontFaceSet):
(WebCore::FontFaceSet::startedLoading):
(WebCore::FontFaceSet::didFirstLayout):
(WebCore::FontFaceSet::completedLoading):
* css/FontFaceSet.h:
* dom/Document.cpp:
(WebCore::Document::implicitClose):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249295 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/fonts/ahem.css [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/infrastructure/assumptions/document-fonts-ready-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/infrastructure/assumptions/document-fonts-ready.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSFontSelector.cpp
Source/WebCore/css/CSSFontSelector.h
Source/WebCore/css/FontFaceSet.cpp
Source/WebCore/css/FontFaceSet.h
Source/WebCore/dom/Document.cpp