mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-29 11:00:29 +00:00
LibWeb/HTML: Define Window's {Global,Window}EventHandlers via IDL
This commit is contained in:
parent
c130fd6993
commit
a6f8b18649
Notes:
sideshowbarker
2024-07-17 18:49:10 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/a6f8b18649 Pull-request: https://github.com/SerenityOS/serenity/pull/17752 Reviewed-by: https://github.com/awesomekling
3 changed files with 3 additions and 39 deletions
|
@ -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
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue