| 
									
										
										
										
											2021-10-11 12:59:45 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> | 
					
						
							| 
									
										
										
										
											2022-08-08 22:29:40 +02:00
										 |  |  |  * Copyright (c) 2022, Andreas Kling <kling@serenityos.org> | 
					
						
							| 
									
										
										
										
											2021-10-11 12:59:45 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-25 16:38:21 -06:00
										 |  |  | #include <LibJS/Heap/Handle.h>
 | 
					
						
							| 
									
										
										
										
											2021-10-11 12:59:45 +01:00
										 |  |  | #include <LibJS/Runtime/Promise.h>
 | 
					
						
							|  |  |  | #include <LibJS/Runtime/Value.h>
 | 
					
						
							|  |  |  | #include <LibWeb/DOM/Event.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Web::HTML { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct PromiseRejectionEventInit : public DOM::EventInit { | 
					
						
							|  |  |  |     JS::Handle<JS::Promise> promise; | 
					
						
							|  |  |  |     JS::Value reason; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-08 22:29:40 +02:00
										 |  |  | class PromiseRejectionEvent final : public DOM::Event { | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     WEB_PLATFORM_OBJECT(PromiseRejectionEvent, DOM::Event); | 
					
						
							| 
									
										
										
										
											2022-08-08 22:29:40 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-11 12:59:45 +01:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2023-01-08 19:23:00 -05:00
										 |  |  |     static PromiseRejectionEvent* create(JS::Realm&, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init = {}); | 
					
						
							|  |  |  |     static PromiseRejectionEvent* construct_impl(JS::Realm&, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init); | 
					
						
							| 
									
										
										
										
											2021-10-11 12:59:45 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-08 22:29:40 +02:00
										 |  |  |     virtual ~PromiseRejectionEvent() override; | 
					
						
							| 
									
										
										
										
											2021-10-11 12:59:45 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Needs to return a pointer for the generated JS bindings to work.
 | 
					
						
							| 
									
										
										
										
											2022-08-08 22:29:40 +02:00
										 |  |  |     JS::Promise const* promise() const { return m_promise; } | 
					
						
							|  |  |  |     JS::Value reason() const { return m_reason; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2023-01-08 19:23:00 -05:00
										 |  |  |     PromiseRejectionEvent(JS::Realm&, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init); | 
					
						
							| 
									
										
										
										
											2022-09-25 16:38:21 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-10 06:28:20 -05:00
										 |  |  |     virtual void initialize(JS::Realm&) override; | 
					
						
							| 
									
										
										
										
											2022-08-08 22:29:40 +02:00
										 |  |  |     virtual void visit_edges(Cell::Visitor&) override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     JS::Promise* m_promise { nullptr }; | 
					
						
							|  |  |  |     JS::Value m_reason; | 
					
						
							| 
									
										
										
										
											2021-10-11 12:59:45 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |