summaryrefslogtreecommitdiff
path: root/core/java/android/webkit/WebView.java
diff options
context:
space:
mode:
authorGrace Kloba <klobag@google.com>2010-02-23 15:25:31 -0800
committerGrace Kloba <klobag@google.com>2010-02-24 14:31:44 -0800
commit93f5831ef27093ccd939077c00a6981a026a6c21 (patch)
treef90dac4e02d4058108d98baddffe3919e0646c3b /core/java/android/webkit/WebView.java
parente0e6a9c0fc4cda5ade07997d3ea4a53afb8762fd (diff)
If mPreventDrag is cancelled due to time out, remove
the pending TOUCH_EVENTS and then send an ACTION_CANCEL and skip the rest of touch events. This should address the drag problem Flash plugin has. Fix http://b/issue?id=245053
Diffstat (limited to 'core/java/android/webkit/WebView.java')
-rw-r--r--core/java/android/webkit/WebView.java34
1 files changed, 24 insertions, 10 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 067241a60286..67543aac9001 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -375,6 +375,7 @@ public class WebView extends AbsoluteLayout
private static final int PREVENT_DRAG_NO = 0;
private static final int PREVENT_DRAG_MAYBE_YES = 1;
private static final int PREVENT_DRAG_YES = 2;
+ private static final int PREVENT_DRAG_CANCEL = 3;
private int mPreventDrag = PREVENT_DRAG_NO;
// by default mPreventLongPress is false. If it is true, long press event
@@ -4437,8 +4438,11 @@ public class WebView extends AbsoluteLayout
}
// pass the touch events from UI thread to WebCore thread
- if (mForwardTouchEvents && (action != MotionEvent.ACTION_MOVE
- || eventTime - mLastSentTouchTime > mCurrentTouchInterval)) {
+ if (mForwardTouchEvents
+ && (action != MotionEvent.ACTION_MOVE || eventTime
+ - mLastSentTouchTime > mCurrentTouchInterval)
+ && (action == MotionEvent.ACTION_DOWN
+ || mPreventDrag != PREVENT_DRAG_CANCEL)) {
WebViewCore.TouchEventData ted = new WebViewCore.TouchEventData();
ted.mAction = action;
ted.mX = viewToContentX((int) x + mScrollX);
@@ -5719,12 +5723,17 @@ public class WebView extends AbsoluteLayout
break;
}
case SWITCH_TO_SHORTPRESS: {
- // if mPreventDrag is not confirmed, treat it as no so that
- // it won't block panning the page.
+ // if mPreventDrag is not confirmed, cancel it so that it
+ // won't block panning the page.
if (mPreventDrag == PREVENT_DRAG_MAYBE_YES) {
- mPreventDrag = PREVENT_DRAG_NO;
+ mPreventDrag = PREVENT_DRAG_CANCEL;
mPreventLongPress = false;
mPreventDoubleTap = false;
+ // remove the pending TOUCH_EVENT and send a cancel
+ mWebViewCore.removeMessages(EventHub.TOUCH_EVENT);
+ WebViewCore.TouchEventData ted = new WebViewCore.TouchEventData();
+ ted.mAction = MotionEvent.ACTION_CANCEL;
+ mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
}
if (mTouchMode == TOUCH_INIT_MODE) {
mTouchMode = mFullScreenHolder == null
@@ -5751,7 +5760,7 @@ public class WebView extends AbsoluteLayout
// don't set it.
ted.mMetaState = 0;
mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
- } else if (mPreventDrag == PREVENT_DRAG_NO) {
+ } else if (mPreventDrag != PREVENT_DRAG_YES) {
mTouchMode = TOUCH_DONE_MODE;
if (mFullScreenHolder == null) {
performLongClick();
@@ -5762,13 +5771,18 @@ public class WebView extends AbsoluteLayout
}
case RELEASE_SINGLE_TAP: {
if (mPreventDrag == PREVENT_DRAG_MAYBE_YES) {
- // if mPreventDrag is not confirmed, treat it as
- // no so that it won't block tap.
- mPreventDrag = PREVENT_DRAG_NO;
+ // if mPreventDrag is not confirmed, cancel it so that
+ // it won't block panning the page.
+ mPreventDrag = PREVENT_DRAG_CANCEL;
mPreventLongPress = false;
mPreventDoubleTap = false;
+ // remove the pending TOUCH_EVENT and send a cancel
+ mWebViewCore.removeMessages(EventHub.TOUCH_EVENT);
+ WebViewCore.TouchEventData ted = new WebViewCore.TouchEventData();
+ ted.mAction = MotionEvent.ACTION_CANCEL;
+ mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
}
- if (mPreventDrag == PREVENT_DRAG_NO) {
+ if (mPreventDrag != PREVENT_DRAG_YES) {
mTouchMode = TOUCH_DONE_MODE;
doShortPress();
}