mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 16:04:59 +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
|
@ -11,9 +11,12 @@ namespace Web::HTML {
|
|||
void ModuleMap::visit_edges(Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
for (auto& it : m_values) {
|
||||
for (auto& it : m_values)
|
||||
visitor.visit(it.value.module_script);
|
||||
}
|
||||
|
||||
for (auto const& it : m_callbacks)
|
||||
for (auto const& callback : it.value)
|
||||
visitor.visit(callback);
|
||||
}
|
||||
|
||||
bool ModuleMap::is_fetching(AK::URL const& url, DeprecatedString const& type) const
|
||||
|
@ -47,14 +50,14 @@ AK::HashSetResult ModuleMap::set(AK::URL const& url, DeprecatedString const& typ
|
|||
auto callbacks = m_callbacks.get({ url, type });
|
||||
if (callbacks.has_value())
|
||||
for (auto const& callback : *callbacks)
|
||||
callback(entry);
|
||||
callback->function()(entry);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void ModuleMap::wait_for_change(AK::URL const& url, DeprecatedString const& type, Function<void(Entry)> callback)
|
||||
void ModuleMap::wait_for_change(JS::Heap& heap, AK::URL const& url, DeprecatedString const& type, Function<void(Entry)> callback)
|
||||
{
|
||||
m_callbacks.ensure({ url, type }).append(move(callback));
|
||||
m_callbacks.ensure({ url, type }).append(JS::create_heap_function(heap, move(callback)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue