mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 20:05:07 +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
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()) {
|
if (result.layout_node && result.layout_node->wants_mouse_events()) {
|
||||||
result.layout_node->handle_mouseup({}, position, button, modifiers);
|
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()) {
|
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)
|
if (!result.layout_node)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
RefPtr<DOM::Node> node = result.layout_node->node();
|
||||||
|
document->set_hovered_node(node);
|
||||||
|
|
||||||
if (result.layout_node->wants_mouse_events()) {
|
if (result.layout_node->wants_mouse_events()) {
|
||||||
result.layout_node->handle_mousedown({}, position, button, modifiers);
|
result.layout_node->handle_mousedown({}, position, button, modifiers);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<DOM::Node> node = result.layout_node->node();
|
|
||||||
document->set_hovered_node(node);
|
|
||||||
if (!node)
|
if (!node)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -210,6 +216,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
|
||||||
if (result.layout_node) {
|
if (result.layout_node) {
|
||||||
|
|
||||||
if (result.layout_node->wants_mouse_events()) {
|
if (result.layout_node->wants_mouse_events()) {
|
||||||
|
document.set_hovered_node(result.layout_node->node());
|
||||||
result.layout_node->handle_mousemove({}, position, buttons, modifiers);
|
result.layout_node->handle_mousemove({}, position, buttons, modifiers);
|
||||||
// FIXME: It feels a bit aggressive to always update the cursor like this.
|
// FIXME: It feels a bit aggressive to always update the cursor like this.
|
||||||
page_client.page_did_request_cursor_change(Gfx::StandardCursor::None);
|
page_client.page_did_request_cursor_change(Gfx::StandardCursor::None);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue