summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2017-04-27 11:29:46 +0200
committerPeter Varga <pvarga@inf.u-szeged.hu>2017-07-20 00:23:45 +0000
commit54e108f1efbc695a8da2f3ce33a44cff2eae4a36 (patch)
treefcd2d8155ec09e5b50e8dd905ff8f768751a7fb0 /src
parent4ea9d5158336313b14a7ca7223371ccd4550706c (diff)
Fix emitting selectionChanged signal for non-user text selection change
This fixes the case when the text selection is triggered by JavaScript. Text selection changes triggered by IME composition text replecement are ignored. Test has been added for mouse selection clipboard: non-user text selection should not update the clipboard. Pulls in Chromium changes: 3deea95 Update TextSelection for non-user initiated events Task-number: QTBUG-53134 Task-number: QTBUG-60381 Change-Id: Ib94f57a2aa61248fba75f595245fb388b9609b6c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src')
m---------src/3rdparty0
-rw-r--r--src/core/render_widget_host_view_qt.cpp25
2 files changed, 17 insertions, 8 deletions
diff --git a/src/3rdparty b/src/3rdparty
-Subproject dfaf1564283dcdd222be9717a1a5ad9389ec7f1
+Subproject 3deea958f1485b50940e7437c0a3b73ed29ee13
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 4e98a1016..f90a44044 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -757,8 +757,12 @@ void RenderWidgetHostViewQt::OnTextSelectionChanged(content::TextInputManager *t
Q_UNUSED(text_input_manager);
Q_UNUSED(updated_view);
+ const content::TextInputManager::TextSelection *selection = GetTextInputManager()->GetTextSelection(updated_view);
+ if (!selection)
+ return;
+
#if defined(USE_X11)
- if (!GetSelectedText().empty()) {
+ if (!GetSelectedText().empty() && selection->user_initiated()) {
// Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard.
ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION);
clipboard_writer.WriteText(GetSelectedText());
@@ -793,6 +797,18 @@ void RenderWidgetHostViewQt::selectionChanged()
return;
}
+ if (GetSelectedText().empty()) {
+ m_anchorPositionWithinSelection = m_cursorPosition;
+ m_cursorPositionWithinSelection = m_cursorPosition;
+
+ if (!m_emptyPreviousSelection) {
+ m_emptyPreviousSelection = GetSelectedText().empty();
+ m_adapterClient->selectionChanged();
+ }
+
+ return;
+ }
+
const content::TextInputManager::TextSelection *selection = text_input_manager_->GetTextSelection();
if (!selection)
return;
@@ -800,13 +816,6 @@ void RenderWidgetHostViewQt::selectionChanged()
if (!selection->range().IsValid())
return;
- // Avoid duplicate empty selectionChanged() signals
- if (GetSelectedText().empty() && m_emptyPreviousSelection) {
- m_anchorPositionWithinSelection = m_cursorPosition;
- m_cursorPositionWithinSelection = m_cursorPosition;
- return;
- }
-
int newAnchorPositionWithinSelection = 0;
int newCursorPositionWithinSelection = 0;