LibWeb: Block rendering until linked stylesheets are loaded

This commit implements the main "render blocking" behavior for link
elements, drastically reducing the amount of FOUC (flash of unstyled
content) we subject our users to.

The document will now block rendering until linked style sheets
referenced by parser-created link elements have loaded (or failed).

Note that we don't yet extend the blocking period until "critical
subresources" such as imported style sheets have been downloaded
as well.
This commit is contained in:
Andreas Kling 2025-02-27 15:30:26 +01:00 committed by Andreas Kling
commit 043e96946f
Notes: github-actions[bot] 2025-02-27 20:37:32 +00:00
5 changed files with 52 additions and 8 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2023, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2018-2025, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2023-2024, Shannon Booth <shannon@serenityos.org>
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
@ -813,6 +813,8 @@ public:
// https://html.spec.whatwg.org/multipage/dom.html#allows-adding-render-blocking-elements
[[nodiscard]] bool allows_adding_render_blocking_elements() const;
[[nodiscard]] bool is_render_blocking_element(GC::Ref<Element>) const;
void add_render_blocking_element(GC::Ref<Element>);
void remove_render_blocking_element(GC::Ref<Element>);