1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 04:57:44 +00:00

Everywhere: Remove unnecessary mutable attributes from lambdas

These lambdas were marked mutable as they captured a Ptr wrapper
class by value, which then only returned const-qualified references
to the value they point from the previous const pointer operators.

Nothing is actually mutating in the lambdas state here, and now
that the Ptr operators don't add extra const qualifiers these
can be removed.
This commit is contained in:
MacDue 2022-11-19 01:09:53 +00:00 committed by Linus Groh
parent 66a428ae03
commit 8a5d2be617
30 changed files with 68 additions and 68 deletions

View file

@ -1142,7 +1142,7 @@ WebIDL::ExceptionOr<void> BrowsingContext::traverse_the_history(size_t entry_ind
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]() mutable {
queue_global_task(Task::Source::DOMManipulation, relevant_global_object(*new_document), [new_document] {
// 1. If newDocument's page showing flag is true, then abort these steps.
if (new_document->page_showing())
return;
@ -1211,7 +1211,7 @@ WebIDL::ExceptionOr<void> BrowsingContext::traverse_the_history(size_t entry_ind
// 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]() mutable {
queue_global_task(Task::Source::DOMManipulation, relevant_global_object(*new_document), [new_document] {
// 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.
@ -1330,7 +1330,7 @@ void BrowsingContext::set_system_visibility_state(VisibilityState visibility_sta
// has changed to newState, it must queue a task on the user interaction task source to update
// the visibility state of all the Document objects in the top-level browsing context's document family with newState.
auto document_family = top_level_browsing_context().document_family();
queue_global_task(Task::Source::UserInteraction, Bindings::main_thread_vm().current_realm()->global_object(), [visibility_state, document_family = move(document_family)]() mutable {
queue_global_task(Task::Source::UserInteraction, Bindings::main_thread_vm().current_realm()->global_object(), [visibility_state, document_family = move(document_family)] {
for (auto& document : document_family) {
document->update_the_visibility_state(visibility_state);
}

View file

@ -103,7 +103,7 @@ void FormAssociatedElement::reset_form_owner()
if (is_listed() && html_element.has_attribute(HTML::AttributeNames::form) && html_element.is_connected()) {
// 1. If the first element in element's tree, in tree order, to have an ID that is identical to element's form content attribute's value, is a form element, then associate the element with that form element.
auto form_value = html_element.attribute(HTML::AttributeNames::form);
html_element.root().for_each_in_inclusive_subtree_of_type<HTMLFormElement>([this, &form_value](HTMLFormElement& form_element) mutable {
html_element.root().for_each_in_inclusive_subtree_of_type<HTMLFormElement>([this, &form_value](HTMLFormElement& form_element) {
if (form_element.attribute(HTML::AttributeNames::id) == form_value) {
set_form(&form_element);
return IterationDecision::Break;

View file

@ -534,7 +534,7 @@ void HTMLHyperlinkElementUtils::follow_the_hyperlink(Optional<String> hyperlink_
// set to source.
// FIXME: "navigate" means implementing the navigation algorithm here:
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate
hyperlink_element_utils_queue_an_element_task(Task::Source::DOMManipulation, [url_string, target]() mutable {
hyperlink_element_utils_queue_an_element_task(Task::Source::DOMManipulation, [url_string, target] {
target->loader().load(url_string, FrameLoader::Type::Navigation);
});
}

View file

@ -123,7 +123,7 @@ void HTMLInputElement::set_files(JS::GCPtr<FileAPI::FileList> files)
void HTMLInputElement::update_the_file_selection(JS::NonnullGCPtr<FileAPI::FileList> files)
{
// 1. Queue an element task on the user interaction task source given element and the following steps:
queue_an_element_task(Task::Source::UserInteraction, [this, files]() mutable {
queue_an_element_task(Task::Source::UserInteraction, [this, files] {
// 1. Update element's selected files so that it represents the user's selection.
this->set_files(files.ptr());

View file

@ -88,7 +88,7 @@ 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, [target_port, message]() mutable {
main_thread_event_loop().task_queue().add(HTML::Task::create(HTML::Task::Source::PostedMessage, nullptr, [target_port, message] {
MessageEventInit event_init {};
event_init.data = message;
event_init.origin = "<origin>";

View file

@ -250,7 +250,7 @@ void HTMLParser::the_end()
}
// 6. 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 = m_document]() mutable {
old_queue_global_task_with_document(HTML::Task::Source::DOMManipulation, *m_document, [document = m_document] {
// 1. 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 = HighResolutionTime::unsafe_shared_current_time();
@ -279,7 +279,7 @@ void HTMLParser::the_end()
});
// 9. 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 = m_document]() mutable {
old_queue_global_task_with_document(HTML::Task::Source::DOMManipulation, *m_document, [document = m_document] {
// 1. Update the current document readiness to "complete".
document->update_readiness(HTML::DocumentReadyState::Complete);

View file

@ -228,7 +228,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, list = move(list)]() mutable {
queue_global_task(Task::Source::DOMManipulation, global, [this, &global, list = move(list)] {
// 1. For each promise p in list:
for (auto promise : list) {

View file

@ -495,7 +495,7 @@ i32 Window::run_timer_initialization_steps(TimerHandler handler, i32 timeout, JS
// 8. Assert: initiating script is not null, since this algorithm is always called from some script.
// 9. Let task be a task that runs the following substeps:
JS::SafeFunction<void()> task = [this, handler = move(handler), timeout, arguments = move(arguments), repeat, id]() mutable {
JS::SafeFunction<void()> task = [this, handler = move(handler), timeout, arguments = move(arguments), repeat, id] {
// 1. If id does not exist in global's map of active timers, then abort these steps.
if (!m_timers.contains(id))
return;
@ -564,7 +564,7 @@ i32 Window::run_timer_initialization_steps(TimerHandler handler, i32 timeout, JS
// https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#run-the-animation-frame-callbacks
i32 Window::request_animation_frame_impl(WebIDL::CallbackType& js_callback)
{
return m_animation_frame_callback_driver.add([this, js_callback = JS::make_handle(js_callback)](auto) mutable {
return m_animation_frame_callback_driver.add([this, js_callback = JS::make_handle(js_callback)](auto) {
// 3. Invoke callback, passing now as the only argument,
auto result = WebIDL::invoke_callback(*js_callback, {}, JS::Value(performance().now()));
@ -802,7 +802,7 @@ void Window::fire_a_page_transition_event(FlyString const& event_name, bool pers
void Window::queue_microtask_impl(WebIDL::CallbackType& callback)
{
// The queueMicrotask(callback) method must queue a microtask to invoke callback,
HTML::queue_a_microtask(&associated_document(), [this, &callback]() mutable {
HTML::queue_a_microtask(&associated_document(), [this, &callback] {
auto result = WebIDL::invoke_callback(callback, {});
// and if callback throws an exception, report the exception.
if (result.is_error())
@ -906,7 +906,7 @@ WebIDL::ExceptionOr<void> Window::post_message_impl(JS::Value message, String co
{
// 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, [this, message]() mutable {
HTML::queue_global_task(HTML::Task::Source::PostedMessage, *this, [this, message] {
HTML::MessageEventInit event_init {};
event_init.data = message;
event_init.origin = "<origin>";
@ -961,7 +961,7 @@ 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, [this]() mutable {
HTML::queue_global_task(HTML::Task::Source::IdleTask, *this, [this] {
invoke_idle_callbacks();
});
}
@ -985,7 +985,7 @@ void Window::invoke_idle_callbacks()
HTML::report_exception(result, realm());
// 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, [this]() mutable {
HTML::queue_global_task(HTML::Task::Source::IdleTask, *this, [this] {
invoke_idle_callbacks();
});
}

View file

@ -154,7 +154,7 @@ void Worker::run_a_worker(AK::URL& url, EnvironmentSettingsObject& outside_setti
auto& event_loop = get_vm_event_loop(m_document->realm().vm());
event_loop.task_queue().add(HTML::Task::create(HTML::Task::Source::PostedMessage, nullptr, [this, message]() mutable {
event_loop.task_queue().add(HTML::Task::create(HTML::Task::Source::PostedMessage, nullptr, [this, message] {
MessageEventInit event_init {};
event_init.data = message;
event_init.origin = "<origin>";