LibWeb: Switch font to loading in FontFace::load()

FontFace.load() set the face's status to "loading" but never switched
the containing FontFaceSets to "loading" or appended to their
`[[LoadingFonts]]` lists. The load-completion handler then found
`[[LoadingFonts]]` already empty and fired switch-to-loaded after the
first face finished, resolving `document.fonts.ready` while faces in
the same set were potentially still loading.
This commit is contained in:
Tim Ledbetter
2026-04-24 11:17:57 +01:00
committed by Andreas Kling
parent fdbdb0ecd2
commit 5cefb14707
Notes: github-actions[bot] 2026-04-24 18:20:53 +00:00

View File

@@ -726,6 +726,18 @@ GC::Ref<WebIDL::Promise> FontFace::load()
if (m_css_font_face_rule)
m_css_font_face_rule->set_loading_state(CSSStyleSheet::LoadingState::Loading);
// AD-HOC: Switch the containing FontFaceSets to "loading" for URL-backed fonts too, mirroring the step the
// constructor performs for BufferSource-backed fonts.
// Spec issue: https://github.com/w3c/csswg-drafts/issues/13235
{
HTML::TemporaryExecutionContext context(realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
for (auto& font_face_set : m_containing_sets) {
if (font_face_set->loading_fonts().is_empty())
font_face_set->switch_to_loading();
font_face_set->loading_fonts().append(*this);
}
}
Web::Platform::EventLoopPlugin::the().deferred_invoke(GC::create_function(heap(), [this] {
// 4. Using the value of font faces [[Urls]] slot, attempt to load a font as defined in [CSS-FONTS-3],
// as if it was the value of a @font-face rules src descriptor.