Only open CAB for long-press.

 Bug 6182286

Change-Id: I18590c457548e63cf45f5f7b626f5e8bd855f521
diff --git a/core/java/android/webkit/WebViewClassic.java b/core/java/android/webkit/WebViewClassic.java
index f4796d5..5d42da1 100644
--- a/core/java/android/webkit/WebViewClassic.java
+++ b/core/java/android/webkit/WebViewClassic.java
@@ -7986,7 +7986,9 @@
         }
         nativeSetTextSelection(mNativeClass, data.mSelectTextPtr);
 
-        if (data.mSelectionReason == TextSelectionData.REASON_ACCESSIBILITY_INJECTOR) {
+        if ((data.mSelectionReason == TextSelectionData.REASON_ACCESSIBILITY_INJECTOR)
+                || (!mSelectingText
+                        && data.mSelectionReason != TextSelectionData.REASON_SELECT_WORD)) {
             selectionDone();
             mShowTextSelectionExtra = true;
             invalidate();
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index 4adfd6a..7aa9a0b 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -22,7 +22,6 @@
 import android.database.Cursor;
 import android.graphics.Point;
 import android.graphics.Rect;
-import android.graphics.Region;
 import android.media.MediaFile;
 import android.net.ProxyProperties;
 import android.net.Uri;
@@ -864,6 +863,7 @@
     static class TextSelectionData {
         static final int REASON_UNKNOWN = 0;
         static final int REASON_ACCESSIBILITY_INJECTOR = 1;
+        static final int REASON_SELECT_WORD = 2;
         public TextSelectionData(int start, int end, int selectTextPtr) {
             mStart = start;
             mEnd = end;
@@ -1718,12 +1718,16 @@
                             break;
                         }
                         case SELECT_WORD_AT: {
+                            mTextSelectionChangeReason
+                                    = TextSelectionData.REASON_SELECT_WORD;
                             int x = msg.arg1;
                             int y = msg.arg2;
                             if (!nativeSelectWordAt(mNativeClass, x, y)) {
                                 mWebViewClassic.mPrivateHandler.obtainMessage(WebViewClassic.SHOW_CARET_HANDLE)
                                     .sendToTarget();
                             }
+                            mTextSelectionChangeReason
+                                    = TextSelectionData.REASON_UNKNOWN;
                             break;
                         }
                         case SELECT_ALL: