/src/serenity/Userland/Libraries/LibWeb/HTML/ToggleEvent.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <AK/FlyString.h> |
10 | | #include <AK/String.h> |
11 | | #include <LibWeb/DOM/Event.h> |
12 | | |
13 | | namespace Web::HTML { |
14 | | |
15 | | struct ToggleEventInit : public DOM::EventInit { |
16 | | String old_state; |
17 | | String new_state; |
18 | | }; |
19 | | |
20 | | class ToggleEvent : public DOM::Event { |
21 | | WEB_PLATFORM_OBJECT(ToggleEvent, DOM::Event); |
22 | | JS_DECLARE_ALLOCATOR(ToggleEvent); |
23 | | |
24 | | public: |
25 | | [[nodiscard]] static JS::NonnullGCPtr<ToggleEvent> create(JS::Realm&, FlyString const& event_name, ToggleEventInit = {}); |
26 | | static WebIDL::ExceptionOr<JS::NonnullGCPtr<ToggleEvent>> construct_impl(JS::Realm&, FlyString const& event_name, ToggleEventInit); |
27 | | |
28 | | // https://html.spec.whatwg.org/multipage/interaction.html#dom-toggleevent-oldstate |
29 | 0 | String const& old_state() const { return m_old_state; } |
30 | | |
31 | | // https://html.spec.whatwg.org/multipage/interaction.html#dom-toggleevent-newstate |
32 | 0 | String const& new_state() const { return m_new_state; } |
33 | | |
34 | | private: |
35 | | ToggleEvent(JS::Realm&, FlyString const& event_name, ToggleEventInit event_init); |
36 | | |
37 | | virtual void initialize(JS::Realm&) override; |
38 | | |
39 | | String m_old_state; |
40 | | String m_new_state; |
41 | | }; |
42 | | |
43 | | } |