Pārlūkot izejas kodu

LibWeb/HTML: Define Window's {Global,Window}EventHandlers via IDL

Linus Groh 2 gadi atpakaļ
vecāks
revīzija
a6f8b18649

+ 0 - 32
Userland/Libraries/LibWeb/HTML/Window.cpp

@@ -1207,13 +1207,6 @@ WebIDL::ExceptionOr<void> Window::initialize_web_interfaces(Badge<WindowEnvironm
     // WebAssembly "namespace"
     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 {};
 }
 
@@ -1963,29 +1956,4 @@ JS_DEFINE_NATIVE_FUNCTION(Window::navigator_getter)
     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
-
 }

+ 0 - 7
Userland/Libraries/LibWeb/HTML/Window.h

@@ -291,13 +291,6 @@ private:
 
     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 };
 
     // [[CrossOriginPropertyDescriptorMap]], https://html.spec.whatwg.org/multipage/browsers.html#crossoriginpropertydescriptormap

+ 3 - 0
Userland/Libraries/LibWeb/HTML/Window.idl

@@ -1,6 +1,9 @@
+#import <DOM/EventHandler.idl>
 #import <DOM/EventTarget.idl>
 
 // https://html.spec.whatwg.org/multipage/nav-history-apis.html#window
 [Global=Window, Exposed=Window, LegacyUnenumerableNamedProperties]
 interface Window : EventTarget {
 };
+Window includes GlobalEventHandlers;
+Window includes WindowEventHandlers;