Skip to content

Truly independent web browser

LibWebView: Let a history step run finish its operation

Shannon Booth934c6fd48d4c
diff --git a/Libraries/LibWebView/ApplyHistoryStep.cpp b/Libraries/LibWebView/ApplyHistoryStep.cpp
index df4c3b9d12f..5c5854d9b81 100644
--- a/Libraries/LibWebView/ApplyHistoryStep.cpp
+++ b/Libraries/LibWebView/ApplyHistoryStep.cpp
@@ -21,8 +21,7 @@ ApplyHistoryStep::ApplyHistoryStep(
Optional<Web::HTML::CrossProcessId> initiator_to_check,
Optional<Web::HTML::NavigationSourceSnapshot> source_snapshot_params,
Web::HTML::UserNavigationInvolvement user_involvement,
- Optional<Web::Bindings::NavigationType> navigation_type,
- Function<void(Web::HTML::HistoryStepResult)> on_complete)
+ Optional<Web::Bindings::NavigationType> navigation_type)
: m_traversable(traversable)
, m_session_history(traversable.m_session_history)
, m_session_history_traversal_queue(traversable.m_history_traversal_queue)
@@ -36,7 +35,6 @@ ApplyHistoryStep::ApplyHistoryStep(
, m_source_snapshot_params(move(source_snapshot_params))
, m_user_involvement(user_involvement)
, m_navigation_type(navigation_type)
- , m_on_complete(move(on_complete))
, m_generation(++m_traversable_state.generation_counter)
{
}
@@ -460,7 +458,7 @@ void ApplyHistoryStep::abandon()
void ApplyHistoryStep::return_result(Web::HTML::HistoryStepResult result)
{
- m_on_complete(result);
+ m_traversable.finish_history_operation(m_operation_id, result);
}
Web::HTML::SessionHistoryEntryDescriptor ChangingNavigable::target_entry_descriptor() const
diff --git a/Libraries/LibWebView/ApplyHistoryStep.h b/Libraries/LibWebView/ApplyHistoryStep.h
index 88be5ae69ec..2febff74cf8 100644
--- a/Libraries/LibWebView/ApplyHistoryStep.h
+++ b/Libraries/LibWebView/ApplyHistoryStep.h
@@ -126,8 +126,7 @@ public:
Optional<Web::HTML::CrossProcessId> initiator_to_check,
Optional<Web::HTML::NavigationSourceSnapshot> source_snapshot_params,
Web::HTML::UserNavigationInvolvement user_involvement,
- Optional<Web::Bindings::NavigationType> navigation_type,
- Function<void(Web::HTML::HistoryStepResult)> on_complete);
+ Optional<Web::Bindings::NavigationType> navigation_type);
~ApplyHistoryStep();
void apply_the_history_step();
@@ -138,7 +137,6 @@ public:
Optional<i32> committed_step() const { return m_committed_step; }
HistoryOperation& operation() const { return m_operation; }
- Web::HTML::CrossProcessId operation_id() const { return m_operation_id; }
Web::HTML::UserNavigationInvolvement user_involvement() const { return m_user_involvement; }
Optional<Web::Bindings::NavigationType> navigation_type() const { return m_navigation_type; }
Optional<Web::HTML::NavigationSourceSnapshot> const& source_snapshot_params() const { return m_source_snapshot_params; }
@@ -180,7 +178,6 @@ private:
Optional<Web::HTML::NavigationSourceSnapshot> const m_source_snapshot_params;
Web::HTML::UserNavigationInvolvement const m_user_involvement;
Optional<Web::Bindings::NavigationType> const m_navigation_type;
- Function<void(Web::HTML::HistoryStepResult)> m_on_complete;
// The algorithm's variables.
i32 m_target_step { 0 };
diff --git a/Libraries/LibWebView/CanonicalTraversable.cpp b/Libraries/LibWebView/CanonicalTraversable.cpp
index d54e55aa719..ee98933b3a3 100644
--- a/Libraries/LibWebView/CanonicalTraversable.cpp
+++ b/Libraries/LibWebView/CanonicalTraversable.cpp
@@ -2092,13 +2092,7 @@ void CanonicalTraversable::enqueue_browser_history_traversal(i32 target_step, bo
void CanonicalTraversable::apply_history_step(HistoryOperation& operation, i32 step, bool check_for_cancelation, Optional<Web::HTML::CrossProcessId> initiator_to_check, Web::HTML::UserNavigationInvolvement user_involvement, Optional<Web::Bindings::NavigationType> navigation_type, Optional<Web::HTML::NavigationSourceSnapshot> source_snapshot_params)
{
VERIFY(!operation.algorithm);
- auto operation_id = operation.operation_id;
- operation.algorithm = make<ApplyHistoryStep>(
- *this, operation, operation_id, operation.sequence_number,
- step, check_for_cancelation, initiator_to_check, move(source_snapshot_params), user_involvement, navigation_type,
- [this, &operation](Web::HTML::HistoryStepResult result) {
- finish_history_operation(operation.operation_id, result);
- });
+ operation.algorithm = make<ApplyHistoryStep>(*this, operation, operation.operation_id, operation.sequence_number, step, check_for_cancelation, initiator_to_check, move(source_snapshot_params), user_involvement, navigation_type);
operation.algorithm->apply_the_history_step();
}
@@ -2605,8 +2599,8 @@ void CanonicalTraversable::finish_history_operation(Web::HTML::CrossProcessId op
if (auto view = this->view(); view.has_value())
view->run_webdriver_commands_waiting_for_a_document({});
- // The completion callback that brought us here can be running inside the algorithm object; destroy the
- // operation only once the stack has unwound.
+ // NB: The run of apply the history step that finished the operation can be on the stack; destroy the operation
+ // only once the stack has unwound.
Core::deferred_invoke([operation = move(operation)] { });
}