Paintable.cpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (c) 2022-2023, 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. #include <LibWeb/Painting/PaintableBox.h>
  10. namespace Web::Painting {
  11. void Paintable::visit_edges(Cell::Visitor& visitor)
  12. {
  13. Base::visit_edges(visitor);
  14. visitor.visit(m_layout_node);
  15. if (m_containing_block.has_value())
  16. visitor.visit(m_containing_block.value());
  17. }
  18. Paintable::DispatchEventOfSameName Paintable::handle_mousedown(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned)
  19. {
  20. return DispatchEventOfSameName::Yes;
  21. }
  22. Paintable::DispatchEventOfSameName Paintable::handle_mouseup(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned)
  23. {
  24. return DispatchEventOfSameName::Yes;
  25. }
  26. Paintable::DispatchEventOfSameName Paintable::handle_mousemove(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned)
  27. {
  28. return DispatchEventOfSameName::Yes;
  29. }
  30. bool Paintable::handle_mousewheel(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned, int, int)
  31. {
  32. return false;
  33. }
  34. Optional<HitTestResult> Paintable::hit_test(CSSPixelPoint, HitTestType) const
  35. {
  36. return {};
  37. }
  38. Paintable const* Paintable::first_child() const
  39. {
  40. auto const* layout_child = m_layout_node->first_child();
  41. for (; layout_child && !layout_child->paintable(); layout_child = layout_child->next_sibling())
  42. ;
  43. return layout_child ? layout_child->paintable() : nullptr;
  44. }
  45. Paintable const* Paintable::next_sibling() const
  46. {
  47. auto const* layout_node = m_layout_node->next_sibling();
  48. for (; layout_node && !layout_node->paintable(); layout_node = layout_node->next_sibling())
  49. ;
  50. return layout_node ? layout_node->paintable() : nullptr;
  51. }
  52. Paintable const* Paintable::last_child() const
  53. {
  54. auto const* layout_child = m_layout_node->last_child();
  55. for (; layout_child && !layout_child->paintable(); layout_child = layout_child->previous_sibling())
  56. ;
  57. return layout_child ? layout_child->paintable() : nullptr;
  58. }
  59. Paintable const* Paintable::previous_sibling() const
  60. {
  61. auto const* layout_node = m_layout_node->previous_sibling();
  62. for (; layout_node && !layout_node->paintable(); layout_node = layout_node->previous_sibling())
  63. ;
  64. return layout_node ? layout_node->paintable() : nullptr;
  65. }
  66. StackingContext const* Paintable::stacking_context_rooted_here() const
  67. {
  68. if (!layout_node().is_box())
  69. return nullptr;
  70. return static_cast<PaintableBox const&>(*this).stacking_context();
  71. }
  72. }