| 
									
										
										
										
											2021-10-14 16:53:39 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2021, Luke Wilde <lukew@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-05 10:17:53 +01:00
										 |  |  | #include <AK/FlyString.h>
 | 
					
						
							| 
									
										
										
										
											2021-10-14 16:53:39 +01:00
										 |  |  | #include <LibWeb/DOM/Event.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Web::HTML { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // https://html.spec.whatwg.org/multipage/webappapis.html#erroreventinit
 | 
					
						
							|  |  |  | struct ErrorEventInit : public DOM::EventInit { | 
					
						
							| 
									
										
										
										
											2023-03-05 10:17:53 +01:00
										 |  |  |     String message; | 
					
						
							|  |  |  |     String filename; // FIXME: This should be a USVString.
 | 
					
						
							| 
									
										
										
										
											2021-10-14 16:53:39 +01:00
										 |  |  |     u32 lineno { 0 }; | 
					
						
							|  |  |  |     u32 colno { 0 }; | 
					
						
							|  |  |  |     JS::Value error { JS::js_null() }; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // https://html.spec.whatwg.org/multipage/webappapis.html#errorevent
 | 
					
						
							|  |  |  | class ErrorEvent final : public DOM::Event { | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     WEB_PLATFORM_OBJECT(ErrorEvent, DOM::Event); | 
					
						
							| 
									
										
										
										
											2022-08-08 22:29:40 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-14 16:53:39 +01:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2023-03-05 10:17:53 +01:00
										 |  |  |     static WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> create(JS::Realm&, FlyString const& event_name, ErrorEventInit const& event_init = {}); | 
					
						
							|  |  |  |     static WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> construct_impl(JS::Realm&, FlyString const& event_name, ErrorEventInit const& event_init); | 
					
						
							| 
									
										
										
										
											2021-10-14 16:53:39 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-08 22:29:40 +02:00
										 |  |  |     virtual ~ErrorEvent() override; | 
					
						
							| 
									
										
										
										
											2021-10-14 16:53:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-message
 | 
					
						
							| 
									
										
										
										
											2023-03-05 10:17:53 +01:00
										 |  |  |     String const& message() const { return m_message; } | 
					
						
							| 
									
										
										
										
											2021-10-14 16:53:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-filename
 | 
					
						
							| 
									
										
										
										
											2023-03-05 10:17:53 +01:00
										 |  |  |     String const& filename() const { return m_filename; } | 
					
						
							| 
									
										
										
										
											2021-10-14 16:53:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-lineno
 | 
					
						
							|  |  |  |     u32 lineno() const { return m_lineno; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-colno
 | 
					
						
							|  |  |  |     u32 colno() const { return m_colno; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-error
 | 
					
						
							| 
									
										
										
										
											2022-08-08 22:29:40 +02:00
										 |  |  |     JS::Value error() const { return m_error; } | 
					
						
							| 
									
										
										
										
											2021-10-14 16:53:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2023-03-05 10:17:53 +01:00
										 |  |  |     ErrorEvent(JS::Realm&, FlyString const& event_name, ErrorEventInit const& event_init); | 
					
						
							| 
									
										
										
										
											2022-09-25 16:38:21 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-07 08:41:28 +02:00
										 |  |  |     virtual void initialize(JS::Realm&) override; | 
					
						
							| 
									
										
										
										
											2022-08-08 22:29:40 +02:00
										 |  |  |     virtual void visit_edges(Cell::Visitor&) override; | 
					
						
							| 
									
										
										
										
											2021-10-14 16:53:39 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-05 10:17:53 +01:00
										 |  |  |     String m_message; | 
					
						
							|  |  |  |     String m_filename; // FIXME: This should be a USVString.
 | 
					
						
							| 
									
										
										
										
											2021-10-14 16:53:39 +01:00
										 |  |  |     u32 m_lineno { 0 }; | 
					
						
							|  |  |  |     u32 m_colno { 0 }; | 
					
						
							| 
									
										
										
										
											2022-08-08 22:29:40 +02:00
										 |  |  |     JS::Value m_error; | 
					
						
							| 
									
										
										
										
											2021-10-14 16:53:39 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |