LibWeb: Dispatch mouseout and mouseover events

This commit is contained in:
Aliaksandr Kalenik 2024-03-24 21:58:11 +01:00 committed by Andreas Kling
commit 4ae2eaead1
Notes: sideshowbarker 2024-07-17 03:03:15 +09:00

View file

@ -1298,6 +1298,12 @@ void Document::set_hovered_node(Node* node)
else
invalidate_style();
// https://w3c.github.io/uievents/#mouseout
if (old_hovered_node && old_hovered_node != m_hovered_node) {
auto event = UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseout);
old_hovered_node->dispatch_event(event);
}
// https://w3c.github.io/uievents/#mouseleave
if (old_hovered_node && (!m_hovered_node || !m_hovered_node->is_descendant_of(*old_hovered_node))) {
// FIXME: Check if we need to dispatch these events in a specific order.
@ -1307,6 +1313,12 @@ void Document::set_hovered_node(Node* node)
}
}
// https://w3c.github.io/uievents/#mouseover
if (m_hovered_node && m_hovered_node != old_hovered_node) {
auto event = UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseover);
m_hovered_node->dispatch_event(event);
}
// https://w3c.github.io/uievents/#mouseenter
if (m_hovered_node && (!old_hovered_node || !m_hovered_node->is_ancestor_of(*old_hovered_node))) {
// FIXME: Check if we need to dispatch these events in a specific order.