summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/Page
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-12-14 10:58:10 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-14 10:58:10 +0100
commit8b9f2c41faa8004759dc933500880b031c81d4b2 (patch)
tree96f1a765b0b988d467c24ee7faf6bed02e7692c0 /Libraries/LibWeb/Page
parent19144b753a24ffabd50a31cf0f45db463e80eeb4 (diff)
downloadserenity-8b9f2c41faa8004759dc933500880b031c81d4b2.zip
LibWeb: Don't replace selection on key press in non-editable content
Diffstat (limited to 'Libraries/LibWeb/Page')
-rw-r--r--Libraries/LibWeb/Page/EventHandler.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cpp
index 3170c7122a..e3fa3adfc3 100644
--- a/Libraries/LibWeb/Page/EventHandler.cpp
+++ b/Libraries/LibWeb/Page/EventHandler.cpp
@@ -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;
+ }
}
}