| 
									
										
										
										
											2022-12-12 12:01:09 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2022, Andreas Kling <kling@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <AK/Vector.h>
 | 
					
						
							|  |  |  | #include <LibWeb/HTML/Navigable.h>
 | 
					
						
							|  |  |  | #include <LibWeb/HTML/VisibilityState.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Web::HTML { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // https://html.spec.whatwg.org/multipage/document-sequences.html#traversable-navigable
 | 
					
						
							|  |  |  | class TraversableNavigable final : public Navigable { | 
					
						
							|  |  |  |     JS_CELL(TraversableNavigable, Navigable); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2022-12-17 14:26:48 +01:00
										 |  |  |     static WebIDL::ExceptionOr<JS::NonnullGCPtr<TraversableNavigable>> create_a_new_top_level_traversable(Page&, JS::GCPtr<BrowsingContext> opener, String target_name); | 
					
						
							|  |  |  |     static WebIDL::ExceptionOr<JS::NonnullGCPtr<TraversableNavigable>> create_a_fresh_top_level_traversable(Page&, AK::URL const& initial_navigation_url, Variant<Empty, String, POSTResource> = Empty {}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-12 12:01:09 +01:00
										 |  |  |     virtual ~TraversableNavigable() override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool is_top_level_traversable() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     int current_session_history_step() const { return m_current_session_history_step; }; | 
					
						
							| 
									
										
										
										
											2023-04-05 09:18:15 +03:00
										 |  |  |     Vector<JS::NonnullGCPtr<SessionHistoryEntry>>& session_history_entries() { return m_session_history_entries; }; | 
					
						
							| 
									
										
										
										
											2022-12-12 12:01:09 +01:00
										 |  |  |     Vector<JS::NonnullGCPtr<SessionHistoryEntry>> const& session_history_entries() const { return m_session_history_entries; }; | 
					
						
							|  |  |  |     bool running_nested_apply_history_step() const { return m_running_nested_apply_history_step; }; | 
					
						
							|  |  |  |     VisibilityState system_visibility_state() const { return m_system_visibility_state; }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-13 10:18:46 +03:00
										 |  |  |     struct HistoryObjectLengthAndIndex { | 
					
						
							|  |  |  |         size_t script_history_length; | 
					
						
							|  |  |  |         size_t script_history_index; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     HistoryObjectLengthAndIndex get_the_history_object_length_and_index(int) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-19 21:08:26 +03:00
										 |  |  |     int get_the_used_step(int step) const; | 
					
						
							| 
									
										
										
										
											2023-06-19 21:11:30 +03:00
										 |  |  |     Vector<JS::Handle<Navigable>> get_all_navigables_whose_current_session_history_entry_will_change_or_reload(int) const; | 
					
						
							| 
									
										
										
										
											2023-04-13 10:11:31 +03:00
										 |  |  |     Vector<int> get_all_used_history_steps() const; | 
					
						
							| 
									
										
										
										
											2023-04-06 12:24:09 +03:00
										 |  |  |     void clear_the_forward_session_history(); | 
					
						
							| 
									
										
										
										
											2023-04-13 10:11:31 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-12 12:01:09 +01:00
										 |  |  | private: | 
					
						
							|  |  |  |     TraversableNavigable(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual void visit_edges(Cell::Visitor&) override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/document-sequences.html#tn-current-session-history-step
 | 
					
						
							|  |  |  |     int m_current_session_history_step { 0 }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/document-sequences.html#tn-session-history-entries
 | 
					
						
							|  |  |  |     Vector<JS::NonnullGCPtr<SessionHistoryEntry>> m_session_history_entries; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // FIXME: https://html.spec.whatwg.org/multipage/document-sequences.html#tn-session-history-traversal-queue
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/document-sequences.html#tn-running-nested-apply-history-step
 | 
					
						
							|  |  |  |     bool m_running_nested_apply_history_step { false }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/document-sequences.html#system-visibility-state
 | 
					
						
							|  |  |  |     VisibilityState m_system_visibility_state { VisibilityState::Visible }; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |