/src/serenity/Userland/Libraries/LibWeb/UIEvents/CompositionEvent.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #include <LibWeb/Bindings/CompositionEventPrototype.h> |
8 | | #include <LibWeb/Bindings/Intrinsics.h> |
9 | | #include <LibWeb/UIEvents/CompositionEvent.h> |
10 | | |
11 | | namespace Web::UIEvents { |
12 | | |
13 | | JS_DEFINE_ALLOCATOR(CompositionEvent); |
14 | | |
15 | | JS::NonnullGCPtr<CompositionEvent> CompositionEvent::create(JS::Realm& realm, FlyString const& event_name, CompositionEventInit const& event_init) |
16 | 0 | { |
17 | 0 | return realm.heap().allocate<CompositionEvent>(realm, realm, event_name, event_init); |
18 | 0 | } |
19 | | |
20 | | WebIDL::ExceptionOr<JS::NonnullGCPtr<CompositionEvent>> CompositionEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, CompositionEventInit const& event_init) |
21 | 0 | { |
22 | 0 | return realm.heap().allocate<CompositionEvent>(realm, realm, event_name, event_init); |
23 | 0 | } |
24 | | |
25 | | CompositionEvent::CompositionEvent(JS::Realm& realm, FlyString const& event_name, CompositionEventInit const& event_init) |
26 | 0 | : UIEvent(realm, event_name, event_init) |
27 | 0 | , m_data(event_init.data) |
28 | 0 | { |
29 | 0 | } |
30 | | |
31 | 0 | CompositionEvent::~CompositionEvent() = default; |
32 | | |
33 | | void CompositionEvent::initialize(JS::Realm& realm) |
34 | 0 | { |
35 | 0 | Base::initialize(realm); |
36 | 0 | WEB_SET_PROTOTYPE_FOR_INTERFACE(CompositionEvent); |
37 | 0 | } |
38 | | |
39 | | // https://w3c.github.io/uievents/#dom-compositionevent-initcompositionevent |
40 | | void CompositionEvent::init_composition_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, String const& data) |
41 | 0 | { |
42 | | // Initializes attributes of a CompositionEvent object. This method has the same behavior as UIEvent.initUIEvent(). |
43 | | // The value of detail remains undefined. |
44 | | |
45 | | // 1. If this’s dispatch flag is set, then return. |
46 | 0 | if (dispatched()) |
47 | 0 | return; |
48 | | |
49 | | // 2. Initialize this with type, bubbles, and cancelable. |
50 | 0 | initialize_event(type, bubbles, cancelable); |
51 | | |
52 | | // Implementation Defined: Initialise other values. |
53 | 0 | m_view = view; |
54 | 0 | m_data = data; |
55 | 0 | } |
56 | | |
57 | | } |