LibWeb: Spin the event loop in HTML parser until scripts can run

Call HTML::EventLoop::spin_until() from the HTML parser when deciding
whether we can run a script yet.

Note that spin_until() actually doesn't do any work yet.
This commit is contained in:
Andreas Kling 2021-09-09 02:15:44 +02:00
parent c759055c08
commit 882c7b1295
Notes: sideshowbarker 2024-07-18 04:24:09 +09:00

View File

@ -15,6 +15,7 @@
#include <LibWeb/DOM/Event.h>
#include <LibWeb/DOM/Text.h>
#include <LibWeb/DOM/Window.h>
#include <LibWeb/HTML/EventLoop/EventLoop.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/HTML/HTMLFormElement.h>
#include <LibWeb/HTML/HTMLHeadElement.h>
@ -1907,11 +1908,16 @@ void HTMLDocumentParser::handle_text(HTMLToken& token)
auto the_script = document().take_pending_parsing_blocking_script({});
m_tokenizer.set_blocked(true);
// FIXME: If the parser's Document has a style sheet that is blocking scripts
// or the script's "ready to be parser-executed" flag is not set:
// spin the event loop until the parser's Document has no style sheet
// that is blocking scripts and the script's "ready to be parser-executed"
// flag is set.
// If the parser's Document has a style sheet that is blocking scripts
// or the script's "ready to be parser-executed" flag is not set:
// spin the event loop until the parser's Document has no style sheet
// that is blocking scripts and the script's "ready to be parser-executed"
// flag is set.
if (m_document->has_a_style_sheet_that_is_blocking_scripts() || !script->is_ready_to_be_parser_executed()) {
main_thread_event_loop().spin_until([&] {
return !m_document->has_a_style_sheet_that_is_blocking_scripts() && script->is_ready_to_be_parser_executed();
});
}
if (the_script->failed_to_load())
return;