summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-02-15 23:24:45 +0100
committerAndreas Kling <kling@serenityos.org>2021-02-15 23:25:29 +0100
commit2323b6fb74d1cc7761a7bb294cf2a52080ccd57e (patch)
tree20e91868bb5b8cadfd60047884d5ce46f1fc32da /Userland/Libraries/LibWeb
parenta0e558ce8930df64259db3b89735c518d7d657e1 (diff)
downloadserenity-2323b6fb74d1cc7761a7bb294cf2a52080ccd57e.zip
LibWeb: Use the correct DOM node when moving text cursor with mouse
We should use the DOM node returned by the TextCursor hit test, and not the one we got from the earlier Exact hit test.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/Page/EventHandler.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp
index d239a1f5f0..b88e760860 100644
--- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp
+++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp
@@ -197,7 +197,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
if (button == GUI::MouseButton::Left) {
auto result = layout_root()->hit_test(position, Layout::HitTestType::TextCursor);
if (result.layout_node && result.layout_node->dom_node()) {
- m_frame.set_cursor_position(DOM::Position(*node, result.index_in_node));
+ m_frame.set_cursor_position(DOM::Position(*result.layout_node->dom_node(), result.index_in_node));
layout_root()->set_selection({ { result.layout_node, result.index_in_node }, {} });
m_in_mouse_selection = true;
}
@@ -262,7 +262,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
if (m_in_mouse_selection) {
auto hit = layout_root()->hit_test(position, Layout::HitTestType::TextCursor);
if (hit.layout_node && hit.layout_node->dom_node()) {
- m_frame.set_cursor_position(DOM::Position(*node, result.index_in_node));
+ m_frame.set_cursor_position(DOM::Position(*hit.layout_node->dom_node(), result.index_in_node));
layout_root()->set_selection_end({ hit.layout_node, hit.index_in_node });
}
if (auto* page = m_frame.page())