diff options
author | Grace Kloba <klobag@google.com> | 2010-01-12 10:00:03 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-01-12 10:00:03 -0800 |
commit | ce63c639e90daafc3382020bb2d9e2b17350f1f0 (patch) | |
tree | eed44fb71df1c4ad8d9812443e711cded04923d6 | |
parent | c93c70c4b849d31ff1b5e5cf2fb9462fd60e5da0 (diff) | |
parent | e67d5cee6706bf5b0af62965a5ccaadcc99002a6 (diff) | |
download | frameworks_base-ce63c639e90daafc3382020bb2d9e2b17350f1f0.zip frameworks_base-ce63c639e90daafc3382020bb2d9e2b17350f1f0.tar.gz frameworks_base-ce63c639e90daafc3382020bb2d9e2b17350f1f0.tar.bz2 |
Merge "DO NOT MERGE." into eclair
-rw-r--r-- | core/java/android/webkit/WebView.java | 41 | ||||
-rw-r--r-- | core/java/android/webkit/WebViewCore.java | 2 |
2 files changed, 22 insertions, 21 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 8308fd1..f6d6d22 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -2098,6 +2098,7 @@ public class WebView extends AbsoluteLayout mWebViewCore.sendMessage(EventHub.VIEW_SIZE_CHANGED, data); mLastWidthSent = newWidth; mLastHeightSent = newHeight; + mAnchorX = mAnchorY = 0; return true; } return false; @@ -3702,9 +3703,13 @@ public class WebView extends AbsoluteLayout private static boolean mSupportMultiTouch; private double mPinchDistance; + private float mLastPressure; private int mAnchorX; private int mAnchorY; + private static float SCALE_INCREMENT = 0.01f; + private static float PRESSURE_THRESHOLD = 0.67f; + private boolean doMultiTouch(MotionEvent ev) { int action = ev.getAction(); @@ -3719,28 +3724,25 @@ public class WebView extends AbsoluteLayout mWebTextView.setInPassword(false); } // start multi (2-pointer) touch - mPreviewZoomOnly = true; float x0 = ev.getX(0); float y0 = ev.getY(0); float x1 = ev.getX(1); float y1 = ev.getY(1); - mLastTouchTime = ev.getEventTime(); mPinchDistance = Math.sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1)); - mZoomCenterX = mZoomCenterY = 0; } else if ((action & 0xff) == MotionEvent.ACTION_POINTER_UP) { - mPreviewZoomOnly = false; - // for testing only, default don't reflow now - boolean reflowNow = !getSettings().getPluginsEnabled(); - // force zoom after mPreviewZoomOnly is set to false so that the new - // view size will be passed to the WebKit - if (reflowNow && (mZoomCenterX != 0) && (mZoomCenterY != 0)) { + if (mPreviewZoomOnly) { + mPreviewZoomOnly = false; mAnchorX = viewToContentX((int) mZoomCenterX + mScrollX); mAnchorY = viewToContentY((int) mZoomCenterY + mScrollY); + // for testing only, default don't reflow now + boolean reflowNow = !getSettings().getPluginsEnabled(); + // force zoom after mPreviewZoomOnly is set to false so that the + // new view size will be passed to the WebKit + setNewZoomScale(mActualScale, reflowNow, true); + // call invalidate() to draw without zoom filter + invalidate(); } - setNewZoomScale(mActualScale, reflowNow, true); - // call invalidate() to draw without zoom filter - invalidate(); // adjust the edit text view if needed if (inEditingMode()) { adjustTextView(true); @@ -3763,12 +3765,11 @@ public class WebView extends AbsoluteLayout * (y0 - y1)); float scale = (float) (Math.round(distance / mPinchDistance * mActualScale * 100) / 100.0); - long time = ev.getEventTime(); - // add distance/time checking to avoid the minor shift right before - // lifting the fingers after a pause - if (Math.abs(scale - mActualScale) >= 0.01f - && ((time - mLastTouchTime) < 300 || Math.abs(distance - - mPinchDistance) > (10 * mDefaultScale))) { + float pressure = ev.getPressure(0) + ev.getPressure(1); + if (Math.abs(scale - mActualScale) >= SCALE_INCREMENT + && (!mPreviewZoomOnly + || (pressure / mLastPressure) > PRESSURE_THRESHOLD)) { + mPreviewZoomOnly = true; // limit the scale change per step if (scale > mActualScale) { scale = Math.min(scale, mActualScale * 1.25f); @@ -3780,7 +3781,7 @@ public class WebView extends AbsoluteLayout setNewZoomScale(scale, false, false); invalidate(); mPinchDistance = distance; - mLastTouchTime = time; + mLastPressure = pressure; } } else { Log.w(LOGTAG, action + " should not happen during doMultiTouch"); @@ -3801,7 +3802,7 @@ public class WebView extends AbsoluteLayout } if (mSupportMultiTouch && getSettings().supportZoom() - && ev.getPointerCount() > 1) { + && mMinZoomScale < mMaxZoomScale && ev.getPointerCount() > 1) { return doMultiTouch(ev); } diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index 27b67d1..c3817fb 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -1518,7 +1518,7 @@ final class WebViewCore { } else if (mViewportWidth > 0) { width = Math.max(w, mViewportWidth); } else { - width = Math.max(w, nativeGetContentMinPrefWidth()); + width = Math.max(w, textwrapWidth); } } nativeSetSize(width, width == w ? h : Math.round((float) width * h / w), |