Merge change 27052 into eclair
* changes: If WebCore doesn't response touch down in time, don't block the UI tap, pan and double tap. Added a time out (which is same as shortpress time out, 200ms) for how long we wait for WebCore's response for touch down.
This commit is contained in:
@@ -356,7 +356,10 @@ public class WebView extends AbsoluteLayout
|
|||||||
// Whether to prevent drag during touch. The initial value depends on
|
// Whether to prevent drag during touch. The initial value depends on
|
||||||
// mForwardTouchEvents. If WebCore wants touch events, we assume it will
|
// mForwardTouchEvents. If WebCore wants touch events, we assume it will
|
||||||
// take control of touch events unless it says no for touch down event.
|
// take control of touch events unless it says no for touch down event.
|
||||||
private boolean mPreventDrag;
|
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 int mPreventDrag = PREVENT_DRAG_NO;
|
||||||
|
|
||||||
// To keep track of whether the current drag was initiated by a WebTextView,
|
// To keep track of whether the current drag was initiated by a WebTextView,
|
||||||
// so that we know not to hide the cursor
|
// so that we know not to hide the cursor
|
||||||
@@ -3710,7 +3713,8 @@ public class WebView extends AbsoluteLayout
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mTouchMode = TOUCH_INIT_MODE;
|
mTouchMode = TOUCH_INIT_MODE;
|
||||||
mPreventDrag = mForwardTouchEvents;
|
mPreventDrag = mForwardTouchEvents ? PREVENT_DRAG_MAYBE_YES
|
||||||
|
: PREVENT_DRAG_NO;
|
||||||
mWebViewCore.sendMessage(
|
mWebViewCore.sendMessage(
|
||||||
EventHub.UPDATE_FRAME_CACHE_IF_LOADING);
|
EventHub.UPDATE_FRAME_CACHE_IF_LOADING);
|
||||||
if (mLogEvent && eventTime - mLastTouchUpTime < 1000) {
|
if (mLogEvent && eventTime - mLastTouchUpTime < 1000) {
|
||||||
@@ -3751,11 +3755,15 @@ public class WebView extends AbsoluteLayout
|
|||||||
invalidate();
|
invalidate();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (mPreventDrag || (deltaX * deltaX + deltaY * deltaY)
|
if ((deltaX * deltaX + deltaY * deltaY) < mTouchSlopSquare) {
|
||||||
< mTouchSlopSquare) {
|
break;
|
||||||
|
}
|
||||||
|
if (mPreventDrag == PREVENT_DRAG_MAYBE_YES) {
|
||||||
|
// track mLastTouchTime as we may need to do fling at
|
||||||
|
// ACTION_UP
|
||||||
|
mLastTouchTime = eventTime;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTouchMode == TOUCH_SHORTPRESS_MODE
|
if (mTouchMode == TOUCH_SHORTPRESS_MODE
|
||||||
|| mTouchMode == TOUCH_SHORTPRESS_START_MODE) {
|
|| mTouchMode == TOUCH_SHORTPRESS_START_MODE) {
|
||||||
mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
|
mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
|
||||||
@@ -3884,15 +3892,6 @@ public class WebView extends AbsoluteLayout
|
|||||||
mTouchMode = TOUCH_DONE_MODE;
|
mTouchMode = TOUCH_DONE_MODE;
|
||||||
doDoubleTap();
|
doDoubleTap();
|
||||||
break;
|
break;
|
||||||
case TOUCH_INIT_MODE: // tap
|
|
||||||
mPrivateHandler.removeMessages(SWITCH_TO_SHORTPRESS);
|
|
||||||
if (!mPreventDrag) {
|
|
||||||
mPrivateHandler.sendMessageDelayed(
|
|
||||||
mPrivateHandler.obtainMessage(
|
|
||||||
RELEASE_SINGLE_TAP),
|
|
||||||
ViewConfiguration.getDoubleTapTimeout());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TOUCH_SHORTPRESS_START_MODE:
|
case TOUCH_SHORTPRESS_START_MODE:
|
||||||
case TOUCH_SHORTPRESS_MODE:
|
case TOUCH_SHORTPRESS_MODE:
|
||||||
mPrivateHandler.removeMessages(SWITCH_TO_SHORTPRESS);
|
mPrivateHandler.removeMessages(SWITCH_TO_SHORTPRESS);
|
||||||
@@ -3904,6 +3903,34 @@ public class WebView extends AbsoluteLayout
|
|||||||
commitCopy();
|
commitCopy();
|
||||||
mTouchSelection = false;
|
mTouchSelection = false;
|
||||||
break;
|
break;
|
||||||
|
case TOUCH_INIT_MODE: // tap
|
||||||
|
mPrivateHandler.removeMessages(SWITCH_TO_SHORTPRESS);
|
||||||
|
if ((deltaX * deltaX + deltaY * deltaY) > mTouchSlopSquare) {
|
||||||
|
Log.w(LOGTAG, "Miss a drag as we are waiting for" +
|
||||||
|
" WebCore's response for touch down.");
|
||||||
|
if (computeHorizontalScrollExtent() < computeHorizontalScrollRange()
|
||||||
|
|| computeVerticalScrollExtent() < computeVerticalScrollRange()) {
|
||||||
|
// we will not rewrite drag code here, but we
|
||||||
|
// will try fling if it applies.
|
||||||
|
WebViewCore.pauseUpdate(mWebViewCore);
|
||||||
|
// fall through to TOUCH_DRAG_MODE
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (mPreventDrag == PREVENT_DRAG_MAYBE_YES) {
|
||||||
|
// if mPreventDrag is not confirmed, treat it as
|
||||||
|
// no so that it won't block tap or double tap.
|
||||||
|
mPreventDrag = PREVENT_DRAG_NO;
|
||||||
|
}
|
||||||
|
if (mPreventDrag == PREVENT_DRAG_NO) {
|
||||||
|
mPrivateHandler.sendMessageDelayed(
|
||||||
|
mPrivateHandler.obtainMessage(
|
||||||
|
RELEASE_SINGLE_TAP),
|
||||||
|
ViewConfiguration.getDoubleTapTimeout());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case TOUCH_DRAG_MODE:
|
case TOUCH_DRAG_MODE:
|
||||||
// redraw in high-quality, as we're done dragging
|
// redraw in high-quality, as we're done dragging
|
||||||
invalidate();
|
invalidate();
|
||||||
@@ -4821,6 +4848,11 @@ public class WebView extends AbsoluteLayout
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SWITCH_TO_SHORTPRESS: {
|
case SWITCH_TO_SHORTPRESS: {
|
||||||
|
// if mPreventDrag is not confirmed, treat it as no so that
|
||||||
|
// it won't block panning the page.
|
||||||
|
if (mPreventDrag == PREVENT_DRAG_MAYBE_YES) {
|
||||||
|
mPreventDrag = PREVENT_DRAG_NO;
|
||||||
|
}
|
||||||
if (mTouchMode == TOUCH_INIT_MODE) {
|
if (mTouchMode == TOUCH_INIT_MODE) {
|
||||||
mTouchMode = TOUCH_SHORTPRESS_START_MODE;
|
mTouchMode = TOUCH_SHORTPRESS_START_MODE;
|
||||||
updateSelection();
|
updateSelection();
|
||||||
@@ -4830,7 +4862,7 @@ public class WebView extends AbsoluteLayout
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SWITCH_TO_LONGPRESS: {
|
case SWITCH_TO_LONGPRESS: {
|
||||||
if (!mPreventDrag) {
|
if (mPreventDrag == PREVENT_DRAG_NO) {
|
||||||
mTouchMode = TOUCH_DONE_MODE;
|
mTouchMode = TOUCH_DONE_MODE;
|
||||||
performLongClick();
|
performLongClick();
|
||||||
rebuildWebTextView();
|
rebuildWebTextView();
|
||||||
@@ -4838,7 +4870,7 @@ public class WebView extends AbsoluteLayout
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RELEASE_SINGLE_TAP: {
|
case RELEASE_SINGLE_TAP: {
|
||||||
if (!mPreventDrag) {
|
if (mPreventDrag == PREVENT_DRAG_NO) {
|
||||||
mTouchMode = TOUCH_DONE_MODE;
|
mTouchMode = TOUCH_DONE_MODE;
|
||||||
doShortPress();
|
doShortPress();
|
||||||
}
|
}
|
||||||
@@ -5064,9 +5096,14 @@ public class WebView extends AbsoluteLayout
|
|||||||
|
|
||||||
case PREVENT_TOUCH_ID:
|
case PREVENT_TOUCH_ID:
|
||||||
if (msg.arg1 == MotionEvent.ACTION_DOWN) {
|
if (msg.arg1 == MotionEvent.ACTION_DOWN) {
|
||||||
mPreventDrag = msg.arg2 == 1;
|
// dont override if mPreventDrag has been set to no due
|
||||||
if (mPreventDrag) {
|
// to time out
|
||||||
mTouchMode = TOUCH_DONE_MODE;
|
if (mPreventDrag == PREVENT_DRAG_MAYBE_YES) {
|
||||||
|
mPreventDrag = msg.arg2 == 1 ? PREVENT_DRAG_YES
|
||||||
|
: PREVENT_DRAG_NO;
|
||||||
|
if (mPreventDrag == PREVENT_DRAG_YES) {
|
||||||
|
mTouchMode = TOUCH_DONE_MODE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user