Cherry-pick "[Android] Don't hide text handles if they are being dragged"

From https://codereview.chromium.org/26491010/

Bug 10723151

Original Description:

In webview, hiding of text handles can be triggered by many events
(containing view being scrolled, capturePicture call, etc.). If the
user is dragging a handle, we don't actually want to hide it. Instead,
explicitly suppress hiding of text handles while they are being dragged.

BUG=b/10723151

Review URL: https://codereview.chromium.org/26491010

Change-Id: I254e12582c0ef3446756c2aa1d8b418639413f3c
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228728 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index e90e7bb..d98e641 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -2214,10 +2214,10 @@
     // Makes the insertion/selection handles invisible. They will fade back in shortly after the
     // last call to scheduleTextHandleFadeIn (or temporarilyHideTextHandles).
     private void temporarilyHideTextHandles() {
-        if (isSelectionHandleShowing()) {
+        if (isSelectionHandleShowing() && !mSelectionHandleController.isDragging()) {
             mSelectionHandleController.setHandleVisibility(HandleView.INVISIBLE);
         }
-        if (isInsertionHandleShowing()) {
+        if (isInsertionHandleShowing() && !mInsertionHandleController.isDragging()) {
             mInsertionHandleController.setHandleVisibility(HandleView.INVISIBLE);
         }
         scheduleTextHandleFadeIn();
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/InsertionHandleController.java b/content/public/android/java/src/org/chromium/content/browser/input/InsertionHandleController.java
index f251edf..c027da1 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/InsertionHandleController.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/InsertionHandleController.java
@@ -72,6 +72,13 @@
         showPastePopup();
     }
 
+    /**
+     * @return whether the handle is being dragged.
+     */
+    public boolean isDragging() {
+        return mHandle != null && mHandle.isDragging();
+    }
+
     /** Shows the handle at the given coordinates, as long as automatic showing is allowed */
     public void onCursorPositionChanged() {
         if (mAllowAutomaticShowing) {