From 157f72e9d7c588e9deae629b033e8291cd0cd830 Mon Sep 17 00:00:00 2001 From: Max Wipfli Date: Tue, 18 May 2021 13:08:25 +0200 Subject: [PATCH] LibWeb: Replace some TODO() calls with FIXME comments in EventHandler This patch downgrades some TODO() calls when the cursor in an editable DOM node should move to the previous or next node. Previously, the process would crash, whereas now, the cursor will just stay where it was. This seems more sensible for now, as there is no reason to crash just because of this. --- .../Libraries/LibWeb/Page/EventHandler.cpp | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index a8530690b4..819b7fde83 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -416,8 +416,10 @@ bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_poin if (key == KeyCode::Key_Backspace) { auto position = m_frame.cursor_position(); - if (position.offset() == 0) - TODO(); + if (position.offset() == 0) { + // FIXME: Move to the previous node and delete the last character there. + return true; + } auto new_position = m_frame.cursor_position(); new_position.set_offset(position.offset() - 1); @@ -429,8 +431,10 @@ bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_poin } else if (key == KeyCode::Key_Delete) { auto position = m_frame.cursor_position(); - if (position.offset() >= downcast(position.node())->data().length()) - TODO(); + if (position.offset() >= downcast(position.node())->data().length()) { + // FIXME: Move to the next node and delete the first character there. + return true; + } m_edit_event_handler->handle_delete(DOM::Range::create(*position.node(), position.offset(), *position.node(), position.offset() + 1)); @@ -438,8 +442,10 @@ bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_poin } else if (key == KeyCode::Key_Right) { auto position = m_frame.cursor_position(); - if (position.offset() >= downcast(position.node())->data().length()) - TODO(); + if (position.offset() >= downcast(position.node())->data().length()) { + // FIXME: Move to the next node. + return true; + } auto new_position = m_frame.cursor_position(); new_position.set_offset(position.offset() + 1); @@ -449,8 +455,10 @@ bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_poin } else if (key == KeyCode::Key_Left) { auto position = m_frame.cursor_position(); - if (position.offset() == 0) - TODO(); + if (position.offset() == 0) { + // FIXME: Move to the previous node. + return true; + } auto new_position = m_frame.cursor_position(); new_position.set_offset(new_position.offset() - 1);