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

LibWeb: Move mouse wheel handling from Paintable to PaintableBox

It is only PaintableBox that can have scrollable overflow so it doesn't
make sense to have handle_mousewheel() implementation in Paintable.

Also new implementation of handle_mousewheel() takes in account overflow
limits from scrollable_overflow_rect().
This commit is contained in:
Aliaksandr Kalenik 2023-08-06 14:28:23 +02:00 committed by Andreas Kling
parent 55b5c61a79
commit c7673605bb
3 changed files with 10 additions and 17 deletions

View file

@ -34,19 +34,8 @@ Paintable::DispatchEventOfSameName Paintable::handle_mousemove(Badge<EventHandle
return DispatchEventOfSameName::Yes;
}
bool Paintable::handle_mousewheel(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned, int wheel_delta_x, int wheel_delta_y)
bool Paintable::handle_mousewheel(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned, int, int)
{
if (auto const* containing_block = this->containing_block()) {
if (!containing_block->is_scrollable())
return false;
auto new_offset = containing_block->scroll_offset();
new_offset.translate_by(wheel_delta_x, wheel_delta_y);
// FIXME: This const_cast is gross.
// FIXME: Scroll offset shouldn't live in the layout tree.
const_cast<Layout::Box*>(containing_block)->set_scroll_offset(new_offset);
return true;
}
return false;
}