mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
LibWeb: Implement "Document has a style sheet that is blocking scripts"
This will be used by the HTML parser to determine whether it's okay to start running a script. Note that we don't actually count the script-blocking style sheets yet. This patch only adds a the checking mechanism for the parser.
This commit is contained in:
parent
71d7c8a353
commit
c759055c08
2 changed files with 19 additions and 0 deletions
|
@ -948,4 +948,18 @@ String Document::dump_dom_tree_as_json() const
|
||||||
return builder.to_string();
|
return builder.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/semantics.html#has-a-style-sheet-that-is-blocking-scripts
|
||||||
|
bool Document::has_a_style_sheet_that_is_blocking_scripts() const
|
||||||
|
{
|
||||||
|
// A Document has a style sheet that is blocking scripts if its script-blocking style sheet counter is greater than 0,
|
||||||
|
if (m_script_blocking_style_sheet_counter > 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// ...or if that Document has a non-null browsing context whose container document is non-null and has a script-blocking style sheet counter greater than 0.
|
||||||
|
if (!browsing_context() || !browsing_context()->container_document())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return browsing_context()->container_document()->m_script_blocking_style_sheet_counter > 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,6 +270,8 @@ public:
|
||||||
|
|
||||||
String dump_dom_tree_as_json() const;
|
String dump_dom_tree_as_json() const;
|
||||||
|
|
||||||
|
bool has_a_style_sheet_that_is_blocking_scripts() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Document(const URL&);
|
explicit Document(const URL&);
|
||||||
|
|
||||||
|
@ -347,6 +349,9 @@ private:
|
||||||
bool m_should_invalidate_styles_on_attribute_changes { true };
|
bool m_should_invalidate_styles_on_attribute_changes { true };
|
||||||
|
|
||||||
u32 m_ignore_destructive_writes_counter { 0 };
|
u32 m_ignore_destructive_writes_counter { 0 };
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/semantics.html#script-blocking-style-sheet-counter
|
||||||
|
u32 m_script_blocking_style_sheet_counter { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue