am f5cf85d0: am d1e89c41: am b1c43c32: Merge "b/4116658 Fix the jumpy scrolling with some flash site." into honeycomb-mr1
* commit 'f5cf85d07c99ae834d1b58bf5109982f9a4f3604':
b/4116658 Fix the jumpy scrolling with some flash site.
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 0c1e39e..056650c 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -1663,6 +1663,7 @@
mDrawHistory = true;
mHistoryPicture = p;
+
mScrollX = sx;
mScrollY = sy;
mZoomManager.restoreZoomState(b);
@@ -5458,7 +5459,6 @@
private boolean handleTouchEventCommon(MotionEvent ev, int action, int x, int y) {
long eventTime = ev.getEventTime();
-
// Due to the touch screen edge effect, a touch closer to the edge
// always snapped to the edge. As getViewWidth() can be different from
// getWidth() due to the scrollbar, adjusting the point to match
@@ -5562,6 +5562,8 @@
ted.mIds[0] = ev.getPointerId(0);
ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(contentX, contentY);
+ ted.mPointsInView = new Point[1];
+ ted.mPointsInView[0] = new Point(x, y);
ted.mMetaState = ev.getMetaState();
ted.mReprocess = mDeferTouchProcess;
ted.mNativeLayer = nativeScrollableLayer(
@@ -5609,6 +5611,8 @@
ted.mIds[0] = ev.getPointerId(0);
ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(contentX, contentY);
+ ted.mPointsInView = new Point[1];
+ ted.mPointsInView[0] = new Point(x, y);
ted.mMetaState = ev.getMetaState();
ted.mReprocess = mDeferTouchProcess;
ted.mNativeLayer = mScrollingLayer;
@@ -5791,6 +5795,8 @@
ted.mAction = action;
ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(contentX, contentY);
+ ted.mPointsInView = new Point[1];
+ ted.mPointsInView[0] = new Point(x, y);
ted.mMetaState = ev.getMetaState();
ted.mReprocess = mDeferTouchProcess;
ted.mNativeLayer = mScrollingLayer;
@@ -5813,6 +5819,8 @@
ted.mAction = WebViewCore.ACTION_DOUBLETAP;
ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(contentX, contentY);
+ ted.mPointsInView = new Point[1];
+ ted.mPointsInView[0] = new Point(x, y);
ted.mMetaState = ev.getMetaState();
ted.mReprocess = mDeferTouchProcess;
ted.mNativeLayer = nativeScrollableLayer(
@@ -5949,11 +5957,13 @@
final int count = ev.getPointerCount();
ted.mIds = new int[count];
ted.mPoints = new Point[count];
+ ted.mPointsInView = new Point[count];
for (int c = 0; c < count; c++) {
ted.mIds[c] = ev.getPointerId(c);
int x = viewToContentX((int) ev.getX(c) + mScrollX);
int y = viewToContentY((int) ev.getY(c) + mScrollY);
ted.mPoints[c] = new Point(x, y);
+ ted.mPointsInView[c] = new Point((int) ev.getX(c), (int) ev.getY(c));
}
if (ted.mAction == MotionEvent.ACTION_POINTER_DOWN
|| ted.mAction == MotionEvent.ACTION_POINTER_UP) {
@@ -6038,6 +6048,10 @@
ted.mIds[0] = 0;
ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(x, y);
+ ted.mPointsInView = new Point[1];
+ int viewX = contentToViewX(x) - mScrollX;
+ int viewY = contentToViewY(y) - mScrollY;
+ ted.mPointsInView[0] = new Point(viewX, viewY);
ted.mAction = MotionEvent.ACTION_CANCEL;
ted.mNativeLayer = nativeScrollableLayer(
x, y, ted.mNativeLayerRect, null);
@@ -7426,16 +7440,15 @@
// Following is for single touch.
switch (ted.mAction) {
case MotionEvent.ACTION_DOWN:
- mLastDeferTouchX = contentToViewX(ted.mPoints[0].x)
- - mScrollX;
- mLastDeferTouchY = contentToViewY(ted.mPoints[0].y)
- - mScrollY;
+ mLastDeferTouchX = ted.mPointsInView[0].x;
+ mLastDeferTouchY = ted.mPointsInView[0].y;
mDeferTouchMode = TOUCH_INIT_MODE;
break;
case MotionEvent.ACTION_MOVE: {
// no snapping in defer process
- int x = contentToViewX(ted.mPoints[0].x) - mScrollX;
- int y = contentToViewY(ted.mPoints[0].y) - mScrollY;
+ int x = ted.mPointsInView[0].x;
+ int y = ted.mPointsInView[0].y;
+
if (mDeferTouchMode != TOUCH_DRAG_MODE) {
mDeferTouchMode = TOUCH_DRAG_MODE;
mLastDeferTouchX = x;
@@ -7469,8 +7482,8 @@
break;
case WebViewCore.ACTION_DOUBLETAP:
// doDoubleTap() needs mLastTouchX/Y as anchor
- mLastTouchX = contentToViewX(ted.mPoints[0].x) - mScrollX;
- mLastTouchY = contentToViewY(ted.mPoints[0].y) - mScrollY;
+ mLastDeferTouchX = ted.mPointsInView[0].x;
+ mLastDeferTouchY = ted.mPointsInView[0].y;
mZoomManager.handleDoubleTap(mLastTouchX, mLastTouchY);
mDeferTouchMode = TOUCH_DONE_MODE;
break;
@@ -7594,6 +7607,8 @@
ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(viewToContentX(mLastTouchX + mScrollX),
viewToContentY(mLastTouchY + mScrollY));
+ ted.mPointsInView = new Point[1];
+ ted.mPointsInView[0] = new Point(mLastTouchX, mLastTouchY);
// metaState for long press is tricky. Should it be the
// state when the press started or when the press was
// released? Or some intermediary key state? For
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index 3b989dc..0271695 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -831,6 +831,7 @@
int mAction;
int[] mIds; // Ids of the touch points
Point[] mPoints;
+ Point[] mPointsInView; // the point coordinates in view axis.
int mActionIndex; // Associated pointer index for ACTION_POINTER_DOWN/UP
int mMetaState;
boolean mReprocess;