mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:07:36 +00:00
LibWeb: Make Layout::Node::containing_block() return a Layout::Box
Containing blocks can be formed by boxes that aren't block containers, so let's make this return a Box and work towards type correctness here.
This commit is contained in:
parent
d5480a44e5
commit
51555dea7c
6 changed files with 42 additions and 30 deletions
|
@ -36,13 +36,16 @@ Paintable::DispatchEventOfSameName Paintable::handle_mousemove(Badge<EventHandle
|
|||
bool Paintable::handle_mousewheel(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned, int wheel_delta_x, int wheel_delta_y)
|
||||
{
|
||||
if (auto* containing_block = this->containing_block()) {
|
||||
if (!containing_block->is_scrollable())
|
||||
if (!containing_block->is_block_container())
|
||||
return false;
|
||||
auto new_offset = containing_block->scroll_offset();
|
||||
auto* scroll_container = static_cast<Layout::BlockContainer const*>(containing_block);
|
||||
if (!scroll_container->is_scrollable())
|
||||
return false;
|
||||
auto new_offset = scroll_container->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::BlockContainer*>(containing_block)->set_scroll_offset(new_offset);
|
||||
const_cast<Layout::BlockContainer*>(scroll_container)->set_scroll_offset(new_offset);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue