summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorAliaksandr Kalenik <kalenik.aliaksandr@gmail.com>2023-04-25 20:46:32 +0300
committerAndreas Kling <kling@serenityos.org>2023-04-26 15:51:50 +0200
commit9a19bdbfcfe2d7ff8eedde93d0ba01927d7a89df (patch)
treedcce719a699c1529b189f99a41312318d7bcbff7 /Userland/Libraries/LibWeb
parent74ab8ec4f07dce57b57da9d08ecfceef3aaf53ac (diff)
downloadserenity-9a19bdbfcfe2d7ff8eedde93d0ba01927d7a89df.zip
LibWeb: Implement Navigable::initialize_navigable()
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/HTML/Navigable.cpp27
-rw-r--r--Userland/Libraries/LibWeb/HTML/Navigable.h2
2 files changed, 29 insertions, 0 deletions
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::navigable_with_active_document(JS::NonnullGCPtr<
return nullptr;
}
+// https://html.spec.whatwg.org/multipage/document-sequences.html#initialize-the-navigable
+ErrorOr<void> Navigable::initialize_navigable(JS::NonnullGCPtr<DocumentState> document_state, JS::GCPtr<Navigable> 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<SessionHistoryEntry> entry = *heap().allocate_without_realm<SessionHistoryEntry>();
+
+ // 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<DOM::Document> Navigable::active_document()
{
diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.h b/Userland/Libraries/LibWeb/HTML/Navigable.h
index 14570ef331..9834465249 100644
--- a/Userland/Libraries/LibWeb/HTML/Navigable.h
+++ b/Userland/Libraries/LibWeb/HTML/Navigable.h
@@ -21,6 +21,8 @@ class Navigable : public JS::Cell {
public:
virtual ~Navigable() override;
+ ErrorOr<void> initialize_navigable(JS::NonnullGCPtr<DocumentState> document_state, JS::GCPtr<Navigable> parent);
+
String const& id() const { return m_id; };
JS::GCPtr<Navigable> parent() const { return m_parent; };