diff options
author | Andreas Kling <kling@serenityos.org> | 2022-02-15 14:10:16 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-15 14:14:02 +0100 |
commit | 9f02afd8fea1501f262fa03bff56c6fde3a82c6f (patch) | |
tree | a00f2cf6c7262944975fa1474afea37ef21b654b | |
parent | 4708a65160f913e46efdf263d371723280a9c7d3 (diff) | |
download | serenity-9f02afd8fea1501f262fa03bff56c6fde3a82c6f.zip |
LibWeb: Don't delay document load event forever with cached CSS imports
If we try to @import 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/CSS/CSSImportRule.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp index 5d0239be13..652bb316c1 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp @@ -20,8 +20,12 @@ CSSImportRule::CSSImportRule(AK::URL url, DOM::Document& document) { dbgln_if(CSS_LOADER_DEBUG, "CSSImportRule: Loading import URL: {}", m_url); auto request = LoadRequest::create_for_url_on_page(m_url, document.page()); - set_resource(ResourceLoader::the().load_resource(Resource::Type::Generic, request)); + + // NOTE: Mark this rule 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)); } CSSImportRule::~CSSImportRule() |