1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09:00

LibWeb: Implement MouseEvent.initMouseEvent

This commit is contained in:
Jamie Mansfield 2024-07-17 12:26:20 +01:00 committed by Tim Ledbetter
parent 3845d174e3
commit 807e63faaf
Notes: sideshowbarker 2024-07-18 02:43:40 +09:00
3 changed files with 32 additions and 0 deletions

View file

@ -96,6 +96,33 @@ bool MouseEvent::get_modifier_state(String const& key_arg) const
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 thiss 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
static i16 determine_button(unsigned mouse_button)
{

View file

@ -68,6 +68,8 @@ public:
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:
MouseEvent(JS::Realm&, FlyString const& event_name, MouseEventInit const& event_init, double page_x, double page_y, double offset_x, double offset_y);

View file

@ -32,6 +32,9 @@ interface MouseEvent : UIEvent {
readonly attribute EventTarget? relatedTarget;
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