diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-09 02:15:44 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-09 02:30:54 +0200 |
commit | 882c7b12959788b9ac40bf5641a7b50d0844a428 (patch) | |
tree | 5a5a26905dd41cb926044519e6147be739746c48 /Userland | |
parent | c759055c08bb67307f7cb0e2596a9323ffd6a205 (diff) | |
download | serenity-882c7b12959788b9ac40bf5641a7b50d0844a428.zip |
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.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp index c18e3a8af4..1d690dc92e 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp @@ -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; |