am ba6339fe: Merge "If we defer processing the touch events, pass the original view coordinate with TouchEventData and use them when we reprocess the events. We can\'t depend on contentToView() to convert the doc point to the view point. When we originally convert the

Merge commit 'ba6339fe2ba2d7325a99201e82d951064efa31a2' into froyo-plus-aosp

* commit 'ba6339fe2ba2d7325a99201e82d951064efa31a2':
  If we defer processing the touch events, pass the
This commit is contained in:
Grace Kloba
2010-04-13 17:24:04 -07:00
committed by Android Git Automerger
2 changed files with 33 additions and 17 deletions

View File

@@ -4659,13 +4659,16 @@ public class WebView extends AbsoluteLayout
ted.mY = contentY; ted.mY = contentY;
ted.mMetaState = ev.getMetaState(); ted.mMetaState = ev.getMetaState();
ted.mReprocess = mDeferTouchProcess; ted.mReprocess = mDeferTouchProcess;
mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
if (mDeferTouchProcess) { if (mDeferTouchProcess) {
// still needs to set them for compute deltaX/Y // still needs to set them for compute deltaX/Y
mLastTouchX = x; mLastTouchX = x;
mLastTouchY = y; mLastTouchY = y;
ted.mViewX = x;
ted.mViewY = y;
mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
break; break;
} }
mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
if (!inFullScreenMode()) { if (!inFullScreenMode()) {
mPrivateHandler.sendMessageDelayed(mPrivateHandler mPrivateHandler.sendMessageDelayed(mPrivateHandler
.obtainMessage(PREVENT_DEFAULT_TIMEOUT, .obtainMessage(PREVENT_DEFAULT_TIMEOUT,
@@ -4691,17 +4694,20 @@ public class WebView extends AbsoluteLayout
// pass the touch events from UI thread to WebCore thread // pass the touch events from UI thread to WebCore thread
if (shouldForwardTouchEvent() && mConfirmMove && (firstMove if (shouldForwardTouchEvent() && mConfirmMove && (firstMove
|| eventTime - mLastSentTouchTime > mCurrentTouchInterval)) { || eventTime - mLastSentTouchTime > mCurrentTouchInterval)) {
mLastSentTouchTime = eventTime;
TouchEventData ted = new TouchEventData(); TouchEventData ted = new TouchEventData();
ted.mAction = action; ted.mAction = action;
ted.mX = contentX; ted.mX = contentX;
ted.mY = contentY; ted.mY = contentY;
ted.mMetaState = ev.getMetaState(); ted.mMetaState = ev.getMetaState();
ted.mReprocess = mDeferTouchProcess; ted.mReprocess = mDeferTouchProcess;
mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
mLastSentTouchTime = eventTime;
if (mDeferTouchProcess) { if (mDeferTouchProcess) {
ted.mViewX = x;
ted.mViewY = y;
mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
break; break;
} }
mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
if (firstMove && !inFullScreenMode()) { if (firstMove && !inFullScreenMode()) {
mPrivateHandler.sendMessageDelayed(mPrivateHandler mPrivateHandler.sendMessageDelayed(mPrivateHandler
.obtainMessage(PREVENT_DEFAULT_TIMEOUT, .obtainMessage(PREVENT_DEFAULT_TIMEOUT,
@@ -4866,6 +4872,10 @@ public class WebView extends AbsoluteLayout
ted.mY = contentY; ted.mY = contentY;
ted.mMetaState = ev.getMetaState(); ted.mMetaState = ev.getMetaState();
ted.mReprocess = mDeferTouchProcess; ted.mReprocess = mDeferTouchProcess;
if (mDeferTouchProcess) {
ted.mViewX = x;
ted.mViewY = y;
}
mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted); mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
} }
mLastTouchUpTime = eventTime; mLastTouchUpTime = eventTime;
@@ -4880,6 +4890,10 @@ public class WebView extends AbsoluteLayout
ted.mY = contentY; ted.mY = contentY;
ted.mMetaState = ev.getMetaState(); ted.mMetaState = ev.getMetaState();
ted.mReprocess = mDeferTouchProcess; ted.mReprocess = mDeferTouchProcess;
if (mDeferTouchProcess) {
ted.mViewX = x;
ted.mViewY = y;
}
mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted); mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
} else if (mPreventDefault != PREVENT_DEFAULT_YES){ } else if (mPreventDefault != PREVENT_DEFAULT_YES){
doDoubleTap(); doDoubleTap();
@@ -6156,6 +6170,10 @@ public class WebView extends AbsoluteLayout
// simplicity for now, we don't set it. // simplicity for now, we don't set it.
ted.mMetaState = 0; ted.mMetaState = 0;
ted.mReprocess = mDeferTouchProcess; ted.mReprocess = mDeferTouchProcess;
if (mDeferTouchProcess) {
ted.mViewX = mLastTouchX;
ted.mViewY = mLastTouchY;
}
mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted); mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
} else if (mPreventDefault != PREVENT_DEFAULT_YES) { } else if (mPreventDefault != PREVENT_DEFAULT_YES) {
mTouchMode = TOUCH_DONE_MODE; mTouchMode = TOUCH_DONE_MODE;
@@ -6452,31 +6470,27 @@ public class WebView extends AbsoluteLayout
TouchEventData ted = (TouchEventData) msg.obj; TouchEventData ted = (TouchEventData) msg.obj;
switch (ted.mAction) { switch (ted.mAction) {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
mLastDeferTouchX = contentToViewX(ted.mX) mLastDeferTouchX = ted.mViewX;
- mScrollX; mLastDeferTouchY = ted.mViewY;
mLastDeferTouchY = contentToViewY(ted.mY)
- mScrollY;
mDeferTouchMode = TOUCH_INIT_MODE; mDeferTouchMode = TOUCH_INIT_MODE;
break; break;
case MotionEvent.ACTION_MOVE: { case MotionEvent.ACTION_MOVE: {
// no snapping in defer process // no snapping in defer process
int x = contentToViewX(ted.mX) - mScrollX;
int y = contentToViewY(ted.mY) - mScrollY;
if (mDeferTouchMode != TOUCH_DRAG_MODE) { if (mDeferTouchMode != TOUCH_DRAG_MODE) {
mDeferTouchMode = TOUCH_DRAG_MODE; mDeferTouchMode = TOUCH_DRAG_MODE;
mLastDeferTouchX = x; mLastDeferTouchX = ted.mViewX;
mLastDeferTouchY = y; mLastDeferTouchY = ted.mViewY;
startDrag(); startDrag();
} }
int deltaX = pinLocX((int) (mScrollX int deltaX = pinLocX((int) (mScrollX
+ mLastDeferTouchX - x)) + mLastDeferTouchX - ted.mViewX))
- mScrollX; - mScrollX;
int deltaY = pinLocY((int) (mScrollY int deltaY = pinLocY((int) (mScrollY
+ mLastDeferTouchY - y)) + mLastDeferTouchY - ted.mViewY))
- mScrollY; - mScrollY;
doDrag(deltaX, deltaY); doDrag(deltaX, deltaY);
if (deltaX != 0) mLastDeferTouchX = x; if (deltaX != 0) mLastDeferTouchX = ted.mViewX;
if (deltaY != 0) mLastDeferTouchY = y; if (deltaY != 0) mLastDeferTouchY = ted.mViewY;
break; break;
} }
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
@@ -6489,8 +6503,8 @@ public class WebView extends AbsoluteLayout
break; break;
case WebViewCore.ACTION_DOUBLETAP: case WebViewCore.ACTION_DOUBLETAP:
// doDoubleTap() needs mLastTouchX/Y as anchor // doDoubleTap() needs mLastTouchX/Y as anchor
mLastTouchX = contentToViewX(ted.mX) - mScrollX; mLastTouchX = ted.mViewX;
mLastTouchY = contentToViewY(ted.mY) - mScrollY; mLastTouchY = ted.mViewY;
doDoubleTap(); doDoubleTap();
mDeferTouchMode = TOUCH_DONE_MODE; mDeferTouchMode = TOUCH_DONE_MODE;
break; break;

View File

@@ -708,6 +708,8 @@ final class WebViewCore {
int mY; int mY;
int mMetaState; int mMetaState;
boolean mReprocess; boolean mReprocess;
float mViewX;
float mViewY;
} }
static class GeolocationPermissionsData { static class GeolocationPermissionsData {