Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java

Issue 2847133004: Smart Select shouldn't shorten selection (Closed)
Patch Set: adding tod Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.annotation.TargetApi; 7 import android.annotation.TargetApi;
8 import android.app.Activity; 8 import android.app.Activity;
9 import android.app.SearchManager; 9 import android.app.SearchManager;
10 import android.content.ClipboardManager; 10 import android.content.ClipboardManager;
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 @Override 1027 @Override
1028 public void onClassified(ContextSelectionProvider.Result result) { 1028 public void onClassified(ContextSelectionProvider.Result result) {
1029 // If the selection does not exist any more, discard |result|. 1029 // If the selection does not exist any more, discard |result|.
1030 if (!mHasSelection) { 1030 if (!mHasSelection) {
1031 assert !mHidden; 1031 assert !mHidden;
1032 assert mClassificationResult == null; 1032 assert mClassificationResult == null;
1033 mPendingShowActionMode = false; 1033 mPendingShowActionMode = false;
1034 return; 1034 return;
1035 } 1035 }
1036 1036
1037 // Do not allow classifier to shorten the selection. If the suggeste d selection is
1038 // smaller than the original we throw away classification result and show the menu.
1039 // TODO(amaralp): This was added to fix the SelectAll problem in
1040 // http://crbug.com/714106. Once we know the cause of the original s election we can
1041 // remove this check.
1042 if (result.startAdjust > 0 || result.endAdjust < 0) {
1043 mClassificationResult = null;
1044 mPendingShowActionMode = false;
1045 showActionModeOrClearOnFailure();
1046 return;
1047 }
1048
1037 // The classificationresult is a property of the selection. Keep it even the action 1049 // The classificationresult is a property of the selection. Keep it even the action
1038 // mode has been dismissed. 1050 // mode has been dismissed.
1039 mClassificationResult = result; 1051 mClassificationResult = result;
1040 1052
1041 // Do not recreate the action mode if it has been cancelled (by Acti onMode.finish()) 1053 // Do not recreate the action mode if it has been cancelled (by Acti onMode.finish())
1042 // and not recreated after that. 1054 // and not recreated after that.
1043 if (!mPendingShowActionMode && !isActionModeValid()) { 1055 if (!mPendingShowActionMode && !isActionModeValid()) {
1044 assert !mHidden; 1056 assert !mHidden;
1045 return; 1057 return;
1046 } 1058 }
1047 1059
1048 // Update the selection range if needed. 1060 // Update the selection range if needed.
1049 if (!(result.startAdjust == 0 && result.endAdjust == 0)) { 1061 if (!(result.startAdjust == 0 && result.endAdjust == 0)) {
1050 // This call causes SELECTION_HANDLES_MOVED event. 1062 // This call causes SELECTION_HANDLES_MOVED event.
1051 mWebContents.adjustSelectionByCharacterOffset(result.startAdjust , result.endAdjust); 1063 mWebContents.adjustSelectionByCharacterOffset(result.startAdjust , result.endAdjust);
1052 1064
1053 // Remain pending until SELECTION_HANDLES_MOVED arrives. 1065 // Remain pending until SELECTION_HANDLES_MOVED arrives.
1054 if (mPendingShowActionMode) return; 1066 if (mPendingShowActionMode) return;
1055 } 1067 }
1056 1068
1057 // Rely on this method to clear |mHidden| and unhide the action mode . 1069 // Rely on this method to clear |mHidden| and unhide the action mode .
1058 showActionModeOrClearOnFailure(); 1070 showActionModeOrClearOnFailure();
1059 } 1071 }
1060 }; 1072 };
1061 1073
1062 private native void nativeInit(WebContents webContents); 1074 private native void nativeInit(WebContents webContents);
1063 } 1075 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698