From ba633882bf3572b2d3ac1fc66ff38595e5114f08 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Tue, 9 Apr 2024 19:32:46 +0200 Subject: [PATCH] LibWeb: Change load_html_document to run parsing from deferred_invoke() ...callback, otherwise Networking task source will be blocked until the end of HTML parsing. This is a preparation before forbidding to interleave HTML tasks with the same source. --- Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp b/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp index bfa0826db72..73298cb435b 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp +++ b/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include namespace Web { @@ -149,8 +150,10 @@ static WebIDL::ExceptionOr> load_html_document(H else { // FIXME: Parse as we receive the document data, instead of waiting for the whole document to be fetched first. auto process_body = [document, url = navigation_params.response->url().value()](ByteBuffer data) { - auto parser = HTML::HTMLParser::create_with_uncertain_encoding(document, data); - parser->run(url); + Platform::EventLoopPlugin::the().deferred_invoke([document = document, data = move(data), url = url] { + auto parser = HTML::HTMLParser::create_with_uncertain_encoding(document, data); + parser->run(url); + }); }; auto process_body_error = [](auto) {