diff options
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/Page/EventHandler.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index 8541269565..6fc36d603c 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -478,13 +478,19 @@ bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_poin bool EventHandler::handle_keyup(KeyCode key, unsigned modifiers, u32 code_point) { + RefPtr<DOM::Document> document = m_frame.active_document(); + if (!document) + return false; + auto event = UIEvents::KeyboardEvent::create_from_platform_event(UIEvents::EventNames::keyup, key, modifiers, code_point); - if (m_frame.active_document()->focused_element()) - return m_frame.active_document()->focused_element()->dispatch_event(move(event)); - else if (m_frame.active_document()->body()) - return m_frame.active_document()->body()->dispatch_event(move(event)); - else - return m_frame.active_document()->root().dispatch_event(move(event)); + + if (RefPtr<DOM::Element> focused_element = document->focused_element()) + return document->focused_element()->dispatch_event(move(event)); + + if (RefPtr<HTML::HTMLElement> body = document->body()) + return body->dispatch_event(move(event)); + + return document->root().dispatch_event(move(event)); } void EventHandler::set_mouse_event_tracking_layout_node(Layout::Node* layout_node) |