mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-14 13:32:23 +00:00
LibWeb: Implement KeyboardEvent.initKeyboardEvent
This commit is contained in:
parent
aefab1de38
commit
3845d174e3
Notes:
sideshowbarker
2024-07-18 02:43:43 +09:00
Author: https://github.com/jamierocks
Commit: 3845d174e3
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/682
Reviewed-by: https://github.com/tcl3 ✅
3 changed files with 28 additions and 0 deletions
|
@ -683,6 +683,29 @@ bool KeyboardEvent::get_modifier_state(String const& key_arg) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://w3c.github.io/uievents/#dom-keyboardevent-initkeyboardevent
|
||||||
|
void KeyboardEvent::init_keyboard_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, String const& key, WebIDL::UnsignedLong location, bool ctrl_key, bool alt_key, bool shift_key, bool meta_key)
|
||||||
|
{
|
||||||
|
// Initializes attributes of a KeyboardEvent object. This method has the same behavior as UIEvent.initUIEvent().
|
||||||
|
// The value of detail remains undefined.
|
||||||
|
|
||||||
|
// 1. If this’s dispatch flag is set, then return.
|
||||||
|
if (dispatched())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 2. Initialize this with type, bubbles, and cancelable.
|
||||||
|
initialize_event(type, bubbles, cancelable);
|
||||||
|
|
||||||
|
// Implementation Defined: Initialise other values.
|
||||||
|
m_view = view;
|
||||||
|
m_key = key;
|
||||||
|
m_location = location;
|
||||||
|
m_ctrl_key = ctrl_key;
|
||||||
|
m_alt_key = alt_key;
|
||||||
|
m_shift_key = shift_key;
|
||||||
|
m_meta_key = meta_key;
|
||||||
|
}
|
||||||
|
|
||||||
JS::NonnullGCPtr<KeyboardEvent> KeyboardEvent::create(JS::Realm& realm, FlyString const& event_name, KeyboardEventInit const& event_init)
|
JS::NonnullGCPtr<KeyboardEvent> KeyboardEvent::create(JS::Realm& realm, FlyString const& event_name, KeyboardEventInit const& event_init)
|
||||||
{
|
{
|
||||||
return realm.heap().allocate<KeyboardEvent>(realm, realm, event_name, event_init);
|
return realm.heap().allocate<KeyboardEvent>(realm, realm, event_name, event_init);
|
||||||
|
|
|
@ -62,6 +62,8 @@ public:
|
||||||
|
|
||||||
virtual u32 which() const override { return m_key_code; }
|
virtual u32 which() const override { return m_key_code; }
|
||||||
|
|
||||||
|
void init_keyboard_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, String const& key, WebIDL::UnsignedLong location, bool ctrl_key, bool alt_key, bool shift_key, bool meta_key);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KeyboardEvent(JS::Realm&, FlyString const& event_name, KeyboardEventInit const& event_init);
|
KeyboardEvent(JS::Realm&, FlyString const& event_name, KeyboardEventInit const& event_init);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,9 @@ interface KeyboardEvent : UIEvent {
|
||||||
|
|
||||||
boolean getModifierState(DOMString keyArg);
|
boolean getModifierState(DOMString keyArg);
|
||||||
|
|
||||||
|
// https://w3c.github.io/uievents/#dom-keyboardevent-initkeyboardevent
|
||||||
|
undefined initKeyboardEvent(DOMString typeArg, optional boolean bubblesArg = false, optional boolean cancelableArg = false, optional Window? viewArg = null, optional DOMString keyArg = "", optional unsigned long locationArg = 0, optional boolean ctrlKey = false, optional boolean altKey = false, optional boolean shiftKey = false, optional boolean metaKey = false);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://www.w3.org/TR/uievents/#dictdef-keyboardeventinit
|
// https://www.w3.org/TR/uievents/#dictdef-keyboardeventinit
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue