abandon long press on scroll; clear hit on keydown

If the application scrolls the webview without allowing
WebView.java to receive the motion event, stop any long
press timer in progress. This prevents select text from
appearing in applications that host webviews and do their
own flinging.

If the cursor is moved with the dpad or trackball,
reset the hit test state used by long press. This allows
cts tests to run reliably; they emulate key presses
to move between links.

bug:3250291 (app fling)
bug:3241830 (cts fail)
Change-Id: Ida364051ffa090455ddc6c3c3dd41baea5615293
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index e8ce7ee..a9fa879 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -2444,6 +2444,7 @@
             mWebViewCore.sendMessage(EventHub.SET_SCROLL_OFFSET,
                     nativeMoveGeneration(), mUserScroll ? 1 : 0, pos);
             mLastVisibleRectSent = rect;
+            mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
         }
         Rect globalRect = new Rect();
         if (getGlobalVisibleRect(globalRect)
@@ -7574,6 +7575,7 @@
         if (mNativeClass == 0) {
             return false;
         }
+        mInitialHitTestResult = null;
         mLastCursorTime = time;
         mLastCursorBounds = nativeGetCursorRingBounds();
         boolean keyHandled