1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 23:17:45 +00:00

LibWeb: Port KeyboardEvent to new String

This commit is contained in:
Kenneth Myhra 2023-03-09 21:35:15 +01:00 committed by Andreas Kling
parent e14be3927a
commit 03d6cb88ff
5 changed files with 26 additions and 23 deletions

View file

@ -6,6 +6,7 @@
#pragma once
#include <AK/FlyString.h>
#include <AK/TypeCasts.h>
#include <Kernel/API/KeyCode.h>
#include <LibWeb/UIEvents/EventModifier.h>
@ -14,8 +15,8 @@
namespace Web::UIEvents {
struct KeyboardEventInit : public EventModifierInit {
DeprecatedString key { "" };
DeprecatedString code { "" };
String key;
String code;
u32 location { 0 };
bool repeat { false };
bool is_composing { false };
@ -28,17 +29,17 @@ class KeyboardEvent final : public UIEvent {
WEB_PLATFORM_OBJECT(KeyboardEvent, UIEvent);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<KeyboardEvent>> create(JS::Realm&, DeprecatedFlyString const& event_name, KeyboardEventInit const& event_init = {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<KeyboardEvent>> construct_impl(JS::Realm&, DeprecatedFlyString const& event_name, KeyboardEventInit const& event_init);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<KeyboardEvent>> create_from_platform_event(JS::Realm&, DeprecatedFlyString const& event_name, KeyCode, unsigned modifiers, u32 code_point);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<KeyboardEvent>> create(JS::Realm&, FlyString const& event_name, KeyboardEventInit const& event_init = {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<KeyboardEvent>> construct_impl(JS::Realm&, FlyString const& event_name, KeyboardEventInit const& event_init);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<KeyboardEvent>> create_from_platform_event(JS::Realm&, FlyString const& event_name, KeyCode, unsigned modifiers, u32 code_point);
virtual ~KeyboardEvent() override;
u32 key_code() const { return m_key_code; }
u32 char_code() const { return m_char_code; }
DeprecatedString key() const { return m_key; }
DeprecatedString code() const { return m_code; }
String key() const { return m_key; }
String code() const { return m_code; }
u32 location() const { return m_location; }
bool ctrl_key() const { return m_ctrl_key; }
@ -49,17 +50,17 @@ public:
bool repeat() const { return m_repeat; }
bool is_composing() const { return m_is_composing; }
bool get_modifier_state(DeprecatedString const& key_arg);
bool get_modifier_state(String const& key_arg);
virtual u32 which() const override { return m_key_code; }
private:
KeyboardEvent(JS::Realm&, DeprecatedFlyString const& event_name, KeyboardEventInit const& event_init);
KeyboardEvent(JS::Realm&, FlyString const& event_name, KeyboardEventInit const& event_init);
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
DeprecatedString m_key;
DeprecatedString m_code;
String m_key;
String m_code;
u32 m_location { 0 };
bool m_ctrl_key { false };
bool m_shift_key { false };