summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-02-15 14:11:51 +0100
committerAndreas Kling <kling@serenityos.org>2022-02-15 14:14:02 +0100
commit32b8023ad11434d9e8039cec07b77dcb6ad35913 (patch)
treedb6fb8d4fd51597ffdd1fcd9ef65cc6c6249e471
parent9f02afd8fea1501f262fa03bff56c6fde3a82c6f (diff)
downloadserenity-32b8023ad11434d9e8039cec07b77dcb6ad35913.zip
LibWeb: Don't delay document load event forever with cached style sheets
If we try to <link> a stylesheet that was already cached, we'll get a synchronous resource_did_load() callback. Because of this, it's necessary to set up the document load event delayer *before* calling set_resource(), as otherwise we'd be stuck without a load event forever.
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp
index a67989527d..57518c3a87 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp
@@ -33,8 +33,10 @@ void HTMLLinkElement::inserted()
auto url = document().parse_url(href());
dbgln_if(CSS_LOADER_DEBUG, "HTMLLinkElement: Loading import URL: {}", url);
auto request = LoadRequest::create_for_url_on_page(url, document().page());
- set_resource(ResourceLoader::the().load_resource(Resource::Type::Generic, request));
+ // NOTE: Mark this element as delaying the document load event *before* calling set_resource()
+ // as it may trigger a synchronous resource_did_load() callback.
m_document_load_event_delayer.emplace(document());
+ set_resource(ResourceLoader::the().load_resource(Resource::Type::Generic, request));
}
if (m_relationship & Relationship::Preload) {