EventHandler.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 BrowsingContext;
  17. class EventHandler {
  18. public:
  19. explicit EventHandler(Badge<BrowsingContext>, BrowsingContext&);
  20. ~EventHandler();
  21. bool handle_mouseup(const Gfx::IntPoint&, unsigned button, unsigned modifiers);
  22. bool handle_mousedown(const Gfx::IntPoint&, unsigned button, unsigned modifiers);
  23. bool handle_mousemove(const Gfx::IntPoint&, unsigned buttons, unsigned modifiers);
  24. bool handle_mousewheel(const Gfx::IntPoint&, unsigned buttons, unsigned modifiers, int wheel_delta);
  25. bool handle_keydown(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::InitialContainingBlockBox* layout_root();
  32. const Layout::InitialContainingBlockBox* layout_root() const;
  33. BrowsingContext& m_frame;
  34. bool m_in_mouse_selection { false };
  35. WeakPtr<Layout::Node> m_mouse_event_tracking_layout_node;
  36. NonnullOwnPtr<EditEventHandler> m_edit_event_handler;
  37. };
  38. }