summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2018-03-02 10:50:32 +0100
committerPeter Varga <pvarga@inf.u-szeged.hu>2018-03-02 16:01:28 +0000
commit5cdc7d41f06393593fc7b8032755f8a654482648 (patch)
treeb5140ce24ad388ddf74b245dc54371d47e21f193 /src/core
parentf99664717f4d6e3270e750154617f651d541fa1e (diff)
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 <allan.jensen@qt.io>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/render_widget_host_view_qt.cpp7
1 files changed, 7 insertions, 0 deletions
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;