LibWeb: Handle two kinds of deferred script executions

This patch adds two script lists to Document:

- Scripts to execute when parsing has finished
- Scripts to execute as soon as possible

Since we don't actually load scripts asynchronously yet (we just do a
synchronous load when parsing the <script> element for simplicity),
these are already loaded by the time we get to "The end" of parsing.
This commit is contained in:
Andreas Kling 2020-05-30 12:26:15 +02:00
parent 6f85422e8a
commit e82226f3fb
Notes: sideshowbarker 2024-07-19 05:57:26 +09:00
4 changed files with 41 additions and 6 deletions

View file

@ -80,7 +80,17 @@ void HTMLDocumentParser::run(const URL& url)
// "The end"
auto scripts_to_execute_when_parsing_has_finished = m_document->take_scripts_to_execute_when_parsing_has_finished({});
for (auto& script : scripts_to_execute_when_parsing_has_finished) {
script.execute_script();
}
m_document->dispatch_event(Event::create("DOMContentLoaded"));
auto scripts_to_execute_as_soon_as_possible = m_document->take_scripts_to_execute_as_soon_as_possible({});
for (auto& script : scripts_to_execute_as_soon_as_possible) {
script.execute_script();
}
}
void HTMLDocumentParser::process_using_the_rules_for(InsertionMode mode, HTMLToken& token)