| 
									
										
										
										
											2021-09-27 16:10:56 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2021, Luke Wilde <lukew@serenityos.org> | 
					
						
							| 
									
										
										
										
											2022-08-08 22:29:40 +02:00
										 |  |  |  * Copyright (c) 2022, Andreas Kling <kling@serenityos.org> | 
					
						
							| 
									
										
										
										
											2021-09-27 16:10:56 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-06 12:54:03 +02:00
										 |  |  | #include <AK/FlyString.h>
 | 
					
						
							| 
									
										
										
										
											2021-09-27 16:10:56 +01:00
										 |  |  | #include <LibWeb/DOM/Event.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Web::DOM { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-29 20:32:29 +03:00
										 |  |  | struct CustomEventInit : public EventInit { | 
					
						
							|  |  |  |     JS::Value detail { JS::js_null() }; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-27 16:10:56 +01:00
										 |  |  | // https://dom.spec.whatwg.org/#customevent
 | 
					
						
							|  |  |  | class CustomEvent : public Event { | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     WEB_PLATFORM_OBJECT(CustomEvent, Event); | 
					
						
							| 
									
										
										
										
											2022-08-08 22:29:40 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-27 16:10:56 +01:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2023-04-06 12:54:03 +02:00
										 |  |  |     static WebIDL::ExceptionOr<JS::NonnullGCPtr<CustomEvent>> create(JS::Realm&, FlyString const& event_name, CustomEventInit const& event_init = {}); | 
					
						
							|  |  |  |     static WebIDL::ExceptionOr<JS::NonnullGCPtr<CustomEvent>> construct_impl(JS::Realm&, FlyString const& event_name, CustomEventInit const& event_init); | 
					
						
							| 
									
										
										
										
											2021-09-27 16:10:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-08 22:29:40 +02:00
										 |  |  |     virtual ~CustomEvent() override; | 
					
						
							| 
									
										
										
										
											2021-09-27 16:10:56 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // https://dom.spec.whatwg.org/#dom-customevent-detail
 | 
					
						
							|  |  |  |     JS::Value detail() const { return m_detail; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-28 12:33:35 -05:00
										 |  |  |     virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; | 
					
						
							| 
									
										
										
										
											2022-08-08 22:29:40 +02:00
										 |  |  |     virtual void visit_edges(JS::Cell::Visitor&) override; | 
					
						
							| 
									
										
										
										
											2021-09-27 16:10:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-06 12:54:03 +02:00
										 |  |  |     void init_custom_event(String const& type, bool bubbles, bool cancelable, JS::Value detail); | 
					
						
							| 
									
										
										
										
											2021-09-27 16:10:56 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2023-04-06 12:54:03 +02:00
										 |  |  |     CustomEvent(JS::Realm&, FlyString const& event_name, CustomEventInit const& event_init); | 
					
						
							| 
									
										
										
										
											2022-09-25 16:15:49 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-27 16:10:56 +01:00
										 |  |  |     // https://dom.spec.whatwg.org/#dom-customevent-initcustomevent-type-bubbles-cancelable-detail-detail
 | 
					
						
							|  |  |  |     JS::Value m_detail { JS::js_null() }; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |