LibWeb: Implement more of the "script-blocking style sheet" mechanism

The basic idea is that style sheets can block script execution under
some circumstances. With this commit, we now handle the simplest cases
where a parser-inserted link element gets to download its style sheet
before script execution continues.

This improves performance on Speedometer 3 where JavaScript APIs that
depend on layout results (like Element.scrollIntoView()) would get
called too early (before the relevant CSS was downloaded), and so we'd
perform premature layout work. This work then had to be redone after
downloading the CSS anyway, wasting time.

Note that our Text/input/link-re-enable-crash.html test had to be
tweaked after these changes, since it relied on the old, incorrect,
behavior where scripts would run before downloading CSS.
This commit is contained in:
Andreas Kling 2025-04-20 11:31:57 +02:00 committed by Andreas Kling
parent 8e37cd2f71
commit 0c0650e60a
Notes: github-actions[bot] 2025-04-20 12:55:15 +00:00
9 changed files with 101 additions and 18 deletions

View file

@ -30,6 +30,8 @@ public:
CSS::CSSStyleSheet* sheet();
CSS::CSSStyleSheet const* sheet() const;
virtual bool contributes_a_script_blocking_style_sheet() const final;
private:
HTMLStyleElement(DOM::Document&, DOM::QualifiedName);