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

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

Issue 2201853002: Blink handle selection handle visibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixing nits and context menu Created 4 years, 2 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
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.chrome.browser.contextualsearch; 5 package org.chromium.chrome.browser.contextualsearch;
6 6
7 import android.os.Handler; 7 import android.os.Handler;
8 import android.text.TextUtils;
8 9
9 import org.chromium.base.VisibleForTesting; 10 import org.chromium.base.VisibleForTesting;
10 import org.chromium.chrome.browser.ChromeActivity; 11 import org.chromium.chrome.browser.ChromeActivity;
11 import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel; 12 import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel;
12 import org.chromium.chrome.browser.contextualsearch.ContextualSearchBlacklist.Bl acklistReason; 13 import org.chromium.chrome.browser.contextualsearch.ContextualSearchBlacklist.Bl acklistReason;
13 import org.chromium.chrome.browser.preferences.ChromePreferenceManager; 14 import org.chromium.chrome.browser.preferences.ChromePreferenceManager;
14 import org.chromium.chrome.browser.tab.Tab; 15 import org.chromium.chrome.browser.tab.Tab;
15 import org.chromium.content.browser.ContentViewCore; 16 import org.chromium.content.browser.ContentViewCore;
16 import org.chromium.content_public.browser.GestureStateListener; 17 import org.chromium.content_public.browser.GestureStateListener;
17 import org.chromium.ui.touch_selection.SelectionEventType; 18 import org.chromium.ui.touch_selection.SelectionEventType;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 private final float mPxToDp; 63 private final float mPxToDp;
63 private final Pattern mContainsWordPattern; 64 private final Pattern mContainsWordPattern;
64 65
65 private String mSelectedText; 66 private String mSelectedText;
66 private SelectionType mSelectionType; 67 private SelectionType mSelectionType;
67 private boolean mWasTapGestureDetected; 68 private boolean mWasTapGestureDetected;
68 // Reflects whether the last tap was valid and whether we still have a tap-b ased selection. 69 // Reflects whether the last tap was valid and whether we still have a tap-b ased selection.
69 private ContextualSearchTapState mLastTapState; 70 private ContextualSearchTapState mLastTapState;
70 private TapSuppressionHeuristics mTapHeuristics; 71 private TapSuppressionHeuristics mTapHeuristics;
71 private boolean mIsWaitingForInvalidTapDetection; 72 private boolean mIsWaitingForInvalidTapDetection;
72 private boolean mIsSelectionEstablished;
73 private boolean mShouldHandleSelectionModification; 73 private boolean mShouldHandleSelectionModification;
74 private boolean mDidExpandSelection; 74 private boolean mDidExpandSelection;
75 75
76 // Position of the selection. 76 // Position of the selection.
77 private float mX; 77 private float mX;
78 private float mY; 78 private float mY;
79 79
80 // The time of the most last scroll activity, or 0 if none. 80 // The time of the most last scroll activity, or 0 if none.
81 private long mLastScrollTimeNs; 81 private long mLastScrollTimeNs;
82 82
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 unscheduleInvalidTapNotification(); 289 unscheduleInvalidTapNotification();
290 } 290 }
291 break; 291 break;
292 case SelectionEventType.SELECTION_HANDLES_CLEARED: 292 case SelectionEventType.SELECTION_HANDLES_CLEARED:
293 mHandler.handleSelectionDismissal(); 293 mHandler.handleSelectionDismissal();
294 resetAllStates(); 294 resetAllStates();
295 break; 295 break;
296 case SelectionEventType.SELECTION_HANDLE_DRAG_STOPPED: 296 case SelectionEventType.SELECTION_HANDLE_DRAG_STOPPED:
297 shouldHandleSelection = mShouldHandleSelectionModification; 297 shouldHandleSelection = mShouldHandleSelectionModification;
298 break; 298 break;
299 case SelectionEventType.SELECTION_ESTABLISHED:
300 mIsSelectionEstablished = true;
301 break;
302 case SelectionEventType.SELECTION_DISSOLVED:
303 mIsSelectionEstablished = false;
304 break;
305 default: 299 default:
306 } 300 }
307 301
308 if (shouldHandleSelection) { 302 if (shouldHandleSelection) {
309 ContentViewCore baseContentView = getBaseContentView(); 303 ContentViewCore baseContentView = getBaseContentView();
310 if (baseContentView != null) { 304 if (baseContentView != null) {
311 String selection = baseContentView.getSelectedText(); 305 String selection = baseContentView.getSelectedText();
312 if (selection != null) { 306 if (selection != null) {
313 mX = posXPix; 307 mX = posXPix;
314 mY = posYPix; 308 mY = posYPix;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 500
507 /** 501 /**
508 * @return whether a tap gesture has been detected, for testing. 502 * @return whether a tap gesture has been detected, for testing.
509 */ 503 */
510 @VisibleForTesting 504 @VisibleForTesting
511 boolean wasAnyTapGestureDetected() { 505 boolean wasAnyTapGestureDetected() {
512 return mIsWaitingForInvalidTapDetection; 506 return mIsWaitingForInvalidTapDetection;
513 } 507 }
514 508
515 /** 509 /**
516 * @return whether the selection has been established, for testing. 510 * @return whether selection is empty, for testing.
517 */ 511 */
518 @VisibleForTesting 512 @VisibleForTesting
519 boolean isSelectionEstablished() { 513 boolean isSelectionEmpty() {
520 return mIsSelectionEstablished; 514 return TextUtils.isEmpty(mSelectedText);
521 } 515 }
522 516
523 /** 517 /**
524 * Evaluates whether the given selection is valid and notifies the handler a bout potential 518 * Evaluates whether the given selection is valid and notifies the handler a bout potential
525 * selection suppression. 519 * selection suppression.
526 * TODO(pedrosimonetti): substitute this once the system supports suppressin g selections. 520 * TODO(pedrosimonetti): substitute this once the system supports suppressin g selections.
527 * @param selection The given selection. 521 * @param selection The given selection.
528 * @return Whether the selection is valid. 522 * @return Whether the selection is valid.
529 */ 523 */
530 private boolean validateSelectionSuppression(String selection) { 524 private boolean validateSelectionSuppression(String selection) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 // Starts are inclusive and ends are non-inclusive for both GSAContext & matcher. 594 // Starts are inclusive and ends are non-inclusive for both GSAContext & matcher.
601 while (matcher.find()) { 595 while (matcher.find()) {
602 if (startOffset >= matcher.start() && endOffset <= matcher.end()) { 596 if (startOffset >= matcher.start() && endOffset <= matcher.end()) {
603 return true; 597 return true;
604 } 598 }
605 } 599 }
606 600
607 return false; 601 return false;
608 } 602 }
609 } 603 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698