mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibWeb: Don't replace selection on key press in non-editable content
This commit is contained in:
parent
19144b753a
commit
8b9f2c41fa
Notes:
sideshowbarker
2024-07-19 00:53:10 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/8b9f2c41faa
1 changed files with 12 additions and 11 deletions
|
@ -348,23 +348,24 @@ bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_poin
|
|||
|
||||
if (layout_root()->selection().is_valid()) {
|
||||
auto range = layout_root()->selection().to_dom_range()->normalized();
|
||||
if (range->start_container()->is_editable()) {
|
||||
m_frame.document()->layout_node()->set_selection({});
|
||||
|
||||
m_frame.document()->layout_node()->set_selection({});
|
||||
// FIXME: This doesn't work for some reason?
|
||||
m_frame.set_cursor_position({ *range->start_container(), range->start_offset() });
|
||||
|
||||
// FIXME: This doesn't work for some reason?
|
||||
m_frame.set_cursor_position({ *range->start_container(), range->start_offset() });
|
||||
if (key == KeyCode::Key_Backspace || key == KeyCode::Key_Delete) {
|
||||
|
||||
if (key == KeyCode::Key_Backspace || key == KeyCode::Key_Delete) {
|
||||
if (range->start_container()->is_editable()) {
|
||||
m_edit_event_handler->handle_delete(range);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
m_edit_event_handler->handle_delete(range);
|
||||
} else {
|
||||
|
||||
m_edit_event_handler->handle_insert(m_frame.cursor_position(), code_point);
|
||||
m_frame.cursor_position().set_offset(m_frame.cursor_position().offset() + 1);
|
||||
return true;
|
||||
m_edit_event_handler->handle_delete(range);
|
||||
|
||||
m_edit_event_handler->handle_insert(m_frame.cursor_position(), code_point);
|
||||
m_frame.cursor_position().set_offset(m_frame.cursor_position().offset() + 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue