summaryrefslogtreecommitdiffstats
path: root/core/java/android/webkit
diff options
context:
space:
mode:
authorGrace Kloba <klobag@google.com>2010-04-13 16:27:41 -0700
committerGrace Kloba <klobag@google.com>2010-04-13 16:27:41 -0700
commit102ed89dbccdebb8d4c1fc0c3ec2957d55be1a22 (patch)
tree6600ead3496f9498af00d9fc6af260edeaf05304 /core/java/android/webkit
parentdb281311a0e957ba989509cf11f2085b4db12074 (diff)
downloadframeworks_base-102ed89dbccdebb8d4c1fc0c3ec2957d55be1a22.zip
frameworks_base-102ed89dbccdebb8d4c1fc0c3ec2957d55be1a22.tar.gz
frameworks_base-102ed89dbccdebb8d4c1fc0c3ec2957d55be1a22.tar.bz2
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 view to doc, the scroll position in UI doesn't change. When we convert the doc back to view, we are chasing a moving target. That is why we saw bigger delta. Fix http://b/issue?id=2577274
Diffstat (limited to 'core/java/android/webkit')
-rw-r--r--core/java/android/webkit/WebView.java48
-rw-r--r--core/java/android/webkit/WebViewCore.java2
2 files changed, 33 insertions, 17 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 06a7a6f..7bd83e7 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -4659,13 +4659,16 @@ public class WebView extends AbsoluteLayout
ted.mY = contentY;
ted.mMetaState = ev.getMetaState();
ted.mReprocess = mDeferTouchProcess;
- mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
if (mDeferTouchProcess) {
// still needs to set them for compute deltaX/Y
mLastTouchX = x;
mLastTouchY = y;
+ ted.mViewX = x;
+ ted.mViewY = y;
+ mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
break;
}
+ mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
if (!inFullScreenMode()) {
mPrivateHandler.sendMessageDelayed(mPrivateHandler
.obtainMessage(PREVENT_DEFAULT_TIMEOUT,
@@ -4691,17 +4694,20 @@ public class WebView extends AbsoluteLayout
// pass the touch events from UI thread to WebCore thread
if (shouldForwardTouchEvent() && mConfirmMove && (firstMove
|| eventTime - mLastSentTouchTime > mCurrentTouchInterval)) {
+ mLastSentTouchTime = eventTime;
TouchEventData ted = new TouchEventData();
ted.mAction = action;
ted.mX = contentX;
ted.mY = contentY;
ted.mMetaState = ev.getMetaState();
ted.mReprocess = mDeferTouchProcess;
- mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
- mLastSentTouchTime = eventTime;
if (mDeferTouchProcess) {
+ ted.mViewX = x;
+ ted.mViewY = y;
+ mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
break;
}
+ mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
if (firstMove && !inFullScreenMode()) {
mPrivateHandler.sendMessageDelayed(mPrivateHandler
.obtainMessage(PREVENT_DEFAULT_TIMEOUT,
@@ -4866,6 +4872,10 @@ public class WebView extends AbsoluteLayout
ted.mY = contentY;
ted.mMetaState = ev.getMetaState();
ted.mReprocess = mDeferTouchProcess;
+ if (mDeferTouchProcess) {
+ ted.mViewX = x;
+ ted.mViewY = y;
+ }
mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
}
mLastTouchUpTime = eventTime;
@@ -4880,6 +4890,10 @@ public class WebView extends AbsoluteLayout
ted.mY = contentY;
ted.mMetaState = ev.getMetaState();
ted.mReprocess = mDeferTouchProcess;
+ if (mDeferTouchProcess) {
+ ted.mViewX = x;
+ ted.mViewY = y;
+ }
mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
} else if (mPreventDefault != PREVENT_DEFAULT_YES){
doDoubleTap();
@@ -6156,6 +6170,10 @@ public class WebView extends AbsoluteLayout
// simplicity for now, we don't set it.
ted.mMetaState = 0;
ted.mReprocess = mDeferTouchProcess;
+ if (mDeferTouchProcess) {
+ ted.mViewX = mLastTouchX;
+ ted.mViewY = mLastTouchY;
+ }
mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted);
} else if (mPreventDefault != PREVENT_DEFAULT_YES) {
mTouchMode = TOUCH_DONE_MODE;
@@ -6452,31 +6470,27 @@ public class WebView extends AbsoluteLayout
TouchEventData ted = (TouchEventData) msg.obj;
switch (ted.mAction) {
case MotionEvent.ACTION_DOWN:
- mLastDeferTouchX = contentToViewX(ted.mX)
- - mScrollX;
- mLastDeferTouchY = contentToViewY(ted.mY)
- - mScrollY;
+ mLastDeferTouchX = ted.mViewX;
+ mLastDeferTouchY = ted.mViewY;
mDeferTouchMode = TOUCH_INIT_MODE;
break;
case MotionEvent.ACTION_MOVE: {
// no snapping in defer process
- int x = contentToViewX(ted.mX) - mScrollX;
- int y = contentToViewY(ted.mY) - mScrollY;
if (mDeferTouchMode != TOUCH_DRAG_MODE) {
mDeferTouchMode = TOUCH_DRAG_MODE;
- mLastDeferTouchX = x;
- mLastDeferTouchY = y;
+ mLastDeferTouchX = ted.mViewX;
+ mLastDeferTouchY = ted.mViewY;
startDrag();
}
int deltaX = pinLocX((int) (mScrollX
- + mLastDeferTouchX - x))
+ + mLastDeferTouchX - ted.mViewX))
- mScrollX;
int deltaY = pinLocY((int) (mScrollY
- + mLastDeferTouchY - y))
+ + mLastDeferTouchY - ted.mViewY))
- mScrollY;
doDrag(deltaX, deltaY);
- if (deltaX != 0) mLastDeferTouchX = x;
- if (deltaY != 0) mLastDeferTouchY = y;
+ if (deltaX != 0) mLastDeferTouchX = ted.mViewX;
+ if (deltaY != 0) mLastDeferTouchY = ted.mViewY;
break;
}
case MotionEvent.ACTION_UP:
@@ -6489,8 +6503,8 @@ public class WebView extends AbsoluteLayout
break;
case WebViewCore.ACTION_DOUBLETAP:
// doDoubleTap() needs mLastTouchX/Y as anchor
- mLastTouchX = contentToViewX(ted.mX) - mScrollX;
- mLastTouchY = contentToViewY(ted.mY) - mScrollY;
+ mLastTouchX = ted.mViewX;
+ mLastTouchY = ted.mViewY;
doDoubleTap();
mDeferTouchMode = TOUCH_DONE_MODE;
break;
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index 625e7ba..0175aed 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -708,6 +708,8 @@ final class WebViewCore {
int mY;
int mMetaState;
boolean mReprocess;
+ float mViewX;
+ float mViewY;
}
static class GeolocationPermissionsData {