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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionController.java

Issue 1205033005: Adds selection expansion support for Contextual Search. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionController.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionController.java b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionController.java
index 4304435e777a360eabb4d214c071fc7926aa80cd..606d9d217bfc671b3586c424992dab308d1dcc74 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionController.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionController.java
@@ -46,6 +46,7 @@ public class ContextualSearchSelectionController {
private boolean mIsSelectionBeingModified;
private boolean mWasLastTapValid;
private boolean mIsWaitingForInvalidTapDetection;
+ private boolean mDidAdjustSelection;
pedro (no code reviews) 2015/06/25 01:30:28 Nit: mDidAdjustSelection --> mDidExpandSelection
aurimas (slooooooooow) 2015/07/01 00:45:38 Done
private float mX;
private float mY;
@@ -129,6 +130,11 @@ public class ContextualSearchSelectionController {
* @param selection The selection portion of the context.
*/
void handleSelectionChanged(String selection) {
+ if (mDidAdjustSelection) {
+ mDidAdjustSelection = false;
+ return;
+ }
+
if (selection == null || selection.isEmpty()) {
scheduleInvalidTapNotification();
// When the user taps on the page it will place the caret in that position, which
@@ -249,6 +255,19 @@ public class ContextualSearchSelectionController {
}
/**
+ * Adjusts the current selection by the given amounts.
+ */
+ void adjustSelection(int selectionStartAdjust, int selectionEndAdjust) {
David Trainor- moved to gerrit 2015/06/25 00:34:55 Eh might as well flesh out this javadoc with the s
+ // TODO(donnd): add code to verify that the selection is still valid before changing it!
+ ContentViewCore basePageContentView = getBaseContentView();
+ if (basePageContentView != null) {
pedro (no code reviews) 2015/06/25 01:30:28 Probably it's worth checking that basePageContentV
aurimas (slooooooooow) 2015/07/01 00:45:38 Done
+ mDidAdjustSelection = true;
+ basePageContentView.getWebContents().moveSelectionByCharacterOffset(
+ selectionStartAdjust, selectionEndAdjust);
+ }
+ }
+
+ /**
* @return whether a tap at the given coordinates should be handled or not.
*/
private boolean shouldHandleTap(int x, int y) {

Powered by Google App Engine
This is Rietveld 408576698