diff --git a/Userland/Libraries/LibWeb/Layout/BlockBox.cpp b/Userland/Libraries/LibWeb/Layout/BlockBox.cpp index d46b743721..5a9f2b5c43 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockBox.cpp @@ -156,13 +156,15 @@ void BlockBox::set_scroll_offset(const Gfx::FloatPoint& offset) set_needs_display(); } -void BlockBox::handle_mousewheel(Badge, const Gfx::IntPoint&, unsigned int, unsigned int, int wheel_delta) +bool BlockBox::handle_mousewheel(Badge, const Gfx::IntPoint&, unsigned int, unsigned int, int wheel_delta) { if (!is_scrollable()) - return; + return false; auto new_offset = m_scroll_offset; new_offset.move_by(0, wheel_delta); set_scroll_offset(new_offset); + + return true; } } diff --git a/Userland/Libraries/LibWeb/Layout/BlockBox.h b/Userland/Libraries/LibWeb/Layout/BlockBox.h index 5d6951a0e0..269a6b939c 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockBox.h +++ b/Userland/Libraries/LibWeb/Layout/BlockBox.h @@ -60,7 +60,7 @@ public: private: virtual bool is_block_box() const final { return true; } virtual bool wants_mouse_events() const override { return true; } - virtual void handle_mousewheel(Badge, const Gfx::IntPoint&, unsigned buttons, unsigned modifiers, int wheel_delta) override; + virtual bool handle_mousewheel(Badge, const Gfx::IntPoint&, unsigned buttons, unsigned modifiers, int wheel_delta) override; bool should_clip_overflow() const; diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp index 7a72dfbca5..b2c1cd4661 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.cpp +++ b/Userland/Libraries/LibWeb/Layout/Node.cpp @@ -322,15 +322,18 @@ void Node::handle_mousemove(Badge, const Gfx::IntPoint&, unsigned, { } -void Node::handle_mousewheel(Badge, const Gfx::IntPoint&, unsigned, unsigned, int wheel_delta) +bool Node::handle_mousewheel(Badge, const Gfx::IntPoint&, unsigned, unsigned, int wheel_delta) { if (auto* containing_block = this->containing_block()) { if (!containing_block->is_scrollable()) - return; + return false; auto new_offset = containing_block->scroll_offset(); new_offset.move_by(0, wheel_delta); containing_block->set_scroll_offset(new_offset); + return true; } + + return false; } bool Node::is_root_element() const diff --git a/Userland/Libraries/LibWeb/Layout/Node.h b/Userland/Libraries/LibWeb/Layout/Node.h index 653baa5264..917f9607b3 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.h +++ b/Userland/Libraries/LibWeb/Layout/Node.h @@ -109,7 +109,7 @@ public: virtual void handle_mousedown(Badge, const Gfx::IntPoint&, unsigned button, unsigned modifiers); virtual void handle_mouseup(Badge, const Gfx::IntPoint&, unsigned button, unsigned modifiers); virtual void handle_mousemove(Badge, const Gfx::IntPoint&, unsigned buttons, unsigned modifiers); - virtual void handle_mousewheel(Badge, const Gfx::IntPoint&, unsigned buttons, unsigned modifiers, int wheel_delta); + virtual bool handle_mousewheel(Badge, const Gfx::IntPoint&, unsigned buttons, unsigned modifiers, int wheel_delta); virtual void before_children_paint(PaintContext&, PaintPhase) {}; virtual void paint(PaintContext&, PaintPhase); diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index 688dc0b9c2..f4f4cd886d 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -139,7 +139,8 @@ bool EventHandler::handle_mousewheel(const Gfx::IntPoint& position, unsigned int auto result = layout_root()->hit_test(position, Layout::HitTestType::Exact); if (result.layout_node) { - result.layout_node->handle_mousewheel({}, position, buttons, modifiers, wheel_delta); + if (result.layout_node->handle_mousewheel({}, position, buttons, modifiers, wheel_delta)) + return true; return true; }