mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:52:45 +00:00 
			
		
		
		
	LibWeb/HTML: Define Window's {Global,Window}EventHandlers via IDL
This commit is contained in:
		
							parent
							
								
									c130fd6993
								
							
						
					
					
						commit
						a6f8b18649
					
				
					 3 changed files with 3 additions and 39 deletions
				
			
		|  | @ -1207,13 +1207,6 @@ WebIDL::ExceptionOr<void> Window::initialize_web_interfaces(Badge<WindowEnvironm | ||||||
|     // WebAssembly "namespace"
 |     // WebAssembly "namespace"
 | ||||||
|     define_direct_property("WebAssembly", MUST_OR_THROW_OOM(heap().allocate<Bindings::WebAssemblyObject>(realm, realm)), JS::Attribute::Enumerable | JS::Attribute::Configurable); |     define_direct_property("WebAssembly", MUST_OR_THROW_OOM(heap().allocate<Bindings::WebAssemblyObject>(realm, realm)), JS::Attribute::Enumerable | JS::Attribute::Configurable); | ||||||
| 
 | 
 | ||||||
|     // HTML::GlobalEventHandlers and HTML::WindowEventHandlers
 |  | ||||||
| #define __ENUMERATE(attribute, event_name) \ |  | ||||||
|     define_native_accessor(realm, #attribute, attribute##_getter, attribute##_setter, attr); |  | ||||||
|     ENUMERATE_GLOBAL_EVENT_HANDLERS(__ENUMERATE); |  | ||||||
|     ENUMERATE_WINDOW_EVENT_HANDLERS(__ENUMERATE); |  | ||||||
| #undef __ENUMERATE |  | ||||||
| 
 |  | ||||||
|     return {}; |     return {}; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -1963,29 +1956,4 @@ JS_DEFINE_NATIVE_FUNCTION(Window::navigator_getter) | ||||||
|     return impl->m_navigator; |     return impl->m_navigator; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #define __ENUMERATE(attribute, event_name)                                      \ |  | ||||||
|     JS_DEFINE_NATIVE_FUNCTION(Window::attribute##_getter)                       \ |  | ||||||
|     {                                                                           \ |  | ||||||
|         auto* impl = TRY(impl_from(vm));                                        \ |  | ||||||
|         auto retval = impl->attribute();                                        \ |  | ||||||
|         if (!retval)                                                            \ |  | ||||||
|             return JS::js_null();                                               \ |  | ||||||
|         return &retval->callback;                                               \ |  | ||||||
|     }                                                                           \ |  | ||||||
|     JS_DEFINE_NATIVE_FUNCTION(Window::attribute##_setter)                       \ |  | ||||||
|     {                                                                           \ |  | ||||||
|         auto* impl = TRY(impl_from(vm));                                        \ |  | ||||||
|         auto value = vm.argument(0);                                            \ |  | ||||||
|         WebIDL::CallbackType* cpp_value = nullptr;                              \ |  | ||||||
|         if (value.is_object()) {                                                \ |  | ||||||
|             cpp_value = vm.heap().allocate_without_realm<WebIDL::CallbackType>( \ |  | ||||||
|                 value.as_object(), HTML::incumbent_settings_object());          \ |  | ||||||
|         }                                                                       \ |  | ||||||
|         impl->set_##attribute(cpp_value);                                       \ |  | ||||||
|         return JS::js_undefined();                                              \ |  | ||||||
|     } |  | ||||||
| ENUMERATE_GLOBAL_EVENT_HANDLERS(__ENUMERATE) |  | ||||||
| ENUMERATE_WINDOW_EVENT_HANDLERS(__ENUMERATE) |  | ||||||
| #undef __ENUMERATE |  | ||||||
| 
 |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -291,13 +291,6 @@ private: | ||||||
| 
 | 
 | ||||||
|     JS_DECLARE_NATIVE_FUNCTION(navigator_getter); |     JS_DECLARE_NATIVE_FUNCTION(navigator_getter); | ||||||
| 
 | 
 | ||||||
| #define __ENUMERATE(attribute, event_name)          \ |  | ||||||
|     JS_DECLARE_NATIVE_FUNCTION(attribute##_getter); \ |  | ||||||
|     JS_DECLARE_NATIVE_FUNCTION(attribute##_setter); |  | ||||||
|     ENUMERATE_GLOBAL_EVENT_HANDLERS(__ENUMERATE); |  | ||||||
|     ENUMERATE_WINDOW_EVENT_HANDLERS(__ENUMERATE); |  | ||||||
| #undef __ENUMERATE |  | ||||||
| 
 |  | ||||||
|     HTML::Location* m_location { nullptr }; |     HTML::Location* m_location { nullptr }; | ||||||
| 
 | 
 | ||||||
|     // [[CrossOriginPropertyDescriptorMap]], https://html.spec.whatwg.org/multipage/browsers.html#crossoriginpropertydescriptormap
 |     // [[CrossOriginPropertyDescriptorMap]], https://html.spec.whatwg.org/multipage/browsers.html#crossoriginpropertydescriptormap
 | ||||||
|  |  | ||||||
|  | @ -1,6 +1,9 @@ | ||||||
|  | #import <DOM/EventHandler.idl> | ||||||
| #import <DOM/EventTarget.idl> | #import <DOM/EventTarget.idl> | ||||||
| 
 | 
 | ||||||
| // https://html.spec.whatwg.org/multipage/nav-history-apis.html#window | // https://html.spec.whatwg.org/multipage/nav-history-apis.html#window | ||||||
| [Global=Window, Exposed=Window, LegacyUnenumerableNamedProperties] | [Global=Window, Exposed=Window, LegacyUnenumerableNamedProperties] | ||||||
| interface Window : EventTarget { | interface Window : EventTarget { | ||||||
| }; | }; | ||||||
|  | Window includes GlobalEventHandlers; | ||||||
|  | Window includes WindowEventHandlers; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Linus Groh
						Linus Groh