LibWeb: Update create_new_child_navigable() after spec fix

Now that https://github.com/whatwg/html/issues/9686 is fixed, let's
fix it the exact same way in our implementation. :^)
This commit is contained in:
Andreas Kling 2024-01-02 20:57:26 +01:00 committed by Alexander Kalenik
parent 49fcc5dcd8
commit 0a05be69cf
Notes: sideshowbarker 2024-07-17 02:29:45 +09:00

View file

@ -114,16 +114,18 @@ WebIDL::ExceptionOr<void> NavigableContainer::create_new_child_navigable()
auto parent_doc_state = parent_navigable->active_session_history_entry()->document_state;
// 2. Let targetStepSHE be the first session history entry in traversable's session history entries whose document state equals parentDocState.
// NOTE: We need to look for parent document state in parent navigable instead of traversable as specification says. https://github.com/whatwg/html/issues/9686
auto target_step_she = *(parent_navigable->get_session_history_entries().find_if([parent_doc_state](auto& entry) {
return entry->document_state == parent_doc_state;
}));
// 2. Let parentNavigableEntries be the result of getting session history entries for parentNavigable.
auto parent_navigable_entries = parent_navigable->get_session_history_entries();
// 3. Set historyEntry's step to targetStepSHE's step.
// 3. Let targetStepSHE be the first session history entry in parentNavigableEntries whose document state equals parentDocState.
auto target_step_she = *parent_navigable_entries.find_if([parent_doc_state](auto& entry) {
return entry->document_state == parent_doc_state;
});
// 4. Set historyEntry's step to targetStepSHE's step.
history_entry->step = target_step_she->step;
// 4. Let nestedHistory be a new nested history whose id is navigable's id and entries list is « historyEntry ».
// 5. Let nestedHistory be a new nested history whose id is navigable's id and entries list is « historyEntry ».
DocumentState::NestedHistory nested_history {
.id = navigable->id(),
.entries { *history_entry },