From 5cdc7d41f06393593fc7b8032755f8a654482648 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Fri, 2 Mar 2018 10:50:32 +0100 Subject: Make cursor position update more reliable This patch makes the cursor position update independent from the order of calling RenderWidgetHostViewQt::OnUpdateTextInputStateCalled() and RenderWidgetHostViewQt::OnTextSelectionChanged(). This fixes the cursor position update after clearing text selection in 65-based Chromium update. From 65-based RenderWidget::WillBeginCompositorFrame() might not be called after text selection changes thus does not trigger an extra TextInputState update which hid this issue with earlier Chromium versions. Change-Id: I80c07e26b66c3a96cb004b9e3ceb57cd99234237 Reviewed-by: Allan Sandfeld Jensen --- src/core/render_widget_host_view_qt.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/core/render_widget_host_view_qt.cpp') diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 4f6d6d0ea..49c07d3ed 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -808,6 +808,8 @@ void RenderWidgetHostViewQt::OnUpdateTextInputStateCalled(content::TextInputMana if (!state) return; + // At this point it is unknown whether the text input state has been updated due to a text selection. + // Keep the cursor position updated for cursor movements too. if (GetSelectedText().empty()) m_cursorPosition = state->selection_start; @@ -891,6 +893,11 @@ void RenderWidgetHostViewQt::selectionChanged() } if (GetSelectedText().empty()) { + // RenderWidgetHostViewQt::OnUpdateTextInputStateCalled() does not update the cursor position + // if the selection is cleared because TextInputState changes before the TextSelection change. + Q_ASSERT(text_input_manager_->GetTextInputState()); + m_cursorPosition = text_input_manager_->GetTextInputState()->selection_start; + m_anchorPositionWithinSelection = m_cursorPosition; m_cursorPositionWithinSelection = m_cursorPosition; -- cgit v1.2.3