mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 20:15:00 +00:00
LibWeb: Pass around JS::HeapFunctions when fetching scripts
This patch replaces the use of JS::SafeFunction for the OnFetchScriptComplete in various script fetching functions with JS::HeapFunction. The same applies for callbacks in ModuleMap. This also removes DescendantFetchingContext, which stashed the on complete function in fetch_descendants_of_a_module_script for multiple calls to fetch_internal_module_script_graph previously.
This commit is contained in:
parent
33b40eaeed
commit
5aa7c51956
5 changed files with 83 additions and 87 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, networkException <networkexception@serenityos.org>
|
||||
* Copyright (c) 2022-2023, networkException <networkexception@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <AK/URL.h>
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
#include <LibJS/Heap/HeapFunction.h>
|
||||
#include <LibWeb/HTML/Scripting/ModuleScript.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -52,6 +53,8 @@ public:
|
|||
JS::GCPtr<JavaScriptModuleScript> module_script;
|
||||
};
|
||||
|
||||
using CallbackFunction = JS::NonnullGCPtr<JS::HeapFunction<void(Entry)>>;
|
||||
|
||||
bool is_fetching(AK::URL const& url, DeprecatedString const& type) const;
|
||||
bool is_failed(AK::URL const& url, DeprecatedString const& type) const;
|
||||
|
||||
|
@ -61,13 +64,13 @@ public:
|
|||
|
||||
AK::HashSetResult set(AK::URL const& url, DeprecatedString const& type, Entry);
|
||||
|
||||
void wait_for_change(AK::URL const& url, DeprecatedString const& type, Function<void(Entry)> callback);
|
||||
void wait_for_change(JS::Heap&, AK::URL const& url, DeprecatedString const& type, Function<void(Entry)> callback);
|
||||
|
||||
private:
|
||||
virtual void visit_edges(JS::Cell::Visitor&) override;
|
||||
|
||||
HashMap<ModuleLocationTuple, Entry> m_values;
|
||||
HashMap<ModuleLocationTuple, Vector<Function<void(Entry)>>> m_callbacks;
|
||||
HashMap<ModuleLocationTuple, Vector<CallbackFunction>> m_callbacks;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue