| 
									
										
										
										
											2023-08-23 13:35:25 -06:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-18 16:22:27 +13:00
										 |  |  | #include <LibURL/URL.h>
 | 
					
						
							| 
									
										
										
										
											2023-08-23 13:35:25 -06:00
										 |  |  | #include <LibWeb/Bindings/PlatformObject.h>
 | 
					
						
							| 
									
										
										
										
											2025-07-17 13:40:50 -04:00
										 |  |  | #include <LibWeb/HTML/StructuredSerializeTypes.h>
 | 
					
						
							| 
									
										
										
										
											2023-08-23 13:35:25 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::HTML { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // https://html.spec.whatwg.org/multipage/nav-history-apis.html#navigationdestination
 | 
					
						
							|  |  |  | class NavigationDestination : public Bindings::PlatformObject { | 
					
						
							|  |  |  |     WEB_PLATFORM_OBJECT(NavigationDestination, Bindings::PlatformObject); | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     GC_DECLARE_ALLOCATOR(NavigationDestination); | 
					
						
							| 
									
										
										
										
											2023-08-23 13:35:25 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     [[nodiscard]] static GC::Ref<NavigationDestination> create(JS::Realm&); | 
					
						
							| 
									
										
										
										
											2023-08-23 13:35:25 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-03 22:31:33 +13:00
										 |  |  |     String url() const; | 
					
						
							| 
									
										
										
										
											2023-08-23 13:35:25 -06:00
										 |  |  |     String key() const; | 
					
						
							|  |  |  |     String id() const; | 
					
						
							|  |  |  |     i64 index() const; | 
					
						
							|  |  |  |     bool same_document() const; | 
					
						
							|  |  |  |     WebIDL::ExceptionOr<JS::Value> get_state(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Non-spec'd getter, not exposed to JS
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     GC::Ptr<NavigationHistoryEntry> navigation_history_entry() const { return m_entry; } | 
					
						
							| 
									
										
										
										
											2023-08-23 13:35:25 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Setters are not available to JS, but expected in many spec algorithms
 | 
					
						
							| 
									
										
										
										
											2024-03-18 16:22:27 +13:00
										 |  |  |     void set_url(URL::URL const& url) { m_url = url; } | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     void set_entry(GC::Ptr<NavigationHistoryEntry> entry) { m_entry = entry; } | 
					
						
							| 
									
										
										
										
											2023-08-23 13:35:25 -06:00
										 |  |  |     void set_state(SerializationRecord state) { m_state = move(state); } | 
					
						
							|  |  |  |     void set_is_same_document(bool b) { m_is_same_document = b; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual ~NavigationDestination() override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-18 16:22:27 +13:00
										 |  |  |     URL::URL const& raw_url() const { return m_url; } | 
					
						
							| 
									
										
										
										
											2023-09-22 18:18:19 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-23 13:35:25 -06:00
										 |  |  | private: | 
					
						
							|  |  |  |     NavigationDestination(JS::Realm&); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual void initialize(JS::Realm&) override; | 
					
						
							|  |  |  |     virtual void visit_edges(JS::Cell::Visitor&) override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationdestination-url
 | 
					
						
							| 
									
										
										
										
											2024-03-18 16:22:27 +13:00
										 |  |  |     URL::URL m_url; | 
					
						
							| 
									
										
										
										
											2023-08-23 13:35:25 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationdestination-url
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     GC::Ptr<NavigationHistoryEntry> m_entry; | 
					
						
							| 
									
										
										
										
											2023-08-23 13:35:25 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationdestination-state
 | 
					
						
							|  |  |  |     SerializationRecord m_state; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationdestination-samedocument
 | 
					
						
							|  |  |  |     bool m_is_same_document { false }; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |