mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 10:12:25 -05:00
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:
parent
a72bb34970
commit
157f72e9d7
Notes:
sideshowbarker
2024-07-18 17:36:23 +09:00
Author: https://github.com/MaxWipfli Commit: https://github.com/SerenityOS/serenity/commit/157f72e9d7c Pull-request: https://github.com/SerenityOS/serenity/pull/7268 Issue: https://github.com/SerenityOS/serenity/issues/7182 Issue: https://github.com/SerenityOS/serenity/issues/7202 Reviewed-by: https://github.com/Dexesttp
1 changed files with 16 additions and 8 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue