resolved conflicts for merge of 12e08f3a to master
Change-Id: Ic691ec7716d5c450406717d3748847cb9c6b7e82
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index bc85444..27178ab 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -3390,6 +3390,14 @@
// to windows overview, the WebView will be temporarily removed from the
// view system. In that case, do nothing.
if (getParent() == null) return false;
+
+ // A multi-finger gesture can look like a long press; make sure we don't take
+ // long press actions if we're scaling.
+ final ScaleGestureDetector detector = mZoomManager.getMultiTouchGestureDetector();
+ if (detector != null && detector.isInProgress()) {
+ return false;
+ }
+
if (mNativeClass != 0 && nativeCursorIsTextInput()) {
// Send the click so that the textfield is in focus
centerKeyPressOnTextField();
@@ -4838,7 +4846,7 @@
mTouchMode != TOUCH_DRAG_LAYER_MODE && !skipScaleGesture) {
// if the page disallows zoom, skip multi-pointer action
- if (mZoomManager.isZoomScaleFixed()) {
+ if (!mZoomManager.supportsPanDuringZoom() && mZoomManager.isZoomScaleFixed()) {
return true;
}
@@ -4849,17 +4857,28 @@
MotionEvent temp = MotionEvent.obtain(ev);
// Clear the original event and set it to
// ACTION_POINTER_DOWN.
- temp.setAction(temp.getAction() &
- ~MotionEvent.ACTION_MASK |
- MotionEvent.ACTION_POINTER_DOWN);
- detector.onTouchEvent(temp);
+ try {
+ temp.setAction(temp.getAction() &
+ ~MotionEvent.ACTION_MASK |
+ MotionEvent.ACTION_POINTER_DOWN);
+ detector.onTouchEvent(temp);
+ } finally {
+ temp.recycle();
+ }
}
detector.onTouchEvent(ev);
if (detector.isInProgress()) {
mLastTouchTime = eventTime;
- return true;
+ cancelLongPress();
+ if (!mZoomManager.supportsPanDuringZoom()) {
+ return true;
+ }
+ mTouchMode = TOUCH_DRAG_MODE;
+ if (mVelocityTracker == null) {
+ mVelocityTracker = VelocityTracker.obtain();
+ }
}
x = detector.getFocusX();
@@ -5073,15 +5092,21 @@
mLastTouchTime = eventTime;
break;
}
- // if it starts nearly horizontal or vertical, enforce it
- int ax = Math.abs(deltaX);
- int ay = Math.abs(deltaY);
- if (ax > MAX_SLOPE_FOR_DIAG * ay) {
- mSnapScrollMode = SNAP_X;
- mSnapPositive = deltaX > 0;
- } else if (ay > MAX_SLOPE_FOR_DIAG * ax) {
- mSnapScrollMode = SNAP_Y;
- mSnapPositive = deltaY > 0;
+
+ // Only lock dragging to one axis if we don't have a scale in progress.
+ // Scaling implies free-roaming movement. Note this is only ever a question
+ // if mZoomManager.supportsPanDuringZoom() is true.
+ if (detector != null && !detector.isInProgress()) {
+ // if it starts nearly horizontal or vertical, enforce it
+ int ax = Math.abs(deltaX);
+ int ay = Math.abs(deltaY);
+ if (ax > MAX_SLOPE_FOR_DIAG * ay) {
+ mSnapScrollMode = SNAP_X;
+ mSnapPositive = deltaX > 0;
+ } else if (ay > MAX_SLOPE_FOR_DIAG * ax) {
+ mSnapScrollMode = SNAP_Y;
+ mSnapPositive = deltaY > 0;
+ }
}
mTouchMode = TOUCH_DRAG_MODE;
diff --git a/core/java/android/webkit/ZoomManager.java b/core/java/android/webkit/ZoomManager.java
index 1323217..a760e91 100644
--- a/core/java/android/webkit/ZoomManager.java
+++ b/core/java/android/webkit/ZoomManager.java
@@ -166,6 +166,11 @@
// whether support multi-touch
private boolean mSupportMultiTouch;
+
+ /**
+ * True if we have a touch panel capable of detecting smooth pan/scale at the same time
+ */
+ private boolean mAllowPanAndScale;
// use the framework's ScaleGestureDetector to handle multi-touch
private ScaleGestureDetector mScaleDetector;
@@ -599,10 +604,12 @@
// check the preconditions
assert mWebView.getSettings() != null;
- WebSettings settings = mWebView.getSettings();
- mSupportMultiTouch = context.getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH)
+ final WebSettings settings = mWebView.getSettings();
+ final PackageManager pm = context.getPackageManager();
+ mSupportMultiTouch = pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH)
&& settings.supportZoom() && settings.getBuiltInZoomControls();
+ mAllowPanAndScale = pm.hasSystemFeature(
+ PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT);
if (mSupportMultiTouch && (mScaleDetector == null)) {
mScaleDetector = new ScaleGestureDetector(context, new ScaleDetectorListener());
} else if (!mSupportMultiTouch && (mScaleDetector != null)) {
@@ -614,6 +621,10 @@
return mSupportMultiTouch;
}
+ public boolean supportsPanDuringZoom() {
+ return mAllowPanAndScale;
+ }
+
/**
* Notifies the caller that the ZoomManager is requesting that scale related
* updates should not be sent to webkit. This can occur in cases where the