mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 19:17:41 +00:00
LibWeb: Align session history step application code with latest spec
Replaces direct "apply the history step" calls with new functions from the spec: - "update for navigable creation/destruction" - "apply the push/replace history step" - "apply the reload history step"
This commit is contained in:
parent
d3d2e56a68
commit
2445205e9d
4 changed files with 39 additions and 15 deletions
|
@ -1293,8 +1293,8 @@ void Navigable::reload()
|
|||
|
||||
// 3. Append the following session history traversal steps to traversable:
|
||||
traversable->append_session_history_traversal_steps([traversable] {
|
||||
// 1. Apply pending history changes to traversable with true.
|
||||
traversable->apply_pending_history_changes();
|
||||
// 1. Apply the reload history step to traversable.
|
||||
traversable->apply_the_reload_history_step();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1438,8 +1438,8 @@ void finalize_a_cross_document_navigation(JS::NonnullGCPtr<Navigable> navigable,
|
|||
target_step = traversable->current_session_history_step();
|
||||
}
|
||||
|
||||
// FIXME: 10. Apply the push/replace history step targetStep to traversable.
|
||||
traversable->apply_the_history_step(target_step);
|
||||
// 10. Apply the push/replace history step targetStep to traversable.
|
||||
traversable->apply_the_push_or_replace_history_step(target_step);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#url-and-history-update-steps
|
||||
|
|
|
@ -126,7 +126,8 @@ WebIDL::ExceptionOr<void> NavigableContainer::create_new_child_navigable()
|
|||
// 5. Append nestedHistory to parentDocState's nested histories.
|
||||
parent_doc_state->nested_histories().append(move(nested_history));
|
||||
|
||||
// FIXME: 6. Update for navigable creation/destruction given traversable
|
||||
// 6. Update for navigable creation/destruction given traversable
|
||||
traversable->update_for_navigable_creation_or_destruction();
|
||||
});
|
||||
|
||||
return {};
|
||||
|
@ -336,7 +337,7 @@ void NavigableContainer::destroy_the_child_navigable()
|
|||
// 8. Append the following session history traversal steps to traversable:
|
||||
traversable->append_session_history_traversal_steps([traversable] {
|
||||
// 1. Apply pending history changes to traversable.
|
||||
traversable->apply_pending_history_changes();
|
||||
traversable->update_for_navigable_creation_or_destruction();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -498,14 +498,34 @@ void TraversableNavigable::traverse_the_history_by_delta(int delta)
|
|||
});
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#apply-pending-history-changes
|
||||
void TraversableNavigable::apply_pending_history_changes()
|
||||
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#update-for-navigable-creation/destruction
|
||||
void TraversableNavigable::update_for_navigable_creation_or_destruction()
|
||||
{
|
||||
// 1. Let targetStep be traversable's current session history step.
|
||||
auto target_step = current_session_history_step();
|
||||
// 1. Let step be traversable's current session history step.
|
||||
auto step = current_session_history_step();
|
||||
|
||||
// 2. Apply the history step targetStep to traversable with checkForUserCancelation set to checkForUserCancelation.
|
||||
apply_the_history_step(target_step);
|
||||
// 2. Return the result of applying the history step step to traversable given false, false, null, null, and null.
|
||||
// FIXME: Pass false, false, null, null, and null as arguments.
|
||||
apply_the_history_step(step);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#apply-the-reload-history-step
|
||||
void TraversableNavigable::apply_the_reload_history_step()
|
||||
{
|
||||
// 1. Let step be traversable's current session history step.
|
||||
auto step = current_session_history_step();
|
||||
|
||||
// 2. Return the result of applying the history step step to traversable given true, false, null, null, and null.
|
||||
// FIXME: Pass true, false, null, null, and null as arguments.
|
||||
apply_the_history_step(step);
|
||||
}
|
||||
|
||||
void TraversableNavigable::apply_the_push_or_replace_history_step(int step)
|
||||
{
|
||||
// 1. Return the result of applying the history step step to traversable given false, false, null, null, and null.
|
||||
// FIXME: Pass false, false, null, null, and null as arguments.
|
||||
// FIXME: Return result of history application.
|
||||
apply_the_history_step(step);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/document-sequences.html#close-a-top-level-traversable
|
||||
|
@ -595,7 +615,7 @@ void finalize_a_same_document_navigation(JS::NonnullGCPtr<TraversableNavigable>
|
|||
}
|
||||
|
||||
// 6. Apply the push/replace history step targetStep to traversable.
|
||||
traversable->apply_the_history_step(*target_step);
|
||||
traversable->apply_the_push_or_replace_history_step(*target_step);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,8 +37,9 @@ public:
|
|||
};
|
||||
HistoryObjectLengthAndIndex get_the_history_object_length_and_index(int) const;
|
||||
|
||||
void apply_the_history_step(int step, Optional<SourceSnapshotParams> = {});
|
||||
void apply_pending_history_changes();
|
||||
void apply_the_reload_history_step();
|
||||
void apply_the_push_or_replace_history_step(int step);
|
||||
void update_for_navigable_creation_or_destruction();
|
||||
|
||||
int get_the_used_step(int step) const;
|
||||
Vector<JS::Handle<Navigable>> get_all_navigables_whose_current_session_history_entry_will_change_or_reload(int) const;
|
||||
|
@ -62,6 +63,8 @@ private:
|
|||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
void apply_the_history_step(int step, Optional<SourceSnapshotParams> = {});
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/document-sequences.html#tn-current-session-history-step
|
||||
int m_current_session_history_step { 0 };
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue