Truly independent web browser
LibWebView: Drop the finalized navigation check on history job replies
Shannon Boothba8b6a90465b
diff --git a/Libraries/LibWeb/HTML/HistoryExecutor.cpp b/Libraries/LibWeb/HTML/HistoryExecutor.cppindex d763f28604f..83bee72eed6 100644--- a/Libraries/LibWeb/HTML/HistoryExecutor.cpp+++ b/Libraries/LibWeb/HTML/HistoryExecutor.cpp@@ -350,8 +350,7 @@ void HistoryExecutor::run_ui_changing_navigable_history_job(CrossProcessId opera// 2. Let targetEntry be navigable's current session history entry.// AD-HOC: A synchronous navigation that jumps the queue during this run's apply-history-step re-claims the// navigable before this task runs. The run still applies its claimed target entry once the jumped- // navigation's nested run completes. A navigation proven newer completes the job as stale before this- // task is queued.+ // navigation's nested run completes.auto target_entry = navigable->current_session_history_entry();if (target_entry != claimed_target_entry) {if (!target_entry) {diff --git a/Libraries/LibWebView/CanonicalNavigable.cpp b/Libraries/LibWebView/CanonicalNavigable.cppindex 576e2c2bc8f..177bcdd1008 100644--- a/Libraries/LibWebView/CanonicalNavigable.cpp+++ b/Libraries/LibWebView/CanonicalNavigable.cpp@@ -1229,7 +1229,7 @@ void CanonicalNavigable::did_commit_navigation(CanonicalSessionHistoryEntry& ent}// A navigation can commit while a newer navigation is already in flight. In that case update the replicated- // state for the committed document without changing the newer navigation's transaction.+ // state for the committed document, and leave the newer navigation alone.if (!commits_ongoing_navigation)return;diff --git a/Libraries/LibWebView/CanonicalTraversable.cpp b/Libraries/LibWebView/CanonicalTraversable.cppindex 7a18ad23328..98562fc80d5 100644--- a/Libraries/LibWebView/CanonicalTraversable.cpp+++ b/Libraries/LibWebView/CanonicalTraversable.cpp@@ -1266,18 +1266,6 @@ ApplyHistoryStep* CanonicalTraversable::find_history_step_run(Web::HTML::CrossPrreturn operation ? operation->algorithm.ptr() : nullptr;}-bool CanonicalTraversable::navigation_transaction_matches(HistoryOperation const& operation, WebContentPage& page, Optional<Web::HTML::CrossProcessId> reply_navigable_id) const-{- if (!operation.parameters.has<Web::FinalizeCrossDocumentNavigationHistoryOperationParameters>())- return true;-- auto const& parameters = operation.parameters.get<Web::FinalizeCrossDocumentNavigationHistoryOperationParameters>();- if (reply_navigable_id.has_value() && *reply_navigable_id != parameters.navigable_id)- return true;- auto navigation = finalized_navigation(operation);- return navigation && navigation->host() == &page;-}-void CanonicalTraversable::add_history_operation_completion_endpoint(HistoryOperation& operation, NonnullRefPtr<WebContentPage> endpoint){if (any_of(operation.completion_endpoints, [&](auto const& completion_endpoint) { return completion_endpoint == endpoint; }))@@ -1292,7 +1280,6 @@ void CanonicalTraversable::did_finish_history_navigation_params_creation(WebContauto* operation = find_history_operation(operation_id);auto* changing_navigable = operation ? operation->pending_changing_job(navigable_id) : nullptr;if (!changing_navigable || changing_navigable->population_loader- || !navigation_transaction_matches(*operation, source_page, navigable_id)|| !source_page.take_owed_reply({ OwedReply::Kind::ChangingJob, operation_id, navigable_id })) {discard();return;@@ -1301,7 +1288,7 @@ void CanonicalTraversable::did_finish_history_navigation_params_creation(WebCont// process a document created from another file: URL, and possibly with it local file access.if (population.request.history_entry.url.scheme() == "file"sv && population.request.history_entry.url != changing_navigable->target_entry->url) {discard();- did_fail_history_navigation_population(*operation, *changing_navigable, source_page);+ did_fail_history_navigation_population(*operation, *changing_navigable);return;}// The document's sandboxing flags are at least those the UI process snapshots for the navigable.@@ -1309,25 +1296,22 @@ void CanonicalTraversable::did_finish_history_navigation_params_creation(WebContauto& loader = changing_navigable->population_loader;loader = NavigationLoader::create(source_page.client().is_private(), move(population.request));loader->did_finish_navigation_params_creation(move(population.result));- loader->acquire_response_body([this, operation_id, navigable_id, source_page = NonnullRefPtr<WebContentPage>(source_page)](bool succeeded) {+ loader->acquire_response_body([this, operation_id, navigable_id](bool succeeded) {auto* operation = find_history_operation(operation_id);auto* changing_navigable = operation ? operation->pending_changing_job(navigable_id) : nullptr;if (!changing_navigable)return;if (!succeeded) {- did_fail_history_navigation_population(*operation, *changing_navigable, *source_page);+ did_fail_history_navigation_population(*operation, *changing_navigable);return;}continue_history_navigation_population(*operation, *changing_navigable);});}-void CanonicalTraversable::did_fail_history_navigation_population(HistoryOperation& operation, ChangingNavigable& changing_navigable, WebContentPage& page)+void CanonicalTraversable::did_fail_history_navigation_population(HistoryOperation& operation, ChangingNavigable& changing_navigable){- auto disposition = navigation_transaction_matches(operation, page, changing_navigable.id)- ? Web::HTML::ChangingNavigableHistoryStepJobDisposition::Skipped- : Web::HTML::ChangingNavigableHistoryStepJobDisposition::Stale;- operation.algorithm->changing_navigable_job_completed(changing_navigable, disposition);+ operation.algorithm->changing_navigable_job_completed(changing_navigable, Web::HTML::ChangingNavigableHistoryStepJobDisposition::Skipped);}void CanonicalTraversable::continue_history_navigation_population(HistoryOperation& operation, ChangingNavigable& changing_navigable)@@ -1351,7 +1335,7 @@ void CanonicalTraversable::continue_history_navigation_population(HistoryOperatireturn;}if (host_or_error.is_error()) {- did_fail_history_navigation_population(operation, changing_navigable, *endpoint);+ did_fail_history_navigation_population(operation, changing_navigable);return;}auto host = host_or_error.release_value();@@ -1366,7 +1350,7 @@ void CanonicalTraversable::continue_history_navigation_population(HistoryOperatiif (!changing_navigable || !weak_loader || changing_navigable->population_loader.ptr() != weak_loader.ptr())return;if (!succeeded || !endpoint->is_open()) {- did_fail_history_navigation_population(*operation, *changing_navigable, *endpoint);+ did_fail_history_navigation_population(*operation, *changing_navigable);return;}auto& loader = *changing_navigable->population_loader;@@ -2720,16 +2704,10 @@ void CanonicalTraversable::did_receive_changing_navigable_history_job_ready(WebCif (!changing_navigable)return;- if (!navigation_transaction_matches(*operation, source_page, navigable_id))- disposition = Web::HTML::ChangingNavigableHistoryStepJobDisposition::Stale;-if (disposition == Web::HTML::ChangingNavigableHistoryStepJobDisposition::Ready) {changing_navigable->update_only = update_only;changing_navigable->target_document_id = target_document_id;- operation->algorithm->changing_navigable_job_completed(*changing_navigable, disposition);- return;}-operation->algorithm->changing_navigable_job_completed(*changing_navigable, disposition);}diff --git a/Libraries/LibWebView/CanonicalTraversable.h b/Libraries/LibWebView/CanonicalTraversable.hindex 7cc06c45810..0c6dd302334 100644--- a/Libraries/LibWebView/CanonicalTraversable.h+++ b/Libraries/LibWebView/CanonicalTraversable.h@@ -189,11 +189,10 @@ private:HistoryOperation* find_history_operation(Web::HTML::CrossProcessId operation_id);ApplyHistoryStep* find_history_step_run(Web::HTML::CrossProcessId operation_id);- bool navigation_transaction_matches(HistoryOperation const&, WebContentPage&, Optional<Web::HTML::CrossProcessId> reply_navigable_id = {}) const;RefPtr<CanonicalNavigation> finalized_navigation(HistoryOperation const&) const;bool update_session_history_entry_persisted_state(CanonicalNavigable&, Web::HTML::SessionHistoryEntryPersistedState const&);void add_history_operation_completion_endpoint(HistoryOperation&, NonnullRefPtr<WebContentPage>);- void did_fail_history_navigation_population(HistoryOperation&, ChangingNavigable&, WebContentPage&);+ void did_fail_history_navigation_population(HistoryOperation&, ChangingNavigable&);void continue_history_navigation_population(HistoryOperation&, ChangingNavigable&);void send_changing_navigable_continuation_task(HistoryOperation&, ChangingNavigable&);void send_displayed_document_unload_task(HistoryOperation&, ChangingNavigable&);