Serenity Operating System
at master 44 lines 1.2 kB view raw
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 13namespace Web::HTML { 14 15struct CloseEventInit : public DOM::EventInit { 16 bool was_clean { false }; 17 u16 code { 0 }; 18 String reason; 19}; 20 21class CloseEvent : public DOM::Event { 22 WEB_PLATFORM_OBJECT(CloseEvent, DOM::Event); 23 24public: 25 static WebIDL::ExceptionOr<JS::NonnullGCPtr<CloseEvent>> create(JS::Realm&, FlyString const& event_name, CloseEventInit const& event_init = {}); 26 static WebIDL::ExceptionOr<JS::NonnullGCPtr<CloseEvent>> construct_impl(JS::Realm&, FlyString const& event_name, CloseEventInit const& event_init); 27 28 virtual ~CloseEvent() override; 29 30 bool was_clean() const { return m_was_clean; } 31 u16 code() const { return m_code; } 32 String reason() const { return m_reason; } 33 34private: 35 CloseEvent(JS::Realm&, FlyString const& event_name, CloseEventInit const& event_init); 36 37 virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; 38 39 bool m_was_clean { false }; 40 u16 m_code { 0 }; 41 String m_reason; 42}; 43 44}