Explorar el Código

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.
Andreas Kling hace 4 años
padre
commit
2323b6fb74
Se han modificado 1 ficheros con 2 adiciones y 2 borrados
  1. 2 2
      Userland/Libraries/LibWeb/Page/EventHandler.cpp

+ 2 - 2
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) {
         if (button == GUI::MouseButton::Left) {
             auto result = layout_root()->hit_test(position, Layout::HitTestType::TextCursor);
             auto result = layout_root()->hit_test(position, Layout::HitTestType::TextCursor);
             if (result.layout_node && result.layout_node->dom_node()) {
             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 }, {} });
                 layout_root()->set_selection({ { result.layout_node, result.index_in_node }, {} });
                 m_in_mouse_selection = true;
                 m_in_mouse_selection = true;
             }
             }
@@ -262,7 +262,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
         if (m_in_mouse_selection) {
         if (m_in_mouse_selection) {
             auto hit = layout_root()->hit_test(position, Layout::HitTestType::TextCursor);
             auto hit = layout_root()->hit_test(position, Layout::HitTestType::TextCursor);
             if (hit.layout_node && hit.layout_node->dom_node()) {
             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 });
                 layout_root()->set_selection_end({ hit.layout_node, hit.index_in_node });
             }
             }
             if (auto* page = m_frame.page())
             if (auto* page = m_frame.page())