Merge "resolved conflicts for merge of 12e08f3a to master"

This commit is contained in:
Adam Powell
2010-09-12 13:14:16 -07:00
committed by Android (Google) Code Review
2 changed files with 54 additions and 18 deletions

View File

@@ -3390,6 +3390,14 @@ public class WebView extends AbsoluteLayout
// 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 @@ public class WebView extends AbsoluteLayout
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 @@ public class WebView extends AbsoluteLayout
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 @@ public class WebView extends AbsoluteLayout
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;

View File

@@ -166,6 +166,11 @@ class ZoomManager {
// 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 @@ class ZoomManager {
// 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 @@ class ZoomManager {
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