mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-14 19:06:35 +02:00
Previously, populate_session_history_entry_document() took a SessionHistoryEntry as both input and output — reading URL and document_state fields while also mutating the entry across a chain of async functions. This made it very hard to reason about data flow. Refactor the internal helpers (create_navigation_params_from_a_srcdoc_resource, create_navigation_params_by_fetching, NavigationParamsFetchStateHolder, perform_navigation_params_fetch) to take individual field values instead of reading from the entry, and accumulate redirect mutations on the state holder rather than writing them to the entry immediately. Introduce PopulateSessionHistoryEntryDocumentOutput, a GC cell that collects all mutations (document, redirect URL, classic history API state, replacement document state, resource cleared flag, and finalization data). The completion_steps callback now receives this output object (or nullptr on cancellation), and callers apply it to the entry via apply_to(). The replacement DocumentState for the redirect path is built eagerly at redirect time from values captured on the state holder, making apply_to() fully self-contained — it never reads from the target entry's live document_state. This is important for the traversal path where the entry may be mutated during unload (e.g. window.name writes navigable_target_name through the active session history entry).
79 KiB
79 KiB