LibWeb: Replace spin_until in apply_the_history_step with state machine

Replace the blocking spin_processing_tasks_with_source_until calls
in apply_the_history_step_after_unload_check() with an event-driven
ApplyHistoryStepState GC cell that tracks 5 phases, following the
same pattern used by CheckUnloadingCanceledState.

Key changes:
- Introduce ApplyHistoryStepState with phases:
  WaitingForDocumentPopulation, ProcessingContinuations,
  WaitingForChangeJobCompletion, WaitingForNonChangingJobs and Completed
- Add on_complete callbacks to apply_the_push_or_replace_history_step,
  finalize_a_same_document_navigation,
  finalize_a_cross_document_navigation, and
  update_for_navigable_creation_or_destruction
- Remove spin_until from Document::open()
- Use null-document tasks for non-changing navigable updates and
  document unload/destroy to avoid stuck tasks when documents become
  non-fully-active
- Defer completely_finish_loading when document has no navigable yet,
  and re-trigger post-load steps in activate_history_entry for documents
  that completed loading before activation

Co-Authored-By: Shannon Booth <shannon@serenityos.org>
This commit is contained in:
Aliaksandr Kalenik
2026-03-29 12:06:39 +02:00
committed by Alexander Kalenik
parent b36f2361f1
commit 2a69fd4c52
Notes: github-actions[bot] 2026-03-31 07:49:17 +00:00
18 changed files with 613 additions and 438 deletions

View File

@@ -443,7 +443,6 @@ void HTMLObjectElement::run_object_representation_handler_steps(Fetch::Infrastru
// If the object element's content navigable is null, then create a new child navigable for the element.
if (!m_content_navigable && in_a_document_tree()) {
MUST(create_new_child_navigable());
set_content_navigable_has_session_history_entry_and_ready_for_navigation();
}
// NOTE: Creating a new nested browsing context can fail if the document is not attached to a browsing context