summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGrace Kloba <klobag@google.com>2010-01-11 17:28:01 -0800
committerGrace Kloba <klobag@google.com>2010-01-12 09:58:43 -0800
commite67d5cee6706bf5b0af62965a5ccaadcc99002a6 (patch)
treed48d7369aee9e677d6a1ff724a87817ee5294ed4 /core
parentdfe25b0e0c382d04a59bb03c7f5f8689ece5395e (diff)
downloadframeworks_base-e67d5cee6706bf5b0af62965a5ccaadcc99002a6.zip
frameworks_base-e67d5cee6706bf5b0af62965a5ccaadcc99002a6.tar.gz
frameworks_base-e67d5cee6706bf5b0af62965a5ccaadcc99002a6.tar.bz2
DO NOT MERGE.
Couple of tweak for multi-touch in WebView. 1. If we can't zoom, don't get in multitouch mode. This avoid the logo in google.com looks fuzzy. 2. Reset mAnchor after sending VIEW_SIZE_CHANGED. 3. Don't call zoom when finishing multitouch unless zoom is called before. 4. Change the width for nativeSetSize, which was modified in the last check-in. The new logic should make both msn.com and news.google.com looks correct. 5. Use the pressure instead of distance/time to filter out the jitter just before lifting the finger. Fix http://b/issue?id=2360032
Diffstat (limited to 'core')
-rw-r--r--core/java/android/webkit/WebView.java41
-rw-r--r--core/java/android/webkit/WebViewCore.java2
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),