summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/Page/EventHandler.cpp
diff options
context:
space:
mode:
authorasynts <asynts@gmail.com>2020-12-06 19:51:55 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-09 21:05:06 +0100
commit10f9c850902f221f9e4cbc2123cfc107f52d113c (patch)
tree994b1266f8cbf6e49392da234261e26af51a950f /Libraries/LibWeb/Page/EventHandler.cpp
parent4df0eeaa3dba7ec1fa651657435a4754d5cd4108 (diff)
downloadserenity-10f9c850902f221f9e4cbc2123cfc107f52d113c.zip
LibWeb: Make DOM::Range more suitable for JS.
Diffstat (limited to 'Libraries/LibWeb/Page/EventHandler.cpp')
-rw-r--r--Libraries/LibWeb/Page/EventHandler.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cpp
index 9f3f80b697..3170c7122a 100644
--- a/Libraries/LibWeb/Page/EventHandler.cpp
+++ b/Libraries/LibWeb/Page/EventHandler.cpp
@@ -28,6 +28,7 @@
#include <LibGUI/Window.h>
#include <LibJS/Runtime/Value.h>
#include <LibWeb/DOM/Document.h>
+#include <LibWeb/DOM/Range.h>
#include <LibWeb/DOM/Text.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/HTMLIFrameElement.h>
@@ -346,15 +347,15 @@ 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();
+ auto range = layout_root()->selection().to_dom_range()->normalized();
m_frame.document()->layout_node()->set_selection({});
// FIXME: This doesn't work for some reason?
- m_frame.set_cursor_position(range.start());
+ m_frame.set_cursor_position({ *range->start_container(), range->start_offset() });
if (key == KeyCode::Key_Backspace || key == KeyCode::Key_Delete) {
- if (range.start().node()->is_editable()) {
+ if (range->start_container()->is_editable()) {
m_edit_event_handler->handle_delete(range);
return true;
}
@@ -375,7 +376,7 @@ bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_poin
TODO();
m_frame.cursor_position().set_offset(position.offset() - 1);
- m_edit_event_handler->handle_delete({ { *position.node(), position.offset() - 1 }, position });
+ m_edit_event_handler->handle_delete(DOM::Range::create(*position.node(), position.offset() - 1, *position.node(), position.offset()));
return true;
} else if (key == KeyCode::Key_Delete) {
@@ -384,7 +385,7 @@ bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_poin
if (position.offset() >= downcast<DOM::Text>(position.node())->data().length())
TODO();
- m_edit_event_handler->handle_delete({ position, { *position.node(), position.offset() + 1 } });
+ m_edit_event_handler->handle_delete(DOM::Range::create(*position.node(), position.offset(), *position.node(), position.offset() + 1));
return true;
} else if (key == KeyCode::Key_Right) {