LibWeb/CSS: Wait for resources to load to fire <style> load event

Previously, we fired the load event immediately, without waiting for
anything. This was good for not timing out, but bad for anything that
wanted to wait for the load to complete.

CSSStyleSheet now maintains a list of critical subresources, and waits
for all of them to complete before it then tells its owner that it is
ready. "Complete" here means the network request completed with or
without an error. This is done by having those subresources (just
`@import` for now) notify their style sheet when they complete. This
then propagates up as an `@import` tells its style sheet, which then
would tell its parent `@import` if it had one.

There are other subresources we should wait for (specifically fonts and
background images) but this commit just adds `@import` as a first step.
This commit is contained in:
Sam Atkins
2026-02-05 17:40:15 +00:00
committed by Andreas Kling
parent 44cbdc34fa
commit b21a05d290
Notes: github-actions[bot] 2026-02-12 15:24:37 +00:00
11 changed files with 224 additions and 57 deletions

View File

@@ -2,29 +2,28 @@ Harness status: OK
Found 24 tests
10 Pass
14 Fail
Fail A1 Layer rules with import
24 Pass
Pass A1 Layer rules with import
Pass A2 Layer rules with import
Fail A3 Layer rules with import
Fail A4 Layer rules with import
Pass A3 Layer rules with import
Pass A4 Layer rules with import
Pass B1 Anonymous imports
Fail B2 Anonymous imports
Pass B2 Anonymous imports
Pass B3 Anonymous imports
Fail B4 Anonymous imports
Pass B4 Anonymous imports
Pass C1 Named imports
Fail C2 Named imports
Pass C2 Named imports
Pass C3 Named imports
Pass C4 Named imports
Pass C5 Named imports
Pass C6 Named imports
Fail C7 Named imports
Fail C8 Named imports
Fail C9 Named imports
Fail D1 Layer statement with imports
Fail D2 Layer statement with imports
Fail D3 Layer statement with imports
Fail D4 Layer statement with imports
Fail D5 Layer statement with imports
Pass C7 Named imports
Pass C8 Named imports
Pass C9 Named imports
Pass D1 Layer statement with imports
Pass D2 Layer statement with imports
Pass D3 Layer statement with imports
Pass D4 Layer statement with imports
Pass D5 Layer statement with imports
Pass D6 Layer statement with imports
Pass E1 Named imports establish layer even with network errors