/* * Copyright (c) 2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include #include #include #include #include namespace Web { class EventHandler { public: explicit EventHandler(Badge, HTML::Navigable&); ~EventHandler(); EventResult handle_mouseup(CSSPixelPoint, CSSPixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers); EventResult handle_mousedown(CSSPixelPoint, CSSPixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers); EventResult handle_mousemove(CSSPixelPoint, CSSPixelPoint screen_position, unsigned buttons, unsigned modifiers); EventResult handle_mousewheel(CSSPixelPoint, CSSPixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers, int wheel_delta_x, int wheel_delta_y); EventResult handle_doubleclick(CSSPixelPoint, CSSPixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers); EventResult handle_drag_and_drop_event(DragEvent::Type, CSSPixelPoint, CSSPixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers, Vector files); EventResult handle_keydown(UIEvents::KeyCode, unsigned modifiers, u32 code_point, bool repeat); EventResult handle_keyup(UIEvents::KeyCode, unsigned modifiers, u32 code_point, bool repeat); void set_mouse_event_tracking_paintable(Painting::Paintable*); void handle_paste(String const& text); void visit_edges(JS::Cell::Visitor& visitor) const; Unicode::Segmenter& word_segmenter(); private: bool focus_next_element(); bool focus_previous_element(); EventResult fire_keyboard_event(FlyString const& event_name, HTML::Navigable&, UIEvents::KeyCode, unsigned modifiers, u32 code_point, bool repeat); [[nodiscard]] EventResult input_event(FlyString const& event_name, FlyString const& input_type, HTML::Navigable&, u32 code_point); CSSPixelPoint compute_mouse_event_client_offset(CSSPixelPoint event_page_position) const; CSSPixelPoint compute_mouse_event_page_offset(CSSPixelPoint event_client_offset) const; CSSPixelPoint compute_mouse_event_movement(CSSPixelPoint event_client_offset) const; struct Target { GC::Ptr paintable; Optional index_in_node; }; Optional target_for_mouse_position(CSSPixelPoint position); Painting::PaintableBox* paint_root(); Painting::PaintableBox const* paint_root() const; bool should_ignore_device_input_event() const; GC::Ref m_navigable; bool m_in_mouse_selection { false }; InputEventsTarget* m_mouse_selection_target { nullptr }; GC::Ptr m_mouse_event_tracking_paintable; NonnullOwnPtr m_drag_and_drop_event_handler; WeakPtr m_mousedown_target; Optional m_mousemove_previous_screen_position; OwnPtr m_word_segmenter; }; }