/src/serenity/Userland/Libraries/LibWeb/HTML/CloseEvent.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2021, Dex♪ <dexes.ttp@gmail.com> |
3 | | * Copyright (c) 2022, Andreas Kling <kling@serenityos.org> |
4 | | * |
5 | | * SPDX-License-Identifier: BSD-2-Clause |
6 | | */ |
7 | | |
8 | | #pragma once |
9 | | |
10 | | #include <AK/FlyString.h> |
11 | | #include <LibWeb/DOM/Event.h> |
12 | | |
13 | | namespace Web::HTML { |
14 | | |
15 | | struct CloseEventInit : public DOM::EventInit { |
16 | | bool was_clean { false }; |
17 | | u16 code { 0 }; |
18 | | String reason; |
19 | | }; |
20 | | |
21 | | class CloseEvent : public DOM::Event { |
22 | | WEB_PLATFORM_OBJECT(CloseEvent, DOM::Event); |
23 | | JS_DECLARE_ALLOCATOR(CloseEvent); |
24 | | |
25 | | public: |
26 | | [[nodiscard]] static JS::NonnullGCPtr<CloseEvent> create(JS::Realm&, FlyString const& event_name, CloseEventInit const& event_init = {}); |
27 | | static WebIDL::ExceptionOr<JS::NonnullGCPtr<CloseEvent>> construct_impl(JS::Realm&, FlyString const& event_name, CloseEventInit const& event_init); |
28 | | |
29 | | virtual ~CloseEvent() override; |
30 | | |
31 | 0 | bool was_clean() const { return m_was_clean; } |
32 | 0 | u16 code() const { return m_code; } |
33 | 0 | String reason() const { return m_reason; } |
34 | | |
35 | | private: |
36 | | CloseEvent(JS::Realm&, FlyString const& event_name, CloseEventInit const& event_init); |
37 | | |
38 | | virtual void initialize(JS::Realm&) override; |
39 | | |
40 | | bool m_was_clean { false }; |
41 | | u16 m_code { 0 }; |
42 | | String m_reason; |
43 | | }; |
44 | | |
45 | | } |