mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
LibWeb: Remove some uses of [&] lambda captures for queued tasks
Using a default reference capture for these kinds of tasks is dangerous and prone to error. Some of the variables should for sure be captured by value so that we can keep a GC object alive rather than trying to refer to stack objects.
This commit is contained in:
parent
6ed2bf2bb1
commit
66519af43f
Notes:
github-actions[bot]
2024-12-10 06:14:03 +00:00
Author: https://github.com/ADKaster
Commit: 66519af43f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2860
4 changed files with 10 additions and 10 deletions
|
@ -298,7 +298,7 @@ void HTMLParser::the_end(GC::Ref<DOM::Document> document, GC::Ptr<HTMLParser> pa
|
|||
while (!document->scripts_to_execute_when_parsing_has_finished().is_empty()) {
|
||||
// 1. Spin the event loop until the first script in the list of scripts that will execute when the document has finished parsing
|
||||
// has its "ready to be parser-executed" flag set and the parser's Document has no style sheet that is blocking scripts.
|
||||
main_thread_event_loop().spin_until(GC::create_function(heap, [&] {
|
||||
main_thread_event_loop().spin_until(GC::create_function(heap, [document] {
|
||||
return document->scripts_to_execute_when_parsing_has_finished().first()->is_ready_to_be_parser_executed()
|
||||
&& !document->has_a_style_sheet_that_is_blocking_scripts();
|
||||
}));
|
||||
|
@ -311,7 +311,7 @@ void HTMLParser::the_end(GC::Ref<DOM::Document> document, GC::Ptr<HTMLParser> pa
|
|||
}
|
||||
|
||||
// 6. Queue a global task on the DOM manipulation task source given the Document's relevant global object to run the following substeps:
|
||||
queue_global_task(HTML::Task::Source::DOMManipulation, *document, GC::create_function(heap, [document = document] {
|
||||
queue_global_task(HTML::Task::Source::DOMManipulation, *document, GC::create_function(heap, [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::current_high_resolution_time(relevant_global_object(*document));
|
||||
|
||||
|
@ -329,17 +329,17 @@ void HTMLParser::the_end(GC::Ref<DOM::Document> document, GC::Ptr<HTMLParser> pa
|
|||
}));
|
||||
|
||||
// 7. Spin the event loop until the set of scripts that will execute as soon as possible and the list of scripts that will execute in order as soon as possible are empty.
|
||||
main_thread_event_loop().spin_until(GC::create_function(heap, [&] {
|
||||
main_thread_event_loop().spin_until(GC::create_function(heap, [document] {
|
||||
return document->scripts_to_execute_as_soon_as_possible().is_empty();
|
||||
}));
|
||||
|
||||
// 8. Spin the event loop until there is nothing that delays the load event in the Document.
|
||||
main_thread_event_loop().spin_until(GC::create_function(heap, [&] {
|
||||
main_thread_event_loop().spin_until(GC::create_function(heap, [document] {
|
||||
return !document->anything_is_delaying_the_load_event();
|
||||
}));
|
||||
|
||||
// 9. Queue a global task on the DOM manipulation task source given the Document's relevant global object to run the following steps:
|
||||
queue_global_task(HTML::Task::Source::DOMManipulation, *document, GC::create_function(document->heap(), [document = document] {
|
||||
queue_global_task(HTML::Task::Source::DOMManipulation, *document, GC::create_function(document->heap(), [document] {
|
||||
// 1. Update the current document readiness to "complete".
|
||||
document->update_readiness(HTML::DocumentReadyState::Complete);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue