mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 14:25:06 +00:00
LibWeb: Remove now-unnecessary JS::Handles in HTML task capture lists
JS::SafeFunction will protect anything captures for HTML tasks now.
This commit is contained in:
parent
d505192014
commit
2ccb9bef49
6 changed files with 22 additions and 22 deletions
|
@ -124,14 +124,14 @@ JS::VM& main_thread_vm()
|
|||
|
||||
// 5. Queue a global task on the DOM manipulation task source given global to fire an event named rejectionhandled at global, using PromiseRejectionEvent,
|
||||
// with the promise attribute initialized to promise, and the reason attribute initialized to the value of promise's [[PromiseResult]] internal slot.
|
||||
HTML::queue_global_task(HTML::Task::Source::DOMManipulation, global, [global = JS::make_handle(&global), promise = JS::make_handle(&promise)]() mutable {
|
||||
HTML::queue_global_task(HTML::Task::Source::DOMManipulation, global, [&global, &promise]() mutable {
|
||||
// FIXME: This currently assumes that global is a WindowObject.
|
||||
auto& window = verify_cast<HTML::Window>(*global.cell());
|
||||
auto& window = verify_cast<HTML::Window>(global);
|
||||
|
||||
HTML::PromiseRejectionEventInit event_init {
|
||||
{}, // Initialize the inherited DOM::EventInit
|
||||
/* .promise = */ promise,
|
||||
/* .reason = */ promise.cell()->result(),
|
||||
/* .reason = */ promise.result(),
|
||||
};
|
||||
auto promise_rejection_event = HTML::PromiseRejectionEvent::create(window, HTML::EventNames::rejectionhandled, event_init);
|
||||
window.dispatch_event(*promise_rejection_event);
|
||||
|
@ -179,9 +179,9 @@ JS::VM& main_thread_vm()
|
|||
auto& global = finalization_registry.realm().global_object();
|
||||
|
||||
// 2. Queue a global task on the JavaScript engine task source given global to perform the following steps:
|
||||
HTML::queue_global_task(HTML::Task::Source::JavaScriptEngine, global, [finalization_registry = JS::make_handle(&finalization_registry)]() mutable {
|
||||
HTML::queue_global_task(HTML::Task::Source::JavaScriptEngine, global, [&finalization_registry]() mutable {
|
||||
// 1. Let entry be finalizationRegistry.[[CleanupCallback]].[[Callback]].[[Realm]]'s environment settings object.
|
||||
auto& entry = verify_cast<HTML::EnvironmentSettingsObject>(*finalization_registry.cell()->cleanup_callback().callback.cell()->realm()->host_defined());
|
||||
auto& entry = verify_cast<HTML::EnvironmentSettingsObject>(*finalization_registry.cleanup_callback().callback.cell()->realm()->host_defined());
|
||||
|
||||
// 2. Check if we can run script with entry. If this returns "do not run", then return.
|
||||
if (entry.can_run_script() == HTML::RunScriptDecision::DoNotRun)
|
||||
|
@ -191,7 +191,7 @@ JS::VM& main_thread_vm()
|
|||
entry.prepare_to_run_script();
|
||||
|
||||
// 4. Let result be the result of performing CleanupFinalizationRegistry(finalizationRegistry).
|
||||
auto result = finalization_registry.cell()->cleanup();
|
||||
auto result = finalization_registry.cleanup();
|
||||
|
||||
// 5. Clean up after running script with entry.
|
||||
entry.clean_up_after_running_script();
|
||||
|
|
|
@ -1105,7 +1105,7 @@ DOM::ExceptionOr<void> BrowsingContext::traverse_the_history(size_t entry_index,
|
|||
if (new_document->ready_state() == "complete"sv) {
|
||||
// then queue a global task on the DOM manipulation task source given newDocument's relevant global object to run the following steps:
|
||||
|
||||
queue_global_task(Task::Source::DOMManipulation, relevant_global_object(*new_document), [new_document = JS::make_handle(*new_document)]() mutable {
|
||||
queue_global_task(Task::Source::DOMManipulation, relevant_global_object(*new_document), [new_document]() mutable {
|
||||
// 1. If newDocument's page showing flag is true, then abort these steps.
|
||||
if (new_document->page_showing())
|
||||
return;
|
||||
|
@ -1174,7 +1174,7 @@ DOM::ExceptionOr<void> BrowsingContext::traverse_the_history(size_t entry_index,
|
|||
// 20. If hashChanged is true,
|
||||
if (hash_changed) {
|
||||
// then queue a global task on the DOM manipulation task source given newDocument's relevant global object
|
||||
queue_global_task(Task::Source::DOMManipulation, relevant_global_object(*new_document), [new_document = JS::make_handle(*new_document)]() mutable {
|
||||
queue_global_task(Task::Source::DOMManipulation, relevant_global_object(*new_document), [new_document]() mutable {
|
||||
// to fire an event named hashchange at newDocument's relevant global object,
|
||||
// using HashChangeEvent, with the oldURL attribute initialized to oldURL
|
||||
// and the newURL attribute initialized to newURL.
|
||||
|
|
|
@ -87,11 +87,11 @@ void MessagePort::post_message(JS::Value message)
|
|||
|
||||
// FIXME: This is an ad-hoc hack implementation instead, since we don't currently
|
||||
// have serialization and deserialization of messages.
|
||||
main_thread_event_loop().task_queue().add(HTML::Task::create(HTML::Task::Source::PostedMessage, nullptr, [strong_port = JS::make_handle(*target_port), strong_message = JS::make_handle(message)]() mutable {
|
||||
main_thread_event_loop().task_queue().add(HTML::Task::create(HTML::Task::Source::PostedMessage, nullptr, [target_port, message]() mutable {
|
||||
MessageEventInit event_init {};
|
||||
event_init.data = strong_message.value();
|
||||
event_init.data = message;
|
||||
event_init.origin = "<origin>";
|
||||
strong_port->dispatch_event(*MessageEvent::create(verify_cast<HTML::Window>(strong_port->realm().global_object()), HTML::EventNames::message, event_init));
|
||||
target_port->dispatch_event(*MessageEvent::create(verify_cast<HTML::Window>(target_port->realm().global_object()), HTML::EventNames::message, event_init));
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -195,7 +195,7 @@ void EnvironmentSettingsObject::notify_about_rejected_promises(Badge<EventLoop>)
|
|||
auto& global = global_object();
|
||||
|
||||
// 5. Queue a global task on the DOM manipulation task source given global to run the following substep:
|
||||
queue_global_task(Task::Source::DOMManipulation, global, [this, global = JS::make_handle(&global), list = move(list)]() mutable {
|
||||
queue_global_task(Task::Source::DOMManipulation, global, [this, &global, list = move(list)]() mutable {
|
||||
// 1. For each promise p in list:
|
||||
for (auto promise_handle : list) {
|
||||
auto& promise = *promise_handle.cell();
|
||||
|
@ -217,7 +217,7 @@ void EnvironmentSettingsObject::notify_about_rejected_promises(Badge<EventLoop>)
|
|||
/* .reason = */ promise.result(),
|
||||
};
|
||||
// FIXME: This currently assumes that global is a WindowObject.
|
||||
auto& window = verify_cast<HTML::Window>(*global.cell());
|
||||
auto& window = verify_cast<HTML::Window>(global);
|
||||
|
||||
auto promise_rejection_event = PromiseRejectionEvent::create(window, HTML::EventNames::unhandledrejection, event_init);
|
||||
|
||||
|
|
|
@ -600,11 +600,11 @@ DOM::ExceptionOr<void> Window::post_message_impl(JS::Value message, String const
|
|||
{
|
||||
// FIXME: This is an ad-hoc hack implementation instead, since we don't currently
|
||||
// have serialization and deserialization of messages.
|
||||
HTML::queue_global_task(HTML::Task::Source::PostedMessage, *this, [strong_this = JS::make_handle(*this), strong_message = JS::make_handle(message)]() mutable {
|
||||
HTML::queue_global_task(HTML::Task::Source::PostedMessage, *this, [this, message]() mutable {
|
||||
HTML::MessageEventInit event_init {};
|
||||
event_init.data = strong_message.value();
|
||||
event_init.data = message;
|
||||
event_init.origin = "<origin>";
|
||||
strong_this->dispatch_event(*HTML::MessageEvent::create(*strong_this, HTML::EventNames::message, event_init));
|
||||
dispatch_event(*HTML::MessageEvent::create(*this, HTML::EventNames::message, event_init));
|
||||
});
|
||||
return {};
|
||||
}
|
||||
|
@ -655,8 +655,8 @@ void Window::start_an_idle_period()
|
|||
|
||||
// 5. Queue a task on the queue associated with the idle-task task source,
|
||||
// which performs the steps defined in the invoke idle callbacks algorithm with window and getDeadline as parameters.
|
||||
HTML::queue_global_task(HTML::Task::Source::IdleTask, *this, [window = JS::make_handle(*this)]() mutable {
|
||||
window->invoke_idle_callbacks();
|
||||
HTML::queue_global_task(HTML::Task::Source::IdleTask, *this, [this]() mutable {
|
||||
invoke_idle_callbacks();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -679,8 +679,8 @@ void Window::invoke_idle_callbacks()
|
|||
HTML::report_exception(result);
|
||||
// 4. If window's list of runnable idle callbacks is not empty, queue a task which performs the steps
|
||||
// in the invoke idle callbacks algorithm with getDeadline and window as a parameters and return from this algorithm
|
||||
HTML::queue_global_task(HTML::Task::Source::IdleTask, *this, [window = JS::make_handle(*this)]() mutable {
|
||||
window->invoke_idle_callbacks();
|
||||
HTML::queue_global_task(HTML::Task::Source::IdleTask, *this, [this]() mutable {
|
||||
invoke_idle_callbacks();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ void XMLDocumentBuilder::document_end()
|
|||
(void)m_document.scripts_to_execute_when_parsing_has_finished().take_first();
|
||||
}
|
||||
// Queue a global task on the DOM manipulation task source given the Document's relevant global object to run the following substeps:
|
||||
old_queue_global_task_with_document(HTML::Task::Source::DOMManipulation, m_document, [document = JS::make_handle(m_document)]() mutable {
|
||||
old_queue_global_task_with_document(HTML::Task::Source::DOMManipulation, m_document, [document = &m_document]() mutable {
|
||||
// Set the Document's load timing info's DOM content loaded event start time to the current high resolution time given the Document's relevant global object.
|
||||
document->load_timing_info().dom_content_loaded_event_start_time = HTML::main_thread_event_loop().unsafe_shared_current_time();
|
||||
|
||||
|
@ -200,7 +200,7 @@ void XMLDocumentBuilder::document_end()
|
|||
});
|
||||
|
||||
// Queue a global task on the DOM manipulation task source given the Document's relevant global object to run the following steps:
|
||||
old_queue_global_task_with_document(HTML::Task::Source::DOMManipulation, m_document, [document = JS::make_handle(m_document)]() mutable {
|
||||
old_queue_global_task_with_document(HTML::Task::Source::DOMManipulation, m_document, [document = &m_document]() mutable {
|
||||
// Update the current document readiness to "complete".
|
||||
document->update_readiness(HTML::DocumentReadyState::Complete);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue