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

LibWeb: Use clip rectangles assigned to paintables in hit-testing

This change makes hit-testing more consistent in the handling of hidden
overflow by reusing the same clip-rectangles.

Also, it fixes bugs where the box is visible for hit-testing even
though it is clipped by the hidden overflow of the containing block.
This commit is contained in:
Aliaksandr Kalenik 2024-01-30 10:02:07 +01:00 committed by Andreas Kling
parent d3b983b201
commit 16f1962f10
8 changed files with 64 additions and 28 deletions

View file

@ -182,6 +182,9 @@ void InlinePaintable::for_each_fragment(Callback callback) const
Optional<HitTestResult> InlinePaintable::hit_test(CSSPixelPoint position, HitTestType type) const
{
if (m_clip_rect.has_value() && !m_clip_rect.value().contains(position))
return {};
auto position_adjusted_by_scroll_offset = position;
if (m_enclosing_scroll_frame_offset.has_value())
position_adjusted_by_scroll_offset.translate_by(-m_enclosing_scroll_frame_offset.value());