mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
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:
committed by
Andreas Kling
parent
fdbdb0ecd2
commit
5cefb14707
Notes:
github-actions[bot]
2026-04-24 18:20:53 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/5cefb14707f Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/9070
@@ -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 face’s [[Urls]] slot, attempt to load a font as defined in [CSS-FONTS-3],
|
||||
// as if it was the value of a @font-face rule’s src descriptor.
|
||||
|
||||
Reference in New Issue
Block a user