Remove moveCursorToSelectionEnd()
moveCursorToSelectionEnd() blocks the IME thread unnecessarily, which causes
back navigation to fail. So this CL removes moveCursorToSelectionEnd() and
replaces with mWebContents.unselect().
In RenderFrameImpl::OnUnselect(), the cursor is deleted entirely, which causes
text boxes to be unfocused as a side effect. To fix that, this CL collapses the
selection to the selection end, and renames the functions to CollapseSelection().
BUG=697756
TEST=run_chrome_public_test_apk --test-filter TabsTest.testTabSwitcherCollapseSelection
Review-Url: https://codereview.chromium.org/2734943005
Cr-Commit-Position: refs/heads/master@{#455963}
diff --git a/content/browser/web_contents/web_contents_android.cc b/content/browser/web_contents/web_contents_android.cc
index 7e829ce..141a83c3 100644
--- a/content/browser/web_contents/web_contents_android.cc
+++ b/content/browser/web_contents/web_contents_android.cc
@@ -346,9 +346,9 @@
web_contents_->SelectAll();
}
-void WebContentsAndroid::Unselect(JNIEnv* env,
- const JavaParamRef<jobject>& obj) {
- web_contents_->Unselect();
+void WebContentsAndroid::CollapseSelection(JNIEnv* env,
+ const JavaParamRef<jobject>& obj) {
+ web_contents_->CollapseSelection();
}
RenderWidgetHostViewAndroid*
diff --git a/content/browser/web_contents/web_contents_android.h b/content/browser/web_contents/web_contents_android.h
index 33b16b6..6fee01eb 100644
--- a/content/browser/web_contents/web_contents_android.h
+++ b/content/browser/web_contents/web_contents_android.h
@@ -63,7 +63,8 @@
const base::android::JavaParamRef<jobject>& obj,
const base::android::JavaParamRef<jstring>& jstr);
void SelectAll(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
- void Unselect(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
+ void CollapseSelection(JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& obj);
jint GetBackgroundColor(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
base::android::ScopedJavaLocalRef<jstring> GetURL(
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 4b5645f..f8910b4 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -2793,13 +2793,13 @@
RecordAction(base::UserMetricsAction("SelectAll"));
}
-void WebContentsImpl::Unselect() {
+void WebContentsImpl::CollapseSelection() {
RenderFrameHost* focused_frame = GetFocusedFrame();
if (!focused_frame)
return;
- focused_frame->Send(new InputMsg_Unselect(focused_frame->GetRoutingID()));
- RecordAction(base::UserMetricsAction("Unselect"));
+ focused_frame->Send(
+ new InputMsg_CollapseSelection(focused_frame->GetRoutingID()));
}
void WebContentsImpl::Replace(const base::string16& word) {
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
index d02b08d3..9124e255 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
@@ -346,7 +346,7 @@
void PasteAndMatchStyle() override;
void Delete() override;
void SelectAll() override;
- void Unselect() override;
+ void CollapseSelection() override;
void Replace(const base::string16& word) override;
void ReplaceMisspelling(const base::string16& word) override;
void NotifyContextMenuClosed(