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.
This commit is contained in:
Max Wipfli 2021-05-18 13:08:25 +02:00 committed by Andreas Kling
parent a72bb34970
commit 157f72e9d7
Notes: sideshowbarker 2024-07-18 17:36:23 +09:00

View file

@ -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<DOM::Text>(position.node())->data().length())
TODO();
if (position.offset() >= downcast<DOM::Text>(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<DOM::Text>(position.node())->data().length())
TODO();
if (position.offset() >= downcast<DOM::Text>(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);