mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-01 16:02:53 +00:00
LibWeb: Resolve document.fonts.ready() after fonts defined in CSS loaded
This is an ad-hoc implementation that resolves the ready() promise once the document and all fonts collected by the style computer are done loading. A spec-compliant implementation would include creating a proxy CSS::FontFace for each @font-face and correctly implementing the specification steps for font fetching, but we are far from there yet. This hackish implementation should yield good WPT progress because it will actually start waiting for the Ahem font to load before capturing layout measurements. For example, it makes https://wpt.live/css/css-grid/abspos/positioned-grid-descendants-001.html go from 0/100 to 36/100 passing subtests.
This commit is contained in:
parent
814fa0682a
commit
5faca4f027
Notes:
github-actions[bot]
2024-09-30 06:08:51 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 5faca4f027
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1569
5 changed files with 35 additions and 5 deletions
|
@ -8,10 +8,13 @@
|
|||
#include <LibCore/EventLoop.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/CSS/FontFaceSet.h>
|
||||
#include <LibWeb/CSS/StyleComputer.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/EventLoop/EventLoop.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
|
||||
#include <LibWeb/HTML/TraversableNavigable.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/HighResolutionTime/Performance.h>
|
||||
|
@ -381,6 +384,14 @@ void EventLoop::process()
|
|||
for_each_fully_active_document_in_docs([&](DOM::Document& document) {
|
||||
document.process_top_layer_removals();
|
||||
});
|
||||
|
||||
// Not in the spec:
|
||||
for_each_fully_active_document_in_docs([&](DOM::Document& document) {
|
||||
if (document.readiness() == HTML::DocumentReadyState::Complete && document.style_computer().number_of_css_font_faces_with_loading_in_progress() == 0) {
|
||||
HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(document), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
|
||||
document.fonts()->resolve_ready_promise();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue