LibWeb: Move adjustmust of scrollbar offset into compute_scrollbar_data

Currently, compute_scrollbar_data does not adjust the position of the
scrollbar thumb based on the actual scroll offset. This is because we
perform this offset in most cases inside the display list executor, in
order to allow us to avoid recomputing the display list.

However, there are cases where we do want the thumb rect with an offset
inside PaintableBox. We currently use scroll_thumb_rect to perform that
computation.

In an upcoming patch, we will need both this offset thumb rect and the
scrollbar gutter rect. So this patch moves the computation of the offset
to compute_scrollbar_data, performed behind an optional parameter.
This commit is contained in:
Timothy Flynn 2025-04-21 10:15:13 -04:00 committed by Tim Flynn
commit a135ce528e
Notes: github-actions[bot] 2025-04-22 15:30:08 +00:00
2 changed files with 24 additions and 27 deletions

View file

@ -266,8 +266,11 @@ protected:
Horizontal,
Vertical,
};
Optional<ScrollbarData> compute_scrollbar_data(ScrollDirection) const;
[[nodiscard]] Optional<CSSPixelRect> scroll_thumb_rect(ScrollDirection) const;
enum class AdjustThumbRectForScrollOffset {
No,
Yes,
};
Optional<ScrollbarData> compute_scrollbar_data(ScrollDirection, AdjustThumbRectForScrollOffset = AdjustThumbRectForScrollOffset::No) const;
[[nodiscard]] bool could_be_scrolled_by_wheel_event(ScrollDirection) const;
TraversalDecision hit_test_scrollbars(CSSPixelPoint position, Function<TraversalDecision(HitTestResult)> const& callback) const;