mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibWeb: Add support for range deletion.
This commit is contained in:
parent
bbcc5a9332
commit
43dc47a494
Notes:
sideshowbarker
2024-07-19 00:57:20 +09:00
Author: https://github.com/asynts
Commit: 43dc47a494
Pull-request: https://github.com/SerenityOS/serenity/pull/4318
Reviewed-by: https://github.com/Lubrsi
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/linusg
8 changed files with 107 additions and 6 deletions
|
@ -345,16 +345,33 @@ bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_poin
|
|||
return focus_next_element();
|
||||
}
|
||||
|
||||
if (layout_root()->selection().is_valid()) {
|
||||
auto range = layout_root()->selection().to_dom_range();
|
||||
|
||||
if (key == KeyCode::Key_Backspace) {
|
||||
if (range.start().node()->is_editable()) {
|
||||
m_edit_event_handler->handle_delete(range);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Check if this code point is in the printable character range.
|
||||
|
||||
m_edit_event_handler->handle_delete(range);
|
||||
m_edit_event_handler->handle_insert(m_frame.cursor_position(), code_point);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_frame.cursor_position().is_valid() && m_frame.cursor_position().node()->is_editable()) {
|
||||
if (key == KeyCode::Key_Backspace) {
|
||||
m_edit_event_handler->handle_delete(m_frame.cursor_position());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (code_point) {
|
||||
m_edit_event_handler->handle_insert(m_frame.cursor_position(), code_point);
|
||||
return true;
|
||||
}
|
||||
// FIXME: Check if this code point is in the printable character range.
|
||||
|
||||
m_edit_event_handler->handle_insert(m_frame.cursor_position(), code_point);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue