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

LibWeb: Account for scroll offset in hit-testing

The hit-testing position is now shifted by the scroll offsets before
performing any checks for containment. This is implemented by assigning
each PaintableBox/InlinePaintable an offset corresponding to the scroll
frame in which it is contained. The non-scroll-adjusted position is
still passed down when recursing to children because the assigned
offset accumulated for nested scroll frames.

With this change, hit testing works in the Inspector.
Fixes https://github.com/SerenityOS/serenity/issues/22068
This commit is contained in:
Aliaksandr Kalenik 2024-01-29 06:28:17 +01:00 committed by Andreas Kling
parent beb1c85b6b
commit 556679fedd
7 changed files with 81 additions and 10 deletions

View file

@ -195,6 +195,7 @@ public:
void set_clip_rect(Optional<CSSPixelRect> rect) { m_clip_rect = rect; }
void set_scroll_frame_id(int id) { m_scroll_frame_id = id; }
void set_enclosing_scroll_frame_offset(CSSPixelPoint offset) { m_enclosing_scroll_frame_offset = offset; }
void set_corner_clip_radii(CornerRadii const& corner_radii) { m_corner_clip_radii = corner_radii; }
protected:
@ -208,6 +209,8 @@ protected:
virtual CSSPixelRect compute_absolute_rect() const;
virtual CSSPixelRect compute_absolute_paint_rect() const;
Optional<CSSPixelPoint> enclosing_scroll_frame_offset() const { return m_enclosing_scroll_frame_offset; }
private:
[[nodiscard]] virtual bool is_paintable_box() const final { return true; }
@ -224,6 +227,7 @@ private:
Optional<CSSPixelRect> m_clip_rect;
Optional<int> m_scroll_frame_id;
Optional<CSSPixelPoint> m_enclosing_scroll_frame_offset;
Optional<CornerRadii> m_corner_clip_radii;
Optional<BordersDataWithElementKind> m_override_borders_data;