| 
									
										
										
										
											2021-04-03 11:43:08 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2021-04-03 11:43:08 +02:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <LibWeb/HTML/HTMLElement.h>
 | 
					
						
							| 
									
										
										
										
											2023-04-13 18:50:09 +03:00
										 |  |  | #include <LibWeb/HTML/Navigable.h>
 | 
					
						
							| 
									
										
										
										
											2021-04-03 11:43:08 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::HTML { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-12 12:20:02 +01:00
										 |  |  | class NavigableContainer : public HTMLElement { | 
					
						
							|  |  |  |     WEB_PLATFORM_OBJECT(NavigableContainer, HTMLElement); | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-03 11:43:08 +02:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2023-04-23 17:50:08 +03:00
										 |  |  |     static JS::GCPtr<NavigableContainer> navigable_container_with_content_navigable(JS::NonnullGCPtr<Navigable> navigable); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-12 12:20:02 +01:00
										 |  |  |     virtual ~NavigableContainer() override; | 
					
						
							| 
									
										
										
										
											2021-04-03 11:43:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-12 12:20:02 +01:00
										 |  |  |     static HashTable<NavigableContainer*>& all_instances(); | 
					
						
							| 
									
										
										
										
											2022-09-19 20:50:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-21 15:45:41 +03:00
										 |  |  |     JS::GCPtr<Navigable> content_navigable() { return m_content_navigable; } | 
					
						
							|  |  |  |     JS::GCPtr<Navigable const> content_navigable() const { return m_content_navigable.ptr(); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-13 18:50:09 +03:00
										 |  |  |     BrowsingContext* nested_browsing_context() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (m_content_navigable) | 
					
						
							|  |  |  |             return m_content_navigable->active_browsing_context(); | 
					
						
							|  |  |  |         return nullptr; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     BrowsingContext const* nested_browsing_context() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (m_content_navigable) | 
					
						
							|  |  |  |             return m_content_navigable->active_browsing_context(); | 
					
						
							|  |  |  |         return nullptr; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-04-03 11:43:08 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const DOM::Document* content_document() const; | 
					
						
							| 
									
										
										
										
											2022-02-16 22:51:25 +00:00
										 |  |  |     DOM::Document const* content_document_without_origin_check() const; | 
					
						
							| 
									
										
										
										
											2021-04-03 11:43:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-04 10:05:10 +01:00
										 |  |  |     HTML::WindowProxy* content_window(); | 
					
						
							| 
									
										
										
										
											2022-08-04 20:13:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-24 22:08:06 +02:00
										 |  |  |     DOM::Document const* get_svg_document() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-16 23:28:12 +01:00
										 |  |  |     void destroy_the_child_navigable(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-24 15:52:56 +00:00
										 |  |  |     // All elements that extend NavigableContainer "potentially delay the load event".
 | 
					
						
							|  |  |  |     // (embed, frame, iframe, and object)
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#potentially-delays-the-load-event
 | 
					
						
							|  |  |  |     bool currently_delays_the_load_event() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-03 11:43:08 +02:00
										 |  |  | protected: | 
					
						
							| 
									
										
										
										
											2022-12-12 12:20:02 +01:00
										 |  |  |     NavigableContainer(DOM::Document&, DOM::QualifiedName); | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-17 11:06:50 +02:00
										 |  |  |     virtual void visit_edges(Cell::Visitor&) override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-19 13:34:36 +02:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#shared-attribute-processing-steps-for-iframe-and-frame-elements
 | 
					
						
							| 
									
										
										
										
											2024-03-18 16:22:27 +13:00
										 |  |  |     Optional<URL::URL> shared_attribute_processing_steps_for_iframe_and_frame(bool initial_insertion); | 
					
						
							| 
									
										
										
										
											2022-09-19 13:34:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#navigate-an-iframe-or-frame
 | 
					
						
							| 
									
										
										
										
											2024-03-18 16:22:27 +13:00
										 |  |  |     void navigate_an_iframe_or_frame(URL::URL url, ReferrerPolicy::ReferrerPolicy referrer_policy, Optional<String> srcdoc_string = {}); | 
					
						
							| 
									
										
										
										
											2022-03-23 20:13:34 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-04 18:49:40 +02:00
										 |  |  |     WebIDL::ExceptionOr<void> create_new_child_navigable(JS::SafeFunction<void()> afterSessionHistoryUpdate = {}); | 
					
						
							| 
									
										
										
										
											2023-07-10 21:08:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-21 15:45:41 +03:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/document-sequences.html#content-navigable
 | 
					
						
							|  |  |  |     JS::GCPtr<Navigable> m_content_navigable { nullptr }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-24 15:52:56 +00:00
										 |  |  |     void set_potentially_delays_the_load_event(bool value) { m_potentially_delays_the_load_event = value; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-04 18:49:40 +02:00
										 |  |  |     void set_content_navigable_initialized() { m_content_navigable_initialized = true; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-24 19:15:04 +03:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2022-12-12 12:20:02 +01:00
										 |  |  |     virtual bool is_navigable_container() const override { return true; } | 
					
						
							| 
									
										
										
										
											2023-11-24 15:52:56 +00:00
										 |  |  |     bool m_potentially_delays_the_load_event { true }; | 
					
						
							| 
									
										
										
										
											2024-04-04 18:49:40 +02:00
										 |  |  |     bool m_content_navigable_initialized { false }; | 
					
						
							| 
									
										
										
										
											2021-04-03 11:43:08 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-11-24 19:15:04 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::DOM { | 
					
						
							|  |  |  | template<> | 
					
						
							| 
									
										
										
										
											2022-12-12 12:20:02 +01:00
										 |  |  | inline bool Node::fast_is<HTML::NavigableContainer>() const { return is_navigable_container(); } | 
					
						
							| 
									
										
										
										
											2021-11-24 19:15:04 +03:00
										 |  |  | } |