summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp
blob: dd6c7a3c65e8942888f9d4dfcbdf528617097d1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * Copyright (c) 2020, the SerenityOS developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/UIEvents/EventNames.h>
#include <LibWeb/UIEvents/MouseEvent.h>

namespace Web::UIEvents {

MouseEvent::MouseEvent(const FlyString& event_name, i32 offset_x, i32 offset_y, i32 client_x, i32 client_y)
    : UIEvent(event_name)
    , m_offset_x(offset_x)
    , m_offset_y(offset_y)
    , m_client_x(client_x)
    , m_client_y(client_y)
{
    set_event_characteristics();
}

MouseEvent::~MouseEvent()
{
}

void MouseEvent::set_event_characteristics()
{
    if (type().is_one_of(EventNames::mousedown, EventNames::mousemove, EventNames::mouseout, EventNames::mouseover, EventNames::mouseup, HTML::EventNames::click)) {
        set_bubbles(true);
        set_cancelable(true);
        set_composed(true);
    }
}

}