1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:57:45 +00:00

LibWeb: Change StackingContext::hit_test() to accept callback

This change modifies hit_test() to no longer return the first paintable
encountered at a specified position. Instead, this function accepts a
callback that is invoked for each paintable located at a position, in
hit-testing order.

This modification will allow us to reuse this call for
`Document.elementsFromPoint()` in upcoming changes.
This commit is contained in:
Aliaksandr Kalenik 2024-02-13 21:34:07 +01:00 committed by Andreas Kling
parent 15d151ee66
commit 9c99182b1e
11 changed files with 120 additions and 104 deletions

View file

@ -136,7 +136,8 @@ public:
virtual void apply_clip_overflow_rect(PaintContext&, PaintPhase) const override;
virtual void clear_clip_overflow_rect(PaintContext&, PaintPhase) const override;
virtual Optional<HitTestResult> hit_test(CSSPixelPoint, HitTestType) const override;
[[nodiscard]] virtual TraversalDecision hit_test(CSSPixelPoint position, HitTestType type, Function<TraversalDecision(HitTestResult)> const& callback) const override;
Optional<HitTestResult> hit_test(CSSPixelPoint, HitTestType) const;
virtual bool handle_mousewheel(Badge<EventHandler>, CSSPixelPoint, unsigned buttons, unsigned modifiers, int wheel_delta_x, int wheel_delta_y) override;
@ -286,7 +287,7 @@ public:
virtual void paint(PaintContext&, PaintPhase) const override;
virtual bool wants_mouse_events() const override { return false; }
virtual Optional<HitTestResult> hit_test(CSSPixelPoint, HitTestType) const override;
[[nodiscard]] virtual TraversalDecision hit_test(CSSPixelPoint position, HitTestType type, Function<TraversalDecision(HitTestResult)> const& callback) const override;
virtual void visit_edges(Cell::Visitor& visitor) override
{