From 2f345c4ab511a0aadf2dc1f3f5fa2fdf8adbe336 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sun, 21 Apr 2024 15:07:59 +0200 Subject: [PATCH] LibWeb: Use HeapFunction for `update_document` callback --- Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp index ace5553d737..d946a627b44 100644 --- a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp @@ -691,9 +691,9 @@ TraversableNavigable::HistoryStepResult TraversableNavigable::apply_the_history_ // 2. Let updateDocument be an algorithm step which performs update document for history step application given // targetEntry's document, targetEntry, changingNavigableContinuation's update-only, scriptHistoryLength, // scriptHistoryIndex, navigationType, entriesForNavigationAPI, and displayedEntry. - auto update_document = JS::SafeFunction([script_history_length, script_history_index, entries_for_navigation_api = move(entries_for_navigation_api), target_entry, update_only] { + auto update_document = [script_history_length, script_history_index, entries_for_navigation_api = move(entries_for_navigation_api), target_entry, update_only] { target_entry->document()->update_for_history_step_application(*target_entry, update_only, script_history_length, script_history_index, entries_for_navigation_api); - }); + }; // 3. If targetEntry's document is equal to displayedDocument, then perform updateDocument. if (target_entry->document().ptr() == displayed_document.ptr()) { @@ -701,9 +701,7 @@ TraversableNavigable::HistoryStepResult TraversableNavigable::apply_the_history_ } // 5. Otherwise, queue a global task on the navigation and traversal task source given targetEntry's document's relevant global object to perform updateDocument else { - queue_global_task(Task::Source::NavigationAndTraversal, relevant_global_object(*target_entry->document()), JS::create_heap_function(heap, [update_document = move(update_document)]() { - update_document(); - })); + queue_global_task(Task::Source::NavigationAndTraversal, relevant_global_object(*target_entry->document()), JS::create_heap_function(heap, move(update_document))); } // 6. Increment completedChangeJobs.