| 
									
										
										
										
											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
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #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: | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     static PromiseRejectionEvent* create(HTML::Window&, FlyString const& event_name, PromiseRejectionEventInit const& event_init = {}); | 
					
						
							|  |  |  |     static PromiseRejectionEvent* create_with_global_object(HTML::Window&, FlyString const& event_name, PromiseRejectionEventInit const& event_init); | 
					
						
							| 
									
										
										
										
											2022-08-08 22:29:40 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     PromiseRejectionEvent(HTML::Window&, FlyString 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: | 
					
						
							|  |  |  |     virtual void visit_edges(Cell::Visitor&) override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     JS::Promise* m_promise { nullptr }; | 
					
						
							|  |  |  |     JS::Value m_reason; | 
					
						
							| 
									
										
										
										
											2021-10-11 12:59:45 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-08-08 22:29:40 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::Bindings { | 
					
						
							|  |  |  | inline JS::Object* wrap(JS::Realm&, Web::HTML::PromiseRejectionEvent& object) { return &object; } | 
					
						
							|  |  |  | using PromiseRejectionEventWrapper = Web::HTML::PromiseRejectionEvent; | 
					
						
							|  |  |  | } |