diff options
12 files changed, 15 insertions, 23 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp index 0b6cdd61d4..850ee15e35 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp @@ -510,18 +510,6 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter @cpp_name@ = @parameter.optional_default_value@L; )~~~"); } - } else if (parameter.type->name == "EventHandler") { - // x.onfoo = function() { ... }, x.onfoo = () => { ... }, x.onfoo = {} - // NOTE: Anything else than an object will be treated as null. This is because EventHandler has the [LegacyTreatNonObjectAsNull] extended attribute. - // Yes, you can store objects in event handler attributes. They just get ignored when there's any attempt to invoke them. - // FIXME: Replace this with proper support for callback function types. - - scoped_generator.append(R"~~~( - Optional<Bindings::CallbackType> @cpp_name@; - if (@js_name@@js_suffix@.is_object()) { - @cpp_name@ = Bindings::CallbackType { JS::make_handle(&@js_name@@js_suffix@.as_object()), HTML::incumbent_settings_object() }; - } -)~~~"); } else if (parameter.type->name == "Promise") { // NOTE: It's not clear to me where the implicit wrapping of non-Promise values in a resolved // Promise is defined in the spec; https://webidl.spec.whatwg.org/#idl-promise doesn't say @@ -1351,17 +1339,6 @@ static void generate_wrap_statement(SourceGenerator& generator, String const& va scoped_generator.append(R"~~~( @result_expression@ @value@; )~~~"); - } else if (type.name == "EventHandler") { - // FIXME: Replace this with proper support for callback function types. - - scoped_generator.append(R"~~~( - if (!@value@) { - @result_expression@ JS::js_null(); - } else { - VERIFY(!@value@->callback.is_null()); - @result_expression@ @value@->callback.cell(); - } -)~~~"); } else if (is<IDL::UnionType>(type)) { TODO(); } else if (interface.enumerations.contains(type.name)) { diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryList.idl b/Userland/Libraries/LibWeb/CSS/MediaQueryList.idl index cd8fa55119..21178328bb 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQueryList.idl +++ b/Userland/Libraries/LibWeb/CSS/MediaQueryList.idl @@ -1,4 +1,5 @@ #import <DOM/EventTarget.idl> +#import <DOM/EventHandler.idl> [Exposed=Window] interface MediaQueryList : EventTarget { diff --git a/Userland/Libraries/LibWeb/DOM/AbortSignal.idl b/Userland/Libraries/LibWeb/DOM/AbortSignal.idl index 82b26fd5e6..4c11a9ba6a 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortSignal.idl +++ b/Userland/Libraries/LibWeb/DOM/AbortSignal.idl @@ -1,4 +1,5 @@ #import <DOM/EventTarget.idl> +#import <DOM/EventHandler.idl> [Exposed=(Window,Worker), CustomVisit] interface AbortSignal : EventTarget { diff --git a/Userland/Libraries/LibWeb/DOM/Document.idl b/Userland/Libraries/LibWeb/DOM/Document.idl index f681407e87..b656ecc2df 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.idl +++ b/Userland/Libraries/LibWeb/DOM/Document.idl @@ -5,6 +5,7 @@ #import <DOM/DocumentType.idl> #import <DOM/Element.idl> #import <DOM/Event.idl> +#import <DOM/EventHandler.idl> #import <DOM/HTMLCollection.idl> #import <DOM/Node.idl> #import <DOM/NodeFilter.idl> diff --git a/Userland/Libraries/LibWeb/DOM/EventHandler.idl b/Userland/Libraries/LibWeb/DOM/EventHandler.idl new file mode 100644 index 0000000000..afb8503383 --- /dev/null +++ b/Userland/Libraries/LibWeb/DOM/EventHandler.idl @@ -0,0 +1,3 @@ +[LegacyTreatNonObjectAsNull] +callback EventHandlerNonNull = any (Event event); +typedef EventHandlerNonNull? EventHandler; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLElement.idl index 8b5518ef1e..fb81dffd01 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.idl @@ -1,4 +1,5 @@ #import <HTML/DOMStringMap.idl> +#import <DOM/EventHandler.idl> interface HTMLElement : Element { diff --git a/Userland/Libraries/LibWeb/HTML/MessagePort.idl b/Userland/Libraries/LibWeb/HTML/MessagePort.idl index af03a2ce83..3a8a92fc7b 100644 --- a/Userland/Libraries/LibWeb/HTML/MessagePort.idl +++ b/Userland/Libraries/LibWeb/HTML/MessagePort.idl @@ -1,4 +1,5 @@ #import <DOM/EventTarget.idl> +#import <DOM/EventHandler.idl> interface MessagePort : EventTarget { diff --git a/Userland/Libraries/LibWeb/HTML/Worker.idl b/Userland/Libraries/LibWeb/HTML/Worker.idl index 73687379a1..4f92053381 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.idl +++ b/Userland/Libraries/LibWeb/HTML/Worker.idl @@ -1,3 +1,6 @@ +#import <DOM/EventTarget.idl> +#import <DOM/EventHandler.idl> + [Exposed=(Window)] interface Worker : EventTarget { constructor(DOMString scriptURL, optional WorkerOptions options = {}); diff --git a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.idl b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.idl index 04117e1d4c..28d1c1581f 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.idl +++ b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.idl @@ -1,4 +1,5 @@ #import <DOM/EventTarget.idl> +#import <DOM/EventHandler.idl> #import <HTML/WorkerLocation.idl> #import <HTML/WorkerNavigator.idl> diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.idl b/Userland/Libraries/LibWeb/WebSockets/WebSocket.idl index 8457b84da6..ebd4545e6d 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.idl +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.idl @@ -1,4 +1,5 @@ #import <DOM/EventTarget.idl> +#import <DOM/EventHandler.idl> interface WebSocket : EventTarget { diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.idl b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.idl index b0de53a340..944f03c683 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.idl +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.idl @@ -1,4 +1,5 @@ #import <XHR/XMLHttpRequestEventTarget.idl> +#import <DOM/EventHandler.idl> enum XMLHttpRequestResponseType { "", diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequestEventTarget.idl b/Userland/Libraries/LibWeb/XHR/XMLHttpRequestEventTarget.idl index 1bedd16034..90e4ab187e 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequestEventTarget.idl +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequestEventTarget.idl @@ -1,4 +1,5 @@ #import <DOM/EventTarget.idl> +#import <DOM/EventHandler.idl> interface XMLHttpRequestEventTarget : EventTarget { |