Skip to content

Truly independent web browser

1.1 KB
Raw Blame
/*
 * Copyright (c) 2021, Dex♪ <[email protected]>
 * Copyright (c) 2022, Andreas Kling <[email protected]>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Utf16FlyString.h>
#include <AK/Utf16String.h>
#include <LibJS/Forward.h>
#include <LibWeb/Bindings/CloseEvent.h>
#include <LibWeb/DOM/Event.h>
#include <LibWebCommon/HighResolutionTime/DOMHighResTimeStamp.h>

namespace Web::HTML {

using CloseEventInit = Bindings::CloseEventInit;

class CloseEvent : public DOM::Event {
    WEB_WRAPPABLE(CloseEvent, DOM::Event);
    GC_DECLARE_ALLOCATOR(CloseEvent);

public:
    [[nodiscard]] static GC::Ref<CloseEvent> create(Utf16FlyString const& event_name, CloseEventInit const& event_init, HighResolutionTime::DOMHighResTimeStamp);

    virtual ~CloseEvent() override;

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

private:
    CloseEvent(Utf16FlyString const& event_name, CloseEventInit const& event_init, HighResolutionTime::DOMHighResTimeStamp);

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

}