/src/serenity/Userland/Libraries/LibWeb/HTML/ErrorEvent.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2021, Luke Wilde <lukew@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <AK/FlyString.h> |
10 | | #include <LibWeb/DOM/Event.h> |
11 | | |
12 | | namespace Web::HTML { |
13 | | |
14 | | // https://html.spec.whatwg.org/multipage/webappapis.html#erroreventinit |
15 | | struct ErrorEventInit : public DOM::EventInit { |
16 | | String message; |
17 | | String filename; // FIXME: This should be a USVString. |
18 | | u32 lineno { 0 }; |
19 | | u32 colno { 0 }; |
20 | | JS::Value error { JS::js_null() }; |
21 | | }; |
22 | | |
23 | | // https://html.spec.whatwg.org/multipage/webappapis.html#errorevent |
24 | | class ErrorEvent final : public DOM::Event { |
25 | | WEB_PLATFORM_OBJECT(ErrorEvent, DOM::Event); |
26 | | JS_DECLARE_ALLOCATOR(ErrorEvent); |
27 | | |
28 | | public: |
29 | | [[nodiscard]] static JS::NonnullGCPtr<ErrorEvent> create(JS::Realm&, FlyString const& event_name, ErrorEventInit const& = {}); |
30 | | static WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> construct_impl(JS::Realm&, FlyString const& event_name, ErrorEventInit const& event_init); |
31 | | |
32 | | virtual ~ErrorEvent() override; |
33 | | |
34 | | // https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-message |
35 | 0 | String const& message() const { return m_message; } |
36 | | |
37 | | // https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-filename |
38 | 0 | String const& filename() const { return m_filename; } |
39 | | |
40 | | // https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-lineno |
41 | 0 | u32 lineno() const { return m_lineno; } |
42 | | |
43 | | // https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-colno |
44 | 0 | u32 colno() const { return m_colno; } |
45 | | |
46 | | // https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-error |
47 | 0 | JS::Value error() const { return m_error; } |
48 | | |
49 | | private: |
50 | | ErrorEvent(JS::Realm&, FlyString const& event_name, ErrorEventInit const& event_init); |
51 | | |
52 | | virtual void initialize(JS::Realm&) override; |
53 | | virtual void visit_edges(Cell::Visitor&) override; |
54 | | |
55 | | String m_message; |
56 | | String m_filename; // FIXME: This should be a USVString. |
57 | | u32 m_lineno { 0 }; |
58 | | u32 m_colno { 0 }; |
59 | | JS::Value m_error; |
60 | | }; |
61 | | |
62 | | } |