summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Page/EventHandler.h
blob: 86ef6ac2f8af1ee17bcac3bc89591b9f39e1de0e (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Forward.h>
#include <AK/NonnullOwnPtr.h>
#include <AK/WeakPtr.h>
#include <Kernel/API/KeyCode.h>
#include <LibGUI/Forward.h>
#include <LibGfx/Forward.h>
#include <LibWeb/Forward.h>
#include <LibWeb/Page/EditEventHandler.h>

namespace Web {

class BrowsingContext;

class EventHandler {
public:
    explicit EventHandler(Badge<BrowsingContext>, BrowsingContext&);
    ~EventHandler();

    bool handle_mouseup(const Gfx::IntPoint&, unsigned button, unsigned modifiers);
    bool handle_mousedown(const Gfx::IntPoint&, unsigned button, unsigned modifiers);
    bool handle_mousemove(const Gfx::IntPoint&, unsigned buttons, unsigned modifiers);
    bool handle_mousewheel(const Gfx::IntPoint&, unsigned buttons, unsigned modifiers, int wheel_delta);

    bool handle_keydown(KeyCode, unsigned modifiers, u32 code_point);
    bool handle_keyup(KeyCode, unsigned modifiers, u32 code_point);

    void set_mouse_event_tracking_layout_node(Layout::Node*);

    void set_edit_event_handler(NonnullOwnPtr<EditEventHandler> value) { m_edit_event_handler = move(value); }

private:
    bool focus_next_element();
    bool focus_previous_element();

    Layout::InitialContainingBlock* layout_root();
    const Layout::InitialContainingBlock* layout_root() const;

    BrowsingContext& m_frame;

    bool m_in_mouse_selection { false };

    WeakPtr<Layout::Node> m_mouse_event_tracking_layout_node;

    NonnullOwnPtr<EditEventHandler> m_edit_event_handler;
};

}