Skip to content

Truly independent web browser

LibWeb+LibWebView+WebContent: Run history jobs once across processes

Shannon Boothd244283f1e24
diff --git a/Libraries/LibWeb/HTML/HistoryExecutor.cpp b/Libraries/LibWeb/HTML/HistoryExecutor.cpp
index 3313730aaf7..94358fa7eb3 100644
--- a/Libraries/LibWeb/HTML/HistoryExecutor.cpp
+++ b/Libraries/LibWeb/HTML/HistoryExecutor.cpp
@@ -290,32 +290,81 @@ void HistoryExecutor::enqueue_changing_navigable_continuation(CrossProcessId ope
on_complete->function()(ChangingNavigableHistoryStepJobDisposition::Ready, continuation->update_only);
}
-void HistoryExecutor::run_ui_changing_navigable_history_job(CrossProcessId operation_id, CrossProcessId navigable_id, SessionHistoryEntryDescriptor target_entry_descriptor, UserNavigationInvolvement user_involvement, Optional<Bindings::NavigationType> navigation_type, Optional<Utf16String> finalized_navigation_id, bool ongoing_navigation_is_traversal, bool needs_population, GC::Ref<OnChangingNavigableHistoryStepJobComplete> on_complete, Optional<HistoryNavigationPopulation> population)
+// In both cases of step 12.8 of apply the history step, afterDocumentPopulated, for a changing navigable continuation.
+GC::Ref<HistoryExecutor::AfterDocumentPopulated> HistoryExecutor::after_document_populated_steps(CrossProcessId operation_id, GC::Ref<ChangingNavigableContinuationState> changing_navigable_continuation, GC::Ref<OnChangingNavigableHistoryStepJobComplete> on_complete)
{
- auto& operation = ensure_history_operation(operation_id);
- // The job for the navigation this process finalizes claims the entry it created, with the document it populated.
- // NB: The update for a navigable's creation targets an entry the navigable retains, not the one the request gave.
- RefPtr<SessionHistoryEntry> local_target_entry;
- GC::Ptr<DOM::Document> pending_document;
- if (operation.local_target_navigable_id == navigable_id && navigation_type.has_value()) {
- VERIFY(operation.local_target_entry);
- local_target_entry = operation.local_target_entry;
- pending_document = operation.pending_document;
- }
+ return GC::create_function(heap(), [this, operation_id, changing_navigable_continuation, on_complete](GC::Ptr<PopulateSessionHistoryEntryDocumentOutput> output) {
+ changing_navigable_continuation->population_output = output;
- // AD-HOC: This process can destroy a navigable, or unload its document, before the UI process removes it, which
- // leaves no active window to queue the task on.
- auto navigable = local_navigable_with_id(navigable_id);
- if (!navigable || navigable->has_been_destroyed() || !navigable->active_window()) {
- on_complete->function()(ChangingNavigableHistoryStepJobDisposition::Skipped, false);
- return;
- }
+ // NB: Population that produces no document leaves targetEntry's document as it was.
+ if (output && output->document)
+ changing_navigable_continuation->target_document = output->document;
+
+ // 1. If targetEntry's document is null, then set changingNavigableContinuation's update-only to true.
+ if (!changing_navigable_continuation->target_document)
+ changing_navigable_continuation->update_only = true;
+
+ // NB: The UI process runs steps 2 and 3.
+ // 4. Enqueue changingNavigableContinuation on changingNavigableContinuations.
+ enqueue_changing_navigable_continuation(operation_id, *changing_navigable_continuation, on_complete);
+ });
+}
+
+// https://html.spec.whatwg.org/multipage/browsing-the-web.html#attempt-to-populate-the-history-entry's-document
+// NB: The steps from step 5 on, for the navigation params the UI process obtained, with completionSteps queuing
+// afterDocumentPopulated.
+GC::Ref<GC::Function<void(HistoryNavigationPopulation)>> HistoryExecutor::population_steps(GC::Ref<LocalNavigable> navigable, GC::Ref<AfterDocumentPopulated> after_document_populated)
+{
+ return GC::create_function(heap(), [this, navigable, after_document_populated](HistoryNavigationPopulation population) {
+ if (navigable->has_been_destroyed() || !navigable->active_window()) {
+ after_document_populated->function()(nullptr);
+ return;
+ }
+ auto& request = population.request;
+ auto& result = population.result;
+ auto& realm = navigable->active_window()->principal_realm();
+ TemporaryExecutionContext execution_context { realm, TemporaryExecutionContext::CallbacksEnabled::Yes };
+ auto params = create_navigation_params_from_descriptor(realm, *navigable, move(result.navigation_params));
+ if (params.is_error()) {
+ after_document_populated->function()(nullptr);
+ return;
+ }
+ auto output = heap().allocate<PopulateSessionHistoryEntryDocumentOutput>();
+ output->redirected_url = move(result.redirected_url);
+ output->redirect_replaced_fragment = result.redirect_replaced_fragment;
+ output->classic_history_api_state = move(result.classic_history_api_state);
+ output->resource_cleared = result.resource_cleared;
+ output->inline_content_origin = move(result.inline_content_origin);
+ output->document_id = result.document_id;
+ if (result.replacement_document_state.has_value()) {
+ output->replacement_document_state = DocumentState::create(result.replacement_document_state->id);
+ apply_session_history_document_state_descriptor_from_ui_process(*output->replacement_document_state, *result.replacement_document_state);
+ }
+ auto fetch_client_origin = request.source_snapshot_params.fetch_client.has_value()
+ ? Optional<URL::Origin> { request.source_snapshot_params.fetch_client->origin }
+ : Optional<URL::Origin> {};
+ navigable->queue_navigation_and_traversal_task_for_session_history_entry_population(
+ request.history_entry.url, request.source_snapshot_params.allows_downloading, move(fetch_client_origin),
+ request.user_involvement, request.navigation_id.is_empty() ? Optional<Utf16String> {} : Optional<Utf16String> { request.navigation_id }, params.release_value(), request.csp_navigation_type,
+ request.history_entry.document_state.reload_pending ? Bindings::NavigationTimingType::Reload : Bindings::NavigationTimingType::BackForward,
+ output, GC::create_function(heap(), [navigable, after_document_populated](GC::Ptr<PopulateSessionHistoryEntryDocumentOutput> output) {
+ queue_apply_history_step_task(*navigable, GC::create_function(navigable->heap(), [after_document_populated, output] {
+ after_document_populated->function()(output);
+ }));
+ }));
+ });
+}
+
+// Steps 8.1 and 8.2 of apply the history step, and the ongoing navigation step 8.4 gives navigable, as the UI process ran
+// them for a navigable this process hosts.
+NonnullRefPtr<SessionHistoryEntry> HistoryExecutor::claim_ui_target_entry(LocalNavigable& navigable, RefPtr<SessionHistoryEntry> local_target_entry, SessionHistoryEntryDescriptor target_entry_descriptor, Optional<Bindings::NavigationType> navigation_type, Optional<Utf16String> const& finalized_navigation_id, bool ongoing_navigation_is_traversal)
+{
if (local_target_entry) {
apply_session_history_entry_descriptor_from_ui_process(*local_target_entry, target_entry_descriptor);
apply_session_history_document_state_descriptor_from_ui_process(*local_target_entry->document_state(), target_entry_descriptor.document_state);
} else {
- local_target_entry = navigable->resolve_local_session_history_entry(move(target_entry_descriptor));
+ local_target_entry = navigable.resolve_local_session_history_entry(move(target_entry_descriptor));
}
// 8.1. Let targetEntry be the result of getting the target history entry given navigable and targetStep.
@@ -324,14 +373,14 @@ void HistoryExecutor::run_ui_changing_navigable_history_job(CrossProcessId opera
NonnullRefPtr claimed_target_entry = local_target_entry.release_nonnull();
// 8.2. Set navigable's current session history entry to targetEntry.
- navigable->set_current_session_history_entry(claimed_target_entry);
+ navigable.set_current_session_history_entry(claimed_target_entry);
// NB: The UI process ran step 8.4 of apply the history step, "Set navigable's ongoing navigation to 'traversal'".
// Mirror its result here.
// AD-HOC: A push or replace leaves a newer navigation's ID in place, as that navigation goes on and commits after
// this one, and nulls the ID of the navigation it finalizes. See https://github.com/whatwg/html/issues/12581.
if (ongoing_navigation_is_traversal) {
- navigable->set_ongoing_navigation_without_informing_navigation_api(HTML::LocalNavigable::Traversal::Tag);
+ navigable.set_ongoing_navigation_without_informing_navigation_api(HTML::LocalNavigable::Traversal::Tag);
// AD-HOC: Only step 11 of navigate stops an iframe's lazy loading, but the update for a navigable's creation
// also traverses a child that a repopulated document created, to the entry its restored nested history
@@ -339,16 +388,42 @@ void HistoryExecutor::run_ui_changing_navigable_history_job(CrossProcessId opera
// stops lazy loading here too — or its lazy load resumption steps would navigate the restored
// document away once the iframe is scrolled into view.
if (!navigation_type.has_value()) {
- if (auto container = navigable->container(); container && container->is_html_iframe_element())
+ if (auto container = navigable.container(); container && container->is_html_iframe_element())
static_cast<HTMLIFrameElement&>(*container).stop_lazy_loading();
}
- } else if (finalized_navigation_id.has_value() && navigable->ongoing_navigation() == *finalized_navigation_id) {
- navigable->set_ongoing_navigation_without_informing_navigation_api(Empty {});
+ } else if (finalized_navigation_id.has_value() && navigable.ongoing_navigation() == *finalized_navigation_id) {
+ navigable.set_ongoing_navigation_without_informing_navigation_api(Empty {});
+ }
+
+ return claimed_target_entry;
+}
+
+void HistoryExecutor::run_ui_changing_navigable_history_job(CrossProcessId operation_id, CrossProcessId navigable_id, SessionHistoryEntryDescriptor target_entry_descriptor, UserNavigationInvolvement user_involvement, Optional<Bindings::NavigationType> navigation_type, Optional<Utf16String> finalized_navigation_id, bool ongoing_navigation_is_traversal, bool needs_population, GC::Ref<OnChangingNavigableHistoryStepJobComplete> on_complete)
+{
+ auto& operation = ensure_history_operation(operation_id);
+ // The job for the navigation this process finalizes claims the entry it created, with the document it populated.
+ // NB: The update for a navigable's creation targets an entry the navigable retains, not the one the request gave.
+ RefPtr<SessionHistoryEntry> local_target_entry;
+ GC::Ptr<DOM::Document> pending_document;
+ if (operation.local_target_navigable_id == navigable_id && navigation_type.has_value()) {
+ VERIFY(operation.local_target_entry);
+ local_target_entry = operation.local_target_entry;
+ pending_document = operation.pending_document;
}
+ // AD-HOC: This process can destroy a navigable, or unload its document, before the UI process removes it, which
+ // leaves no active window to queue the task on.
+ auto navigable = local_navigable_with_id(navigable_id);
+ if (!navigable || navigable->has_been_destroyed() || !navigable->active_window()) {
+ on_complete->function()(ChangingNavigableHistoryStepJobDisposition::Skipped, false);
+ return;
+ }
+
+ auto claimed_target_entry = claim_ui_target_entry(*navigable, move(local_target_entry), move(target_entry_descriptor), navigation_type, finalized_navigation_id, ongoing_navigation_is_traversal);
+
operation.changing_navigable_jobs.ensure(navigable_id);
- queue_apply_history_step_task(*navigable, GC::create_function(heap(), [this, operation_id, navigation_type, user_involvement, population = move(population), needs_population, pending_document, claimed_target_entry = move(claimed_target_entry), navigable, on_complete]() mutable {
+ queue_apply_history_step_task(*navigable, GC::create_function(heap(), [this, operation_id, navigation_type, user_involvement, needs_population, pending_document, claimed_target_entry = move(claimed_target_entry), navigable, on_complete]() mutable {
// 1. Let displayedEntry be navigable's active session history entry.
auto displayed_entry = navigable->active_session_history_entry();
@@ -442,68 +517,12 @@ void HistoryExecutor::run_ui_changing_navigable_history_job(CrossProcessId opera
navigation->fire_a_traverse_navigate_event(*target_entry, user_involvement);
}
- auto after_document_populated = GC::create_function(heap(), [this, operation_id, changing_navigable_continuation, on_complete](GC::Ptr<PopulateSessionHistoryEntryDocumentOutput> output) mutable {
- changing_navigable_continuation->population_output = output;
-
- // NB: Population that produces no document leaves targetEntry's document as it was.
- if (output && output->document)
- changing_navigable_continuation->target_document = output->document;
-
- // 1. If targetEntry's document is null, then set changingNavigableContinuation's update-only to true.
- if (!changing_navigable_continuation->target_document)
- changing_navigable_continuation->update_only = true;
-
- // NB: The UI process runs steps 2 and 3.
-
- // 4. Enqueue changingNavigableContinuation on changingNavigableContinuations.
- enqueue_changing_navigable_continuation(operation_id, *changing_navigable_continuation, on_complete);
- });
+ auto after_document_populated = after_document_populated_steps(operation_id, *changing_navigable_continuation, on_complete);
// 8. If targetEntry's document is null, or targetEntry's document state's reload pending is true, then:
// NB: The UI process decides this, and runs the substeps but for step 4's snapshot of navigable's active document.
- if (population.has_value() || needs_population) {
- auto continue_population = GC::create_function(heap(), [this, navigable, after_document_populated](HistoryNavigationPopulation population) {
- if (navigable->has_been_destroyed() || !navigable->active_window()) {
- after_document_populated->function()(nullptr);
- return;
- }
- auto& request = population.request;
- auto& result = population.result;
- auto& realm = navigable->active_window()->principal_realm();
- TemporaryExecutionContext execution_context { realm, TemporaryExecutionContext::CallbacksEnabled::Yes };
- auto params = create_navigation_params_from_descriptor(realm, *navigable, move(result.navigation_params));
- if (params.is_error()) {
- after_document_populated->function()(nullptr);
- return;
- }
- auto output = heap().allocate<PopulateSessionHistoryEntryDocumentOutput>();
- output->redirected_url = move(result.redirected_url);
- output->redirect_replaced_fragment = result.redirect_replaced_fragment;
- output->classic_history_api_state = move(result.classic_history_api_state);
- output->resource_cleared = result.resource_cleared;
- output->inline_content_origin = move(result.inline_content_origin);
- output->document_id = result.document_id;
- if (result.replacement_document_state.has_value()) {
- output->replacement_document_state = DocumentState::create(result.replacement_document_state->id);
- apply_session_history_document_state_descriptor_from_ui_process(*output->replacement_document_state, *result.replacement_document_state);
- }
- auto fetch_client_origin = request.source_snapshot_params.fetch_client.has_value()
- ? Optional<URL::Origin> { request.source_snapshot_params.fetch_client->origin }
- : Optional<URL::Origin> {};
- navigable->queue_navigation_and_traversal_task_for_session_history_entry_population(
- request.history_entry.url, request.source_snapshot_params.allows_downloading, move(fetch_client_origin),
- request.user_involvement, request.navigation_id.is_empty() ? Optional<Utf16String> {} : Optional<Utf16String> { request.navigation_id }, params.release_value(), request.csp_navigation_type,
- request.history_entry.document_state.reload_pending ? Bindings::NavigationTimingType::Reload : Bindings::NavigationTimingType::BackForward,
- output, GC::create_function(heap(), [navigable, after_document_populated](GC::Ptr<PopulateSessionHistoryEntryDocumentOutput> output) {
- queue_apply_history_step_task(*navigable, GC::create_function(navigable->heap(), [after_document_populated, output] {
- after_document_populated->function()(output);
- }));
- }));
- });
- if (population.has_value()) {
- continue_population->function()(population.release_value());
- return;
- }
+ if (needs_population) {
+ auto continue_population = population_steps(*navigable, after_document_populated);
auto* operation = find_history_operation(operation_id);
if (!operation)
return;
@@ -527,6 +546,30 @@ void HistoryExecutor::run_ui_changing_navigable_history_job(CrossProcessId opera
}));
}
+// https://html.spec.whatwg.org/multipage/browsing-the-web.html#attempt-to-populate-the-history-entry's-document
+// NB: The UI process chose this process to host the document it populated for a changing navigable's job, which another
+// process ran. This process creates the document, and holds the continuation that activates it.
+void HistoryExecutor::populate_ui_history_entry_document(CrossProcessId operation_id, SessionHistoryEntryDescriptor target_entry_descriptor, Optional<Bindings::NavigationType> navigation_type, bool ongoing_navigation_is_traversal, HistoryNavigationPopulation population, GC::Ref<OnChangingNavigableHistoryStepJobComplete> on_complete)
+{
+ auto& operation = ensure_history_operation(operation_id);
+ auto navigable_id = population.request.navigable_id;
+ auto navigable = local_navigable_with_id(navigable_id);
+ if (!navigable || navigable->has_been_destroyed() || !navigable->active_window()) {
+ on_complete->function()(ChangingNavigableHistoryStepJobDisposition::Skipped, false);
+ return;
+ }
+ operation.changing_navigable_jobs.ensure(navigable_id);
+
+ auto changing_navigable_continuation = heap().allocate<ChangingNavigableContinuationState>();
+ changing_navigable_continuation->displayed_document = navigable->active_document();
+ changing_navigable_continuation->target_entry = claim_ui_target_entry(*navigable, {}, move(target_entry_descriptor), navigation_type, {}, ongoing_navigation_is_traversal);
+ changing_navigable_continuation->navigable = navigable;
+ changing_navigable_continuation->navigation_type = navigation_type;
+ changing_navigable_continuation->user_involvement = population.request.user_involvement;
+
+ population_steps(*navigable, after_document_populated_steps(operation_id, *changing_navigable_continuation, on_complete))->function()(move(population));
+}
+
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#attempt-to-populate-the-history-entry's-document
// NB: For step 8.7 of a changing navigable's history step job, which the UI process runs, this process creates
// navigationParams given the request.
diff --git a/Libraries/LibWeb/HTML/HistoryExecutor.h b/Libraries/LibWeb/HTML/HistoryExecutor.h
index a095b46b8c8..f06cc53a926 100644
--- a/Libraries/LibWeb/HTML/HistoryExecutor.h
+++ b/Libraries/LibWeb/HTML/HistoryExecutor.h
@@ -67,7 +67,8 @@ public:
void finalize_same_document_navigation(GC::Ref<LocalNavigable>, NonnullRefPtr<SessionHistoryEntry>, RefPtr<SessionHistoryEntry> entry_to_replace, HistoryHandlingBehavior, UserNavigationInvolvement, Optional<SessionHistoryEntryPersistedState> previous_entry_persisted_state);
void run_ui_beforeunload_check(Vector<CrossProcessId> navigable_ids, Optional<SessionHistoryEntryDescriptor> target_entry, Optional<UserNavigationInvolvement> user_involvement_for_navigate_event, UnloadPromptShown, GC::Ref<GC::Function<void(CheckIfUnloadingIsCanceledResult, UnloadPromptShown)>>);
- void run_ui_changing_navigable_history_job(CrossProcessId operation_id, CrossProcessId navigable_id, SessionHistoryEntryDescriptor target_entry_descriptor, UserNavigationInvolvement, Optional<Bindings::NavigationType>, Optional<Utf16String> finalized_navigation_id, bool ongoing_navigation_is_traversal, bool needs_population, GC::Ref<OnChangingNavigableHistoryStepJobComplete>, Optional<HistoryNavigationPopulation> = {});
+ void run_ui_changing_navigable_history_job(CrossProcessId operation_id, CrossProcessId navigable_id, SessionHistoryEntryDescriptor target_entry_descriptor, UserNavigationInvolvement, Optional<Bindings::NavigationType>, Optional<Utf16String> finalized_navigation_id, bool ongoing_navigation_is_traversal, bool needs_population, GC::Ref<OnChangingNavigableHistoryStepJobComplete>);
+ void populate_ui_history_entry_document(CrossProcessId operation_id, SessionHistoryEntryDescriptor target_entry_descriptor, Optional<Bindings::NavigationType>, bool ongoing_navigation_is_traversal, HistoryNavigationPopulation, GC::Ref<OnChangingNavigableHistoryStepJobComplete>);
bool create_ui_history_navigation_params(CrossProcessId operation_id, NavigationPopulationRequest, bool allow_POST);
bool resume_history_navigation_population(CrossProcessId operation_id, HistoryNavigationPopulation&&);
void apply_ui_changing_navigable_continuation(CrossProcessId operation_id, CrossProcessId navigable_id, SessionHistoryEntryIdentity target_entry_identity, HistoryObjectLengthAndIndex, Vector<SessionHistoryEntryDescriptor> entries_for_navigation_api, bool clear_classic_history_api_state, bool clear_navigable_target_name, GC::Ref<OnChangingNavigableContinuationApplied>);
@@ -88,6 +89,11 @@ private:
};
Optional<DequeuedChangingNavigableContinuation> dequeue_ui_changing_navigable_continuation(CrossProcessId operation_id, CrossProcessId navigable_id, SessionHistoryEntryIdentity target_entry_identity, HistoryObjectLengthAndIndex, Vector<SessionHistoryEntryDescriptor> entries_for_navigation_api, bool clear_classic_history_api_state, bool clear_navigable_target_name, GC::Ref<OnChangingNavigableContinuationApplied>);
+ using AfterDocumentPopulated = GC::Function<void(GC::Ptr<PopulateSessionHistoryEntryDocumentOutput>)>;
+ GC::Ref<AfterDocumentPopulated> after_document_populated_steps(CrossProcessId operation_id, GC::Ref<ChangingNavigableContinuationState>, GC::Ref<OnChangingNavigableHistoryStepJobComplete>);
+ GC::Ref<GC::Function<void(HistoryNavigationPopulation)>> population_steps(GC::Ref<LocalNavigable>, GC::Ref<AfterDocumentPopulated>);
+ NonnullRefPtr<SessionHistoryEntry> claim_ui_target_entry(LocalNavigable&, RefPtr<SessionHistoryEntry> local_target_entry, SessionHistoryEntryDescriptor, Optional<Bindings::NavigationType>, Optional<Utf16String> const& finalized_navigation_id, bool ongoing_navigation_is_traversal);
+
void enqueue_changing_navigable_continuation(CrossProcessId operation_id, GC::Ref<ChangingNavigableContinuationState>, GC::Ref<OnChangingNavigableHistoryStepJobComplete>);
GC::Ref<Page> m_page;
diff --git a/Libraries/LibWebView/CanonicalTraversable.cpp b/Libraries/LibWebView/CanonicalTraversable.cpp
index 28b5ffb7ea5..30dfc964858 100644
--- a/Libraries/LibWebView/CanonicalTraversable.cpp
+++ b/Libraries/LibWebView/CanonicalTraversable.cpp
@@ -1444,7 +1444,8 @@ void CanonicalTraversable::continue_history_navigation_population(HistoryOperati
auto* acquiring = changing_navigable.population.get_pointer<ChangingNavigable::AcquiringResponseBody>();
if (!acquiring)
return;
- RefPtr<WebContentPage> endpoint = changing_job_endpoint(changing_navigable);
+ NonnullRefPtr<WebContentPage> job_page = changing_job_endpoint(changing_navigable);
+ RefPtr<WebContentPage> endpoint = job_page;
auto loader = acquiring->loader;
changing_navigable.population = Empty {};
@@ -1473,7 +1474,7 @@ void CanonicalTraversable::continue_history_navigation_population(HistoryOperati
endpoint = host.page;
add_history_operation_completion_endpoint(operation, *endpoint);
changing_navigable.population = ChangingNavigable::Populating { loader };
- auto finish_handoff = [this, operation_id, navigable_id, weak_loader = loader->make_weak_ptr(), endpoint](bool succeeded) {
+ auto finish_handoff = [this, operation_id, navigable_id, weak_loader = loader->make_weak_ptr(), endpoint, job_page = move(job_page)](bool succeeded) {
auto* operation = find_history_operation(operation_id);
auto* changing_navigable = operation ? operation->pending_changing_job(navigable_id) : nullptr;
auto* populating = changing_navigable ? changing_navigable->population.get_pointer<ChangingNavigable::Populating>() : nullptr;
@@ -1484,9 +1485,16 @@ void CanonicalTraversable::continue_history_navigation_population(HistoryOperati
return;
}
auto& loader = *populating->loader;
+ Web::HTML::HistoryNavigationPopulation population { loader.request(), loader.take_result() };
endpoint->owe_reply({ OwedReply::Kind::ChangingJob, operation_id, navigable_id });
- endpoint->async_continue_history_navigation_population(operation_id, changing_navigable->target_entry_descriptor(), operation->algorithm->navigation_type(),
- changing_navigable->navigable().ongoing_navigation().has<CanonicalNavigable::Traversal>(), Web::HTML::HistoryNavigationPopulation { loader.request(), loader.take_result() });
+ if (endpoint == job_page) {
+ endpoint->async_continue_history_navigation_population(operation_id, move(population));
+ return;
+ }
+ // NB: The job's steps ran in the process displaying the navigable's document. Another process hosts the document
+ // the population creates, and creates it there.
+ endpoint->async_populate_history_entry_document(operation_id, changing_navigable->target_entry_descriptor(), operation->algorithm->navigation_type(),
+ changing_navigable->navigable().ongoing_navigation().has<CanonicalNavigable::Traversal>(), move(population));
};
loader->move_response_body_to(endpoint->client().request_server_site_bindings(), move(finish_handoff));
}
diff --git a/Services/WebContent/ConnectionFromClient.cpp b/Services/WebContent/ConnectionFromClient.cpp
index c6975e56218..fe152b51406 100644
--- a/Services/WebContent/ConnectionFromClient.cpp
+++ b/Services/WebContent/ConnectionFromClient.cpp
@@ -638,23 +638,26 @@ void ConnectionFromClient::queue_navigation_api_state_clear_task(Web::PageId pag
navigable->queue_navigation_api_state_clear_task();
}
-void ConnectionFromClient::continue_history_navigation_population(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::SessionHistoryEntryDescriptor target_entry, Optional<Web::Bindings::NavigationType> navigation_type, bool ongoing_navigation_is_traversal, Web::HTML::HistoryNavigationPopulation population)
+void ConnectionFromClient::continue_history_navigation_population(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::HistoryNavigationPopulation population)
{
- auto page = this->page(page_id);
auto navigable_id = population.request.navigable_id;
+ if (auto page = this->page(page_id); page.has_value() && page->page().history_executor().resume_history_navigation_population(operation_id, move(population)))
+ return;
+ async_changing_navigable_history_job_ready(page_id, operation_id, navigable_id, Web::HTML::ChangingNavigableHistoryStepJobDisposition::Skipped, false);
+}
+
+void ConnectionFromClient::populate_history_entry_document(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::SessionHistoryEntryDescriptor target_entry, Optional<Web::Bindings::NavigationType> navigation_type, bool ongoing_navigation_is_traversal, Web::HTML::HistoryNavigationPopulation population)
+{
+ auto navigable_id = population.request.navigable_id;
+ auto page = this->page(page_id);
if (!page.has_value()) {
async_changing_navigable_history_job_ready(page_id, operation_id, navigable_id, Web::HTML::ChangingNavigableHistoryStepJobDisposition::Skipped, false);
return;
}
- auto& history_executor = page->page().history_executor();
- if (history_executor.resume_history_navigation_population(operation_id, move(population)))
- return;
- auto user_involvement = population.request.user_involvement;
- history_executor.run_ui_changing_navigable_history_job(operation_id, navigable_id, move(target_entry), user_involvement, navigation_type, {}, ongoing_navigation_is_traversal, false,
+ page->page().history_executor().populate_ui_history_entry_document(operation_id, move(target_entry), navigation_type, ongoing_navigation_is_traversal, move(population),
GC::create_function(Web::HTML::main_thread_event_loop().heap(), [this, page_id, operation_id, navigable_id](Web::HTML::ChangingNavigableHistoryStepJobDisposition disposition, bool update_only) {
async_changing_navigable_history_job_ready(page_id, operation_id, navigable_id, disposition, update_only);
- }),
- move(population));
+ }));
}
void ConnectionFromClient::run_changing_navigable_history_job(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::SessionHistoryEntryDescriptor target_entry, Web::HTML::UserNavigationInvolvement user_involvement, Optional<Web::Bindings::NavigationType> navigation_type, Optional<Utf16String> finalized_navigation_id, bool ongoing_navigation_is_traversal, bool needs_population)
diff --git a/Services/WebContent/ConnectionFromClient.h b/Services/WebContent/ConnectionFromClient.h
index 78283f056af..b5650ee9d68 100644
--- a/Services/WebContent/ConnectionFromClient.h
+++ b/Services/WebContent/ConnectionFromClient.h
@@ -97,7 +97,8 @@ private:
virtual void initialize(Web::PageId initial_page_id, Vector<Web::HTML::RemoteNavigableDescriptor> remote_navigables, Web::HTML::CrossProcessId root_navigable_id, Web::HTML::CrossProcessIdAllocator cross_process_id_allocator, Web::HTML::SessionHistoryEntryDescriptor initial_history_entry, Web::HTML::CrossProcessId initial_document_id, Web::HTML::VisibilityState system_visibility_state) override;
virtual void create_representing_page(Web::PageId page_id, Vector<Web::HTML::RemoteNavigableDescriptor> remote_navigables) override;
virtual void create_embedded_page(Web::PageId page_id, Vector<Web::HTML::RemoteNavigableDescriptor> remote_navigables, Web::HTML::CrossProcessId root_navigable_id, Web::HTML::SessionHistoryEntryDescriptor initial_history_entry, Web::HTML::VisibilityState system_visibility_state) override;
- virtual void continue_history_navigation_population(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::SessionHistoryEntryDescriptor target_entry, Optional<Web::Bindings::NavigationType>, bool ongoing_navigation_is_traversal, Web::HTML::HistoryNavigationPopulation) override;
+ virtual void continue_history_navigation_population(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::HistoryNavigationPopulation) override;
+ virtual void populate_history_entry_document(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::SessionHistoryEntryDescriptor target_entry, Optional<Web::Bindings::NavigationType>, bool ongoing_navigation_is_traversal, Web::HTML::HistoryNavigationPopulation) override;
virtual void insert_remote_navigable(Web::PageId page_id, Web::HTML::RemoteNavigableDescriptor) override;
virtual void remove_remote_navigable(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id) override;
virtual void update_remote_navigable(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::ReplicatedNavigableState) override;
diff --git a/Services/WebContent/WebContentServer.ipc b/Services/WebContent/WebContentServer.ipc
index 2f6f93fff12..5ac2415cd11 100644
--- a/Services/WebContent/WebContentServer.ipc
+++ b/Services/WebContent/WebContentServer.ipc
@@ -125,7 +125,8 @@ endpoint WebContentServer routed by Web::PageId page_id
run_beforeunload_check(Web::PageId page_id, Web::HTML::CrossProcessId check_id, Vector<Web::HTML::CrossProcessId> navigable_ids, Optional<Web::HTML::SessionHistoryEntryDescriptor> target_entry, Optional<Web::HTML::UserNavigationInvolvement> user_involvement_for_navigate_event, Web::HTML::UnloadPromptShown unload_prompt_shown) =|
discard_embedded_page(Web::PageId page_id) =|
queue_navigation_api_state_clear_task(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id) =|
- continue_history_navigation_population(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::SessionHistoryEntryDescriptor target_entry, Optional<Web::Bindings::NavigationType> navigation_type, bool ongoing_navigation_is_traversal, Web::HTML::HistoryNavigationPopulation population) =|
+ continue_history_navigation_population(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::HistoryNavigationPopulation population) =|
+ populate_history_entry_document(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::SessionHistoryEntryDescriptor target_entry, Optional<Web::Bindings::NavigationType> navigation_type, bool ongoing_navigation_is_traversal, Web::HTML::HistoryNavigationPopulation population) =|
run_changing_navigable_history_job(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::SessionHistoryEntryDescriptor target_entry, Web::HTML::UserNavigationInvolvement user_involvement, Optional<Web::Bindings::NavigationType> navigation_type, Optional<Utf16String> finalized_navigation_id, bool ongoing_navigation_is_traversal, bool needs_population) =|
create_history_navigation_params(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::NavigationPopulationRequest request, bool allow_POST) =|
clear_ongoing_history_traversal(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id) =|