mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
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:
parent
8e37cd2f71
commit
0c0650e60a
Notes:
github-actions[bot]
2025-04-20 12:55:15 +00:00
Author: https://github.com/awesomekling
Commit: 0c0650e60a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4407
9 changed files with 101 additions and 18 deletions
|
@ -103,4 +103,27 @@ CSS::CSSStyleSheet const* HTMLStyleElement::sheet() const
|
|||
return m_style_element_utils.sheet();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/semantics.html#contributes-a-script-blocking-style-sheet
|
||||
bool HTMLStyleElement::contributes_a_script_blocking_style_sheet() const
|
||||
{
|
||||
// An element el in the context of a Document of an HTML parser or XML parser
|
||||
// contributes a script-blocking style sheet if all of the following are true:
|
||||
|
||||
// FIXME: el was created by that Document's parser.
|
||||
|
||||
// el is either a style element or a link element that was an external resource link that contributes to the styling processing model when the el was created by the parser.
|
||||
// NOTE: This is a style element, so all good!
|
||||
|
||||
// FIXME: el's media attribute's value matches the environment.
|
||||
|
||||
// FIXME: el's style sheet was enabled when the element was created by the parser.
|
||||
|
||||
// FIXME: The last time the event loop reached step 1, el's root was that Document.
|
||||
|
||||
// FIXME: The user agent hasn't given up on loading that particular style sheet yet.
|
||||
// A user agent may give up on loading a style sheet at any time.
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue