summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/CloseEvent.h
blob: 9c0e71064b4c0ac25df5294265f7ed9cfd9199f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * Copyright (c) 2021, Dex♪ <dexes.ttp@gmail.com>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibWeb/DOM/Event.h>

namespace Web::HTML {

class CloseEvent : public DOM::Event {
public:
    using WrapperType = Bindings::CloseEventWrapper;

    static NonnullRefPtr<CloseEvent> create(const FlyString& event_name, bool was_clean, u16 code, const String& reason)
    {
        return adopt_ref(*new CloseEvent(event_name, was_clean, code, reason));
    }

    virtual ~CloseEvent() override = default;

    bool was_clean() { return m_was_clean; }
    u16 code() const { return m_code; }
    String reason() const { return m_reason; }

protected:
    CloseEvent(const FlyString& event_name, bool was_clean, u16 code, const String& reason)
        : Event(event_name)
        , m_was_clean(was_clean)
        , m_code(code)
        , m_reason(reason)
    {
    }

    bool m_was_clean { false };
    u16 m_code { 0 };
    String m_reason;
};

}