mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:32:46 +00:00 
			
		
		
		
	LibWeb: Add window.navigation property
This commit is contained in:
		
							parent
							
								
									0c2f758067
								
							
						
					
					
						commit
						7f043e3083
					
				
					 3 changed files with 22 additions and 0 deletions
				
			
		|  | @ -38,6 +38,7 @@ | |||
| #include <LibWeb/HTML/Focus.h> | ||||
| #include <LibWeb/HTML/Location.h> | ||||
| #include <LibWeb/HTML/MessageEvent.h> | ||||
| #include <LibWeb/HTML/Navigation.h> | ||||
| #include <LibWeb/HTML/Navigator.h> | ||||
| #include <LibWeb/HTML/Origin.h> | ||||
| #include <LibWeb/HTML/PageTransitionEvent.h> | ||||
|  | @ -106,6 +107,7 @@ void Window::visit_edges(JS::Cell::Visitor& visitor) | |||
|     visitor.visit(m_location); | ||||
|     visitor.visit(m_crypto); | ||||
|     visitor.visit(m_navigator); | ||||
|     visitor.visit(m_navigation); | ||||
|     visitor.visit(m_custom_element_registry); | ||||
|     for (auto& plugin_object : m_pdf_viewer_plugin_objects) | ||||
|         visitor.visit(plugin_object); | ||||
|  | @ -1410,6 +1412,20 @@ JS::NonnullGCPtr<Crypto::Crypto> Window::crypto() | |||
|     return JS::NonnullGCPtr { *m_crypto }; | ||||
| } | ||||
| 
 | ||||
| // https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigation
 | ||||
| JS::NonnullGCPtr<Navigation> Window::navigation() | ||||
| { | ||||
|     // Upon creation of the Window object, its navigation API must be set
 | ||||
|     // to a new Navigation object created in the Window object's relevant realm.
 | ||||
|     if (!m_navigation) { | ||||
|         auto& realm = relevant_realm(*this); | ||||
|         m_navigation = heap().allocate<Navigation>(realm, realm); | ||||
|     } | ||||
| 
 | ||||
|     // The navigation getter steps are to return this's navigation API.
 | ||||
|     return *m_navigation; | ||||
| } | ||||
| 
 | ||||
| // https://html.spec.whatwg.org/multipage/custom-elements.html#dom-window-customelements
 | ||||
| JS::NonnullGCPtr<CustomElementRegistry> Window::custom_elements() | ||||
| { | ||||
|  |  | |||
|  | @ -136,6 +136,7 @@ public: | |||
|     void set_name(String const&); | ||||
|     [[nodiscard]] JS::NonnullGCPtr<Location> location(); | ||||
|     JS::NonnullGCPtr<History> history() const; | ||||
|     JS::NonnullGCPtr<Navigation> navigation(); | ||||
|     void focus(); | ||||
| 
 | ||||
|     JS::NonnullGCPtr<WindowProxy> frames() const; | ||||
|  | @ -226,6 +227,9 @@ private: | |||
|     JS::GCPtr<Navigator> m_navigator; | ||||
|     JS::GCPtr<Location> m_location; | ||||
| 
 | ||||
|     // https://html.spec.whatwg.org/multipage/nav-history-apis.html#window-navigation-api
 | ||||
|     JS::GCPtr<Navigation> m_navigation; | ||||
| 
 | ||||
|     // https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-api
 | ||||
|     // Each Window object is associated with a unique instance of a CustomElementRegistry object, allocated when the Window object is created.
 | ||||
|     JS::GCPtr<CustomElementRegistry> m_custom_element_registry; | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ | |||
| #import <HighResolutionTime/Performance.idl> | ||||
| #import <HTML/AnimationFrameProvider.idl> | ||||
| #import <HTML/CustomElements/CustomElementRegistry.idl> | ||||
| #import <HTML/Navigation.idl> | ||||
| #import <HTML/Navigator.idl> | ||||
| #import <HTML/WindowLocalStorage.idl> | ||||
| #import <HTML/WindowOrWorkerGlobalScope.idl> | ||||
|  | @ -24,6 +25,7 @@ interface Window : EventTarget { | |||
|     attribute DOMString name; | ||||
|     [PutForwards=href, LegacyUnforgeable] readonly attribute Location location; | ||||
|     readonly attribute History history; | ||||
|     readonly attribute Navigation navigation; | ||||
|     readonly attribute CustomElementRegistry customElements; | ||||
|     undefined focus(); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andrew Kaster
						Andrew Kaster