2020-06-07 14:40:38 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-07 14:40:38 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Forward.h>
|
2021-01-21 20:55:37 +01:00
|
|
|
#include <AK/NonnullOwnPtr.h>
|
2020-09-11 18:15:47 +02:00
|
|
|
#include <AK/WeakPtr.h>
|
2020-08-02 12:10:01 +02:00
|
|
|
#include <Kernel/API/KeyCode.h>
|
2020-06-07 14:40:38 +02:00
|
|
|
#include <LibGUI/Forward.h>
|
|
|
|
#include <LibGfx/Forward.h>
|
|
|
|
#include <LibWeb/Forward.h>
|
2020-12-01 23:35:47 +01:00
|
|
|
#include <LibWeb/Page/EditEventHandler.h>
|
2022-11-02 17:35:53 +00:00
|
|
|
#include <LibWeb/PixelUnits.h>
|
2020-06-07 14:40:38 +02:00
|
|
|
|
|
|
|
namespace Web {
|
|
|
|
|
|
|
|
class EventHandler {
|
|
|
|
public:
|
2021-11-18 15:01:28 +01:00
|
|
|
explicit EventHandler(Badge<HTML::BrowsingContext>, HTML::BrowsingContext&);
|
2020-06-07 14:40:38 +02:00
|
|
|
~EventHandler();
|
|
|
|
|
2022-11-02 17:35:53 +00:00
|
|
|
bool handle_mouseup(CSSPixelPoint, unsigned button, unsigned buttons, unsigned modifiers);
|
|
|
|
bool handle_mousedown(CSSPixelPoint, unsigned button, unsigned buttons, unsigned modifiers);
|
|
|
|
bool handle_mousemove(CSSPixelPoint, unsigned buttons, unsigned modifiers);
|
|
|
|
bool handle_mousewheel(CSSPixelPoint, unsigned button, unsigned buttons, unsigned modifiers, int wheel_delta_x, int wheel_delta_y);
|
|
|
|
bool handle_doubleclick(CSSPixelPoint, unsigned button, unsigned buttons, unsigned modifiers);
|
2020-06-07 14:40:38 +02:00
|
|
|
|
2020-08-02 12:10:01 +02:00
|
|
|
bool handle_keydown(KeyCode, unsigned modifiers, u32 code_point);
|
2021-09-28 15:39:35 +02:00
|
|
|
bool handle_keyup(KeyCode, unsigned modifiers, u32 code_point);
|
2020-08-02 12:10:01 +02:00
|
|
|
|
2020-11-22 15:53:01 +01:00
|
|
|
void set_mouse_event_tracking_layout_node(Layout::Node*);
|
2020-09-11 18:15:47 +02:00
|
|
|
|
2020-12-01 23:35:47 +01:00
|
|
|
void set_edit_event_handler(NonnullOwnPtr<EditEventHandler> value) { m_edit_event_handler = move(value); }
|
|
|
|
|
2020-06-07 14:40:38 +02:00
|
|
|
private:
|
2020-08-14 19:40:37 +02:00
|
|
|
bool focus_next_element();
|
|
|
|
bool focus_previous_element();
|
|
|
|
|
2022-11-05 15:36:03 +00:00
|
|
|
bool fire_keyboard_event(FlyString const& event_name, HTML::BrowsingContext& browsing_context, KeyCode key, unsigned modifiers, u32 code_point);
|
2022-12-31 16:04:48 +02:00
|
|
|
CSSPixelPoint compute_mouse_event_client_offset(CSSPixelPoint event_page_position) const;
|
2022-11-05 15:36:03 +00:00
|
|
|
|
2021-09-08 11:27:46 +02:00
|
|
|
Layout::InitialContainingBlock* layout_root();
|
2022-04-01 20:58:27 +03:00
|
|
|
Layout::InitialContainingBlock const* layout_root() const;
|
2020-06-07 14:40:38 +02:00
|
|
|
|
2022-03-11 00:03:28 +01:00
|
|
|
Painting::PaintableBox* paint_root();
|
|
|
|
Painting::PaintableBox const* paint_root() const;
|
|
|
|
|
2022-02-06 14:41:29 +01:00
|
|
|
HTML::BrowsingContext& m_browsing_context;
|
2020-06-07 14:40:38 +02:00
|
|
|
|
|
|
|
bool m_in_mouse_selection { false };
|
2020-09-11 18:15:47 +02:00
|
|
|
|
2020-11-22 15:53:01 +01:00
|
|
|
WeakPtr<Layout::Node> m_mouse_event_tracking_layout_node;
|
2020-12-01 23:35:47 +01:00
|
|
|
|
|
|
|
NonnullOwnPtr<EditEventHandler> m_edit_event_handler;
|
2022-02-07 13:27:17 +01:00
|
|
|
|
|
|
|
WeakPtr<DOM::EventTarget> m_mousedown_target;
|
2020-06-07 14:40:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|