summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/UIEvents
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibWeb/UIEvents')
-rw-r--r--Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp21
-rw-r--r--Userland/Libraries/LibWeb/UIEvents/FocusEvent.h32
-rw-r--r--Userland/Libraries/LibWeb/UIEvents/FocusEvent.idl15
3 files changed, 68 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp
new file mode 100644
index 0000000000..3397fc7b60
--- /dev/null
+++ b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibWeb/UIEvents/FocusEvent.h>
+
+namespace Web::UIEvents {
+
+FocusEvent::FocusEvent(FlyString const& event_name, FocusEventInit const& event_init)
+ : UIEvent(event_name)
+{
+ set_related_target(const_cast<DOM::EventTarget*>(event_init.related_target.ptr()));
+}
+
+FocusEvent::~FocusEvent()
+{
+}
+
+}
diff --git a/Userland/Libraries/LibWeb/UIEvents/FocusEvent.h b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.h
new file mode 100644
index 0000000000..4a244dbede
--- /dev/null
+++ b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <LibWeb/UIEvents/UIEvent.h>
+
+namespace Web::UIEvents {
+
+struct FocusEventInit : public UIEventInit {
+ RefPtr<DOM::EventTarget> related_target;
+};
+
+class FocusEvent final : public UIEvent {
+public:
+ using WrapperType = Bindings::FocusEventWrapper;
+
+ virtual ~FocusEvent() override;
+
+ static NonnullRefPtr<FocusEvent> create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, FocusEventInit const& event_init)
+ {
+ return adopt_ref(*new FocusEvent(event_name, event_init));
+ }
+
+private:
+ FocusEvent(FlyString const& event_name, FocusEventInit const&);
+};
+
+}
diff --git a/Userland/Libraries/LibWeb/UIEvents/FocusEvent.idl b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.idl
new file mode 100644
index 0000000000..1cba0af8fd
--- /dev/null
+++ b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.idl
@@ -0,0 +1,15 @@
+#import <UIEvents/UIEvent.idl>
+
+[Exposed=Window]
+interface FocusEvent : UIEvent {
+
+ constructor(DOMString type, optional FocusEventInit eventInitDict = {});
+ readonly attribute EventTarget? relatedTarget;
+
+};
+
+dictionary FocusEventInit : UIEventInit {
+
+ EventTarget? relatedTarget = null;
+
+};