diff options
author | Andreas Kling <kling@serenityos.org> | 2020-09-12 17:55:19 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-09-12 17:55:19 +0200 |
commit | 94c55d9e3707dfd2acbc3c7c48daad8cfcb69df1 (patch) | |
tree | 18c42374a3570df64006601554174a28300f980b /Libraries/LibWeb/Page | |
parent | d10368626152401af25cc36093579548a09133bb (diff) | |
download | serenity-94c55d9e3707dfd2acbc3c7c48daad8cfcb69df1.zip |
LibWeb: Two mouse event handling fixes
- After letting a LayoutNode handle a mouseup, re-do the hit test
since things may have changed.
- Make sure we always update the document's hovered node.
Diffstat (limited to 'Libraries/LibWeb/Page')
-rw-r--r-- | Libraries/LibWeb/Page/EventHandler.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cpp index 57b73c9673..3307290e5b 100644 --- a/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Libraries/LibWeb/Page/EventHandler.cpp @@ -87,6 +87,11 @@ bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button if (result.layout_node && result.layout_node->wants_mouse_events()) { result.layout_node->handle_mouseup({}, position, button, modifiers); + + // Things may have changed as a consequence of LayoutNode::handle_mouseup(). Hit test again. + if (!layout_root()) + return true; + result = layout_root()->hit_test(position, HitTestType::Exact); } if (result.layout_node && result.layout_node->node()) { @@ -125,13 +130,14 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt if (!result.layout_node) return false; + RefPtr<DOM::Node> node = result.layout_node->node(); + document->set_hovered_node(node); + if (result.layout_node->wants_mouse_events()) { result.layout_node->handle_mousedown({}, position, button, modifiers); return true; } - RefPtr<DOM::Node> node = result.layout_node->node(); - document->set_hovered_node(node); if (!node) return false; @@ -210,6 +216,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt if (result.layout_node) { if (result.layout_node->wants_mouse_events()) { + document.set_hovered_node(result.layout_node->node()); result.layout_node->handle_mousemove({}, position, buttons, modifiers); // FIXME: It feels a bit aggressive to always update the cursor like this. page_client.page_did_request_cursor_change(Gfx::StandardCursor::None); |