mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-19 07:33:20 +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
|
@ -499,7 +499,8 @@ public:
|
|||
|
||||
String dump_dom_tree_as_json() const;
|
||||
|
||||
bool has_a_style_sheet_that_is_blocking_scripts() const;
|
||||
[[nodiscard]] bool has_a_style_sheet_that_is_blocking_scripts() const;
|
||||
[[nodiscard]] bool has_no_style_sheet_that_is_blocking_scripts() const;
|
||||
|
||||
bool is_fully_active() const;
|
||||
bool is_active() const;
|
||||
|
@ -897,6 +898,9 @@ public:
|
|||
|
||||
ElementByIdMap& element_by_id() const;
|
||||
|
||||
auto& script_blocking_style_sheet_set() { return m_script_blocking_style_sheet_set; }
|
||||
auto const& script_blocking_style_sheet_set() const { return m_script_blocking_style_sheet_set; }
|
||||
|
||||
protected:
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
@ -1030,8 +1034,8 @@ private:
|
|||
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#throw-on-dynamic-markup-insertion-counter
|
||||
u32 m_throw_on_dynamic_markup_insertion_counter { 0 };
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/semantics.html#script-blocking-style-sheet-counter
|
||||
u32 m_script_blocking_style_sheet_counter { 0 };
|
||||
// https://html.spec.whatwg.org/multipage/semantics.html#script-blocking-style-sheet-set
|
||||
HashTable<GC::Ref<DOM::Element>> m_script_blocking_style_sheet_set;
|
||||
|
||||
GC::Ptr<HTML::History> m_history;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue