| 
									
										
										
										
											2022-08-01 16:34:56 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2022, Andreas Kling <kling@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <AK/WeakPtr.h>
 | 
					
						
							| 
									
										
										
										
											2022-12-12 10:58:30 +01:00
										 |  |  | #include <LibJS/Heap/Cell.h>
 | 
					
						
							| 
									
										
										
										
											2023-02-25 10:42:45 -07:00
										 |  |  | #include <LibJS/Heap/GCPtr.h>
 | 
					
						
							| 
									
										
										
										
											2024-03-18 16:22:27 +13:00
										 |  |  | #include <LibURL/URL.h>
 | 
					
						
							| 
									
										
										
										
											2022-08-01 16:34:56 +02:00
										 |  |  | #include <LibWeb/Forward.h>
 | 
					
						
							|  |  |  | #include <LibWeb/HTML/PolicyContainers.h>
 | 
					
						
							| 
									
										
										
										
											2023-08-23 10:26:47 -06:00
										 |  |  | #include <LibWeb/HTML/StructuredSerialize.h>
 | 
					
						
							| 
									
										
										
										
											2022-08-01 16:34:56 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::HTML { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // https://html.spec.whatwg.org/multipage/history.html#scroll-restoration-mode
 | 
					
						
							|  |  |  | enum class ScrollRestorationMode { | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/history.html#dom-scrollrestoration-auto
 | 
					
						
							|  |  |  |     // The user agent is responsible for restoring the scroll position upon navigation.
 | 
					
						
							|  |  |  |     Auto, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/history.html#dom-scrollrestoration-manual
 | 
					
						
							|  |  |  |     // The page is responsible for restoring the scroll position and the user agent does not attempt to do so automatically.
 | 
					
						
							|  |  |  |     Manual, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // https://html.spec.whatwg.org/multipage/history.html#session-history-entry
 | 
					
						
							| 
									
										
										
										
											2024-03-27 15:59:12 +01:00
										 |  |  | class SessionHistoryEntry final : public JS::Cell { | 
					
						
							| 
									
										
										
										
											2022-12-12 10:58:30 +01:00
										 |  |  |     JS_CELL(SessionHistoryEntry, JS::Cell); | 
					
						
							| 
									
										
										
										
											2023-11-19 19:47:52 +01:00
										 |  |  |     JS_DECLARE_ALLOCATOR(SessionHistoryEntry); | 
					
						
							| 
									
										
										
										
											2022-12-12 10:58:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-27 15:59:12 +01:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2023-08-23 10:26:47 -06:00
										 |  |  |     SessionHistoryEntry(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-12 10:58:30 +01:00
										 |  |  |     void visit_edges(Cell::Visitor&) override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-27 16:14:52 +01:00
										 |  |  |     JS::GCPtr<DOM::Document> document() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-25 20:50:53 +03:00
										 |  |  |     enum class Pending { | 
					
						
							|  |  |  |         Tag, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-27 15:59:12 +01:00
										 |  |  |     [[nodiscard]] Variant<int, Pending> step() const { return m_step; } | 
					
						
							|  |  |  |     void set_step(Variant<int, Pending> step) { m_step = step; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     [[nodiscard]] URL::URL const& url() const { return m_url; } | 
					
						
							|  |  |  |     void set_url(URL::URL url) { m_url = move(url); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     [[nodiscard]] JS::GCPtr<HTML::DocumentState> document_state() const { return m_document_state; } | 
					
						
							|  |  |  |     void set_document_state(JS::GCPtr<HTML::DocumentState> document_state) { m_document_state = document_state; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     [[nodiscard]] SerializationRecord const& classic_history_api_state() const { return m_classic_history_api_state; } | 
					
						
							|  |  |  |     void set_classic_history_api_state(SerializationRecord classic_history_api_state) { m_classic_history_api_state = move(classic_history_api_state); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     [[nodiscard]] SerializationRecord const& navigation_api_state() const { return m_navigation_api_state; } | 
					
						
							|  |  |  |     void set_navigation_api_state(SerializationRecord navigation_api_state) { m_navigation_api_state = move(navigation_api_state); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     [[nodiscard]] String const& navigation_api_key() const { return m_navigation_api_key; } | 
					
						
							|  |  |  |     void set_navigation_api_key(String navigation_api_key) { m_navigation_api_key = move(navigation_api_key); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     [[nodiscard]] String const& navigation_api_id() const { return m_navigation_api_id; } | 
					
						
							|  |  |  |     void set_navigation_api_id(String navigation_api_id) { m_navigation_api_id = move(navigation_api_id); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     [[nodiscard]] ScrollRestorationMode scroll_restoration_mode() const { return m_scroll_restoration_mode; } | 
					
						
							|  |  |  |     void set_scroll_restoration_mode(ScrollRestorationMode scroll_restoration_mode) { m_scroll_restoration_mode = scroll_restoration_mode; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     [[nodiscard]] Optional<PolicyContainer> const& policy_container() const { return m_policy_container; } | 
					
						
							|  |  |  |     void set_policy_container(Optional<PolicyContainer> policy_container) { m_policy_container = move(policy_container); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     [[nodiscard]] Optional<ByteString> const& browsing_context_name() const { return m_browsing_context_name; } | 
					
						
							|  |  |  |     void set_browsing_context_name(Optional<ByteString> browsing_context_name) { m_browsing_context_name = move(browsing_context_name); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     [[nodiscard]] JS::GCPtr<BrowsingContext> original_source_browsing_context() const { return m_original_source_browsing_context; } | 
					
						
							|  |  |  |     void set_original_source_browsing_context(JS::GCPtr<BrowsingContext> original_source_browsing_context) { m_original_source_browsing_context = original_source_browsing_context; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2023-04-25 20:50:53 +03:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-step
 | 
					
						
							|  |  |  |     // step, a non-negative integer or "pending", initially "pending".
 | 
					
						
							| 
									
										
										
										
											2024-03-27 15:59:12 +01:00
										 |  |  |     Variant<int, Pending> m_step { Pending::Tag }; | 
					
						
							| 
									
										
										
										
											2023-04-25 20:50:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-01 18:25:01 +01:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-url
 | 
					
						
							| 
									
										
										
										
											2022-08-01 16:34:56 +02:00
										 |  |  |     // URL, a URL
 | 
					
						
							| 
									
										
										
										
											2024-03-27 15:59:12 +01:00
										 |  |  |     URL::URL m_url; | 
					
						
							| 
									
										
										
										
											2022-08-01 16:34:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-14 22:27:52 +03:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-document-state
 | 
					
						
							| 
									
										
										
										
											2024-03-27 15:59:12 +01:00
										 |  |  |     JS::GCPtr<HTML::DocumentState> m_document_state; | 
					
						
							| 
									
										
										
										
											2022-08-01 16:34:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-23 10:26:47 -06:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-classic-history-api-state
 | 
					
						
							|  |  |  |     // classic history API state, which is serialized state, initially StructuredSerializeForStorage(null).
 | 
					
						
							| 
									
										
										
										
											2024-03-27 15:59:12 +01:00
										 |  |  |     SerializationRecord m_classic_history_api_state; | 
					
						
							| 
									
										
										
										
											2023-08-23 10:26:47 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-navigation-api-state
 | 
					
						
							|  |  |  |     // navigation API state, which is a serialized state, initially StructuredSerializeForStorage(undefined).
 | 
					
						
							| 
									
										
										
										
											2024-03-27 15:59:12 +01:00
										 |  |  |     SerializationRecord m_navigation_api_state; | 
					
						
							| 
									
										
										
										
											2023-08-23 10:26:47 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-navigation-api-key
 | 
					
						
							|  |  |  |     // navigation API key, which is a string, initially set to the result of generating a random UUID.
 | 
					
						
							| 
									
										
										
										
											2024-03-27 15:59:12 +01:00
										 |  |  |     String m_navigation_api_key; | 
					
						
							| 
									
										
										
										
											2023-08-23 10:26:47 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-navigation-api-id
 | 
					
						
							|  |  |  |     // navigation API ID, which is a string, initially set to the result of generating a random UUID.
 | 
					
						
							| 
									
										
										
										
											2024-03-27 15:59:12 +01:00
										 |  |  |     String m_navigation_api_id; | 
					
						
							| 
									
										
										
										
											2023-08-23 10:26:47 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-14 22:27:52 +03:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-scroll-restoration-mode
 | 
					
						
							| 
									
										
										
										
											2022-08-01 16:34:56 +02:00
										 |  |  |     // scroll restoration mode, a scroll restoration mode, initially "auto"
 | 
					
						
							| 
									
										
										
										
											2024-03-27 15:59:12 +01:00
										 |  |  |     ScrollRestorationMode m_scroll_restoration_mode { ScrollRestorationMode::Auto }; | 
					
						
							| 
									
										
										
										
											2022-08-01 16:34:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-14 22:27:52 +03:00
										 |  |  |     // policy container, a policy container or null
 | 
					
						
							| 
									
										
										
										
											2024-03-27 15:59:12 +01:00
										 |  |  |     Optional<PolicyContainer> m_policy_container; | 
					
						
							| 
									
										
										
										
											2023-04-14 22:27:52 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-scroll-position
 | 
					
						
							| 
									
										
										
										
											2022-08-01 16:34:56 +02:00
										 |  |  |     // FIXME: scroll position data, which is scroll position data for the document's restorable scrollable regions
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // browsing context name, a browsing context name or null, initially null
 | 
					
						
							| 
									
										
										
										
											2024-03-27 15:59:12 +01:00
										 |  |  |     Optional<ByteString> m_browsing_context_name; | 
					
						
							| 
									
										
										
										
											2022-08-01 16:34:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-14 22:27:52 +03:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-other
 | 
					
						
							| 
									
										
										
										
											2022-08-01 16:34:56 +02:00
										 |  |  |     // FIXME: persisted user state, which is implementation-defined, initially null
 | 
					
						
							|  |  |  |     // NOTE: This is where we could remember the state of form controls, for example.
 | 
					
						
							| 
									
										
										
										
											2022-09-19 17:46:34 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-27 15:59:12 +01:00
										 |  |  |     JS::GCPtr<BrowsingContext> m_original_source_browsing_context; | 
					
						
							| 
									
										
										
										
											2022-08-01 16:34:56 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |