mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-06 01:26:22 +00:00
LibWeb: Implement MouseEvent.initMouseEvent
This commit is contained in:
parent
3845d174e3
commit
807e63faaf
Notes:
sideshowbarker
2024-07-18 02:43:40 +09:00
Author: https://github.com/jamierocks
Commit: 807e63faaf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/682
Reviewed-by: https://github.com/tcl3 ✅
3 changed files with 32 additions and 0 deletions
|
@ -96,6 +96,33 @@ bool MouseEvent::get_modifier_state(String const& key_arg) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://w3c.github.io/uievents/#dom-mouseevent-initmouseevent
|
||||||
|
void MouseEvent::init_mouse_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, WebIDL::Long detail, WebIDL::Long screen_x, WebIDL::Long screen_y, WebIDL::Long client_x, WebIDL::Long client_y, bool ctrl_key, bool alt_key, bool shift_key, bool meta_key, WebIDL::Short button, DOM::EventTarget* related_target)
|
||||||
|
{
|
||||||
|
// Initializes attributes of a MouseEvent object. This method has the same behavior as UIEvent.initUIEvent().
|
||||||
|
|
||||||
|
// 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_detail = detail;
|
||||||
|
m_screen_x = screen_x;
|
||||||
|
m_screen_y = screen_y;
|
||||||
|
m_client_x = client_x;
|
||||||
|
m_client_y = client_y;
|
||||||
|
m_ctrl_key = ctrl_key;
|
||||||
|
m_shift_key = shift_key;
|
||||||
|
m_alt_key = alt_key;
|
||||||
|
m_meta_key = meta_key;
|
||||||
|
m_button = button;
|
||||||
|
m_related_target = related_target;
|
||||||
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/uievents/#dom-mouseevent-button
|
// https://www.w3.org/TR/uievents/#dom-mouseevent-button
|
||||||
static i16 determine_button(unsigned mouse_button)
|
static i16 determine_button(unsigned mouse_button)
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,6 +68,8 @@ public:
|
||||||
|
|
||||||
virtual u32 which() const override { return m_button + 1; }
|
virtual u32 which() const override { return m_button + 1; }
|
||||||
|
|
||||||
|
void init_mouse_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, WebIDL::Long detail, WebIDL::Long screen_x, WebIDL::Long screen_y, WebIDL::Long client_x, WebIDL::Long client_y, bool ctrl_key, bool alt_key, bool shift_key, bool meta_key, WebIDL::Short button, DOM::EventTarget* related_target);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MouseEvent(JS::Realm&, FlyString const& event_name, MouseEventInit const& event_init, double page_x, double page_y, double offset_x, double offset_y);
|
MouseEvent(JS::Realm&, FlyString const& event_name, MouseEventInit const& event_init, double page_x, double page_y, double offset_x, double offset_y);
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,9 @@ interface MouseEvent : UIEvent {
|
||||||
readonly attribute EventTarget? relatedTarget;
|
readonly attribute EventTarget? relatedTarget;
|
||||||
|
|
||||||
boolean getModifierState(DOMString keyArg);
|
boolean getModifierState(DOMString keyArg);
|
||||||
|
|
||||||
|
// https://w3c.github.io/uievents/#dom-mouseevent-initmouseevent
|
||||||
|
undefined initMouseEvent(DOMString typeArg, optional boolean bubblesArg = false, optional boolean cancelableArg = false, optional Window? viewArg = null, optional long detailArg = 0, optional long screenXArg = 0, optional long screenYArg = 0, optional long clientXArg = 0, optional long clientYArg = 0, optional boolean ctrlKeyArg = false, optional boolean altKeyArg = false, optional boolean shiftKeyArg = false, optional boolean metaKeyArg = false, optional short buttonArg = 0, optional EventTarget? relatedTargetArg = null);
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://w3c.github.io/uievents/#idl-mouseeventinit
|
// https://w3c.github.io/uievents/#idl-mouseeventinit
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue