EventHandler.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Forward.h>
  8. #include <AK/NonnullOwnPtr.h>
  9. #include <AK/WeakPtr.h>
  10. #include <Kernel/API/KeyCode.h>
  11. #include <LibGUI/Forward.h>
  12. #include <LibGfx/Forward.h>
  13. #include <LibWeb/Forward.h>
  14. #include <LibWeb/Page/EditEventHandler.h>
  15. namespace Web {
  16. class EventHandler {
  17. public:
  18. explicit EventHandler(Badge<HTML::BrowsingContext>, HTML::BrowsingContext&);
  19. ~EventHandler();
  20. bool handle_mouseup(Gfx::IntPoint const&, unsigned button, unsigned modifiers);
  21. bool handle_mousedown(Gfx::IntPoint const&, unsigned button, unsigned modifiers);
  22. bool handle_mousemove(Gfx::IntPoint const&, unsigned buttons, unsigned modifiers);
  23. bool handle_mousewheel(Gfx::IntPoint const&, unsigned buttons, unsigned modifiers, int wheel_delta_x, int wheel_delta_y);
  24. bool handle_keydown(KeyCode, unsigned modifiers, u32 code_point);
  25. bool handle_keyup(KeyCode, unsigned modifiers, u32 code_point);
  26. void set_mouse_event_tracking_layout_node(Layout::Node*);
  27. void set_edit_event_handler(NonnullOwnPtr<EditEventHandler> value) { m_edit_event_handler = move(value); }
  28. private:
  29. bool focus_next_element();
  30. bool focus_previous_element();
  31. Layout::InitialContainingBlock* layout_root();
  32. Layout::InitialContainingBlock const* layout_root() const;
  33. Painting::PaintableBox* paint_root();
  34. Painting::PaintableBox const* paint_root() const;
  35. HTML::BrowsingContext& m_browsing_context;
  36. bool m_in_mouse_selection { false };
  37. WeakPtr<Layout::Node> m_mouse_event_tracking_layout_node;
  38. NonnullOwnPtr<EditEventHandler> m_edit_event_handler;
  39. WeakPtr<DOM::EventTarget> m_mousedown_target;
  40. };
  41. }