Paintable.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/DOM/Document.h>
  7. #include <LibWeb/Layout/BlockContainer.h>
  8. #include <LibWeb/Painting/Paintable.h>
  9. namespace Web::Painting {
  10. void Paintable::handle_mousedown(Badge<EventHandler>, Gfx::IntPoint const&, unsigned, unsigned)
  11. {
  12. }
  13. void Paintable::handle_mouseup(Badge<EventHandler>, Gfx::IntPoint const&, unsigned, unsigned)
  14. {
  15. }
  16. void Paintable::handle_mousemove(Badge<EventHandler>, Gfx::IntPoint const&, unsigned, unsigned)
  17. {
  18. }
  19. bool Paintable::handle_mousewheel(Badge<EventHandler>, Gfx::IntPoint const&, unsigned, unsigned, int wheel_delta_x, int wheel_delta_y)
  20. {
  21. if (auto* containing_block = this->containing_block()) {
  22. if (!containing_block->is_scrollable())
  23. return false;
  24. auto new_offset = containing_block->scroll_offset();
  25. new_offset.translate_by(wheel_delta_x, wheel_delta_y);
  26. // FIXME: This const_cast is gross.
  27. // FIXME: Scroll offset shouldn't live in the layout tree.
  28. const_cast<Layout::BlockContainer*>(containing_block)->set_scroll_offset(new_offset);
  29. return true;
  30. }
  31. return false;
  32. }
  33. HitTestResult Paintable::hit_test(Gfx::IntPoint const&, HitTestType) const
  34. {
  35. VERIFY_NOT_REACHED();
  36. }
  37. }