mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:57:34 +00:00
LibWeb: Don't replace selection on key press in non-editable content
This commit is contained in:
parent
19144b753a
commit
8b9f2c41fa
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()) {
|
if (layout_root()->selection().is_valid()) {
|
||||||
auto range = layout_root()->selection().to_dom_range()->normalized();
|
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?
|
if (key == KeyCode::Key_Backspace || key == KeyCode::Key_Delete) {
|
||||||
m_frame.set_cursor_position({ *range->start_container(), range->start_offset() });
|
|
||||||
|
|
||||||
if (key == KeyCode::Key_Backspace || key == KeyCode::Key_Delete) {
|
|
||||||
if (range->start_container()->is_editable()) {
|
|
||||||
m_edit_event_handler->handle_delete(range);
|
m_edit_event_handler->handle_delete(range);
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
} else {
|
|
||||||
m_edit_event_handler->handle_delete(range);
|
|
||||||
|
|
||||||
m_edit_event_handler->handle_insert(m_frame.cursor_position(), code_point);
|
m_edit_event_handler->handle_delete(range);
|
||||||
m_frame.cursor_position().set_offset(m_frame.cursor_position().offset() + 1);
|
|
||||||
return true;
|
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…
Add table
Add a link
Reference in a new issue