mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
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.
This commit is contained in:
parent
d103686261
commit
94c55d9e37
Notes:
sideshowbarker
2024-07-19 02:43:20 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/94c55d9e370
1 changed files with 9 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue