mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 06:18:59 +00:00
LibWeb: Start implementing render-blocking mechanism from HTML spec
This change implements enough spec steps to block rendering until execution of sync scripts inserted from HTML parser is complete.
This commit is contained in:
parent
75168fa4d6
commit
da579e11b0
Notes:
github-actions[bot]
2025-02-05 17:29:43 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: da579e11b0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3455
7 changed files with 99 additions and 3 deletions
|
@ -97,7 +97,8 @@ void HTMLScriptElement::execute_script()
|
|||
return;
|
||||
}
|
||||
|
||||
// FIXME: 3. Unblock rendering on el.
|
||||
// 3. Unblock rendering on el.
|
||||
unblock_rendering();
|
||||
|
||||
// 3. If el's result is null, then fire an event named error at el, and return.
|
||||
if (m_result.has<ResultState::Null>()) {
|
||||
|
@ -393,7 +394,10 @@ void HTMLScriptElement::prepare_script()
|
|||
return;
|
||||
}
|
||||
|
||||
// FIXME: 7. If el is potentially render-blocking, then block rendering on el.
|
||||
// 7. If el is potentially render-blocking, then block rendering on el.
|
||||
if (is_potentially_render_blocking()) {
|
||||
block_rendering();
|
||||
}
|
||||
|
||||
// 8. Set el's delaying the load event to true.
|
||||
begin_delaying_document_load_event(*m_preparation_time_document);
|
||||
|
@ -664,4 +668,11 @@ WebIDL::ExceptionOr<void> HTMLScriptElement::cloned(Node& copy, bool subtree) co
|
|||
return {};
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#implicitly-potentially-render-blocking
|
||||
bool HTMLScriptElement::is_implicitly_potentially_render_blocking() const
|
||||
{
|
||||
// A script element el is implicitly potentially render-blocking if el's type is "classic", el is parser-inserted, and el does not have an async or defer attribute.
|
||||
return m_script_type == ScriptType::Classic && is_parser_inserted() && !has_attribute(AttributeNames::async) && !has_attribute(AttributeNames::defer);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue