From 9a19bdbfcfe2d7ff8eedde93d0ba01927d7a89df Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Tue, 25 Apr 2023 20:46:32 +0300 Subject: LibWeb: Implement Navigable::initialize_navigable() --- Userland/Libraries/LibWeb/HTML/Navigable.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'Userland/Libraries/LibWeb/HTML/Navigable.cpp') diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.cpp b/Userland/Libraries/LibWeb/HTML/Navigable.cpp index 7fada325e1..bcee4dfa47 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigable.cpp @@ -50,6 +50,33 @@ JS::GCPtr Navigable::navigable_with_active_document(JS::NonnullGCPtr< return nullptr; } +// https://html.spec.whatwg.org/multipage/document-sequences.html#initialize-the-navigable +ErrorOr Navigable::initialize_navigable(JS::NonnullGCPtr document_state, JS::GCPtr parent) +{ + static int next_id = 0; + m_id = TRY(String::number(next_id++)); + + // 1. Let entry be a new session history entry, with + JS::NonnullGCPtr entry = *heap().allocate_without_realm(); + + // URL: document's URL + entry->url = document_state->document()->url(); + + // document state: documentState + entry->document_state = document_state; + + // 2. Set navigable's current session history entry to entry. + m_current_session_history_entry = entry; + + // 3. Set navigable's active session history entry to entry. + m_active_session_history_entry = entry; + + // 4. Set navigable's parent to parent. + m_parent = parent; + + return {}; +} + // https://html.spec.whatwg.org/multipage/document-sequences.html#nav-document JS::GCPtr Navigable::active_document() { -- cgit v1.2.3