LibWeb: Implement "destroy the child navigable" on navigable containers

Co-authored-by: Andreas Kling <kling@serenityos.org>
This commit is contained in:
Aliaksandr Kalenik 2022-12-16 23:28:12 +01:00 committed by Andreas Kling
parent 55f1a70577
commit 934cb601c2
Notes: sideshowbarker 2024-07-17 06:46:15 +09:00
2 changed files with 37 additions and 0 deletions

View File

@ -10,10 +10,12 @@
#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/BrowsingContextGroup.h>
#include <LibWeb/HTML/DocumentState.h>
#include <LibWeb/HTML/HTMLIFrameElement.h>
#include <LibWeb/HTML/NavigableContainer.h>
#include <LibWeb/HTML/NavigationParams.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/TraversableNavigable.h>
#include <LibWeb/Page/Page.h>
namespace Web::HTML {
@ -235,4 +237,37 @@ void NavigableContainer::navigate_an_iframe_or_frame(JS::NonnullGCPtr<Fetch::Inf
MUST(m_nested_browsing_context->navigate(resource, *source_browsing_context, false, history_handling));
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#destroy-a-child-navigable
void NavigableContainer::destroy_the_child_navigable()
{
// 1. Let navigable be container's content navigable.
auto navigable = content_navigable();
// 2. If navigable is null, then return.
if (!navigable)
return;
// 3. Set container's content navigable to null.
m_content_navigable = nullptr;
// 4. Destroy navigable's active document.
navigable->active_document()->destroy();
// 5. Let parentDocState be container's node navigable's active session history entry's document state.
auto parent_doc_state = this->navigable()->active_session_history_entry()->document_state;
// 6. Remove the nested history from parentDocState's nested histories whose id equals navigable's id.
parent_doc_state->nested_histories().remove_all_matching([&](auto& nested_history) {
return navigable->id() == nested_history.id;
});
// 7. Let traversable be container's node navigable's traversable navigable.
auto traversable = this->navigable()->traversable_navigable();
// FIXME: 8. Append the following session history traversal steps to traversable:
// 1. Apply pending history changes to traversable.
traversable->apply_pending_history_changes();
}
}

View File

@ -33,6 +33,8 @@ public:
DOM::Document const* get_svg_document() const;
void destroy_the_child_navigable();
protected:
NavigableContainer(DOM::Document&, DOM::QualifiedName);