am ce63c639: Merge "DO NOT MERGE." into eclair

Merge commit 'ce63c639e90daafc3382020bb2d9e2b17350f1f0' into eclair-plus-aosp

* commit 'ce63c639e90daafc3382020bb2d9e2b17350f1f0':
  DO NOT MERGE.
This commit is contained in:
Grace Kloba
2010-01-12 10:02:48 -08:00
committed by Android Git Automerger
2 changed files with 22 additions and 21 deletions

View File

@@ -2098,6 +2098,7 @@ public class WebView extends AbsoluteLayout
mWebViewCore.sendMessage(EventHub.VIEW_SIZE_CHANGED, data); mWebViewCore.sendMessage(EventHub.VIEW_SIZE_CHANGED, data);
mLastWidthSent = newWidth; mLastWidthSent = newWidth;
mLastHeightSent = newHeight; mLastHeightSent = newHeight;
mAnchorX = mAnchorY = 0;
return true; return true;
} }
return false; return false;
@@ -3702,9 +3703,13 @@ public class WebView extends AbsoluteLayout
private static boolean mSupportMultiTouch; private static boolean mSupportMultiTouch;
private double mPinchDistance; private double mPinchDistance;
private float mLastPressure;
private int mAnchorX; private int mAnchorX;
private int mAnchorY; private int mAnchorY;
private static float SCALE_INCREMENT = 0.01f;
private static float PRESSURE_THRESHOLD = 0.67f;
private boolean doMultiTouch(MotionEvent ev) { private boolean doMultiTouch(MotionEvent ev) {
int action = ev.getAction(); int action = ev.getAction();
@@ -3719,28 +3724,25 @@ public class WebView extends AbsoluteLayout
mWebTextView.setInPassword(false); mWebTextView.setInPassword(false);
} }
// start multi (2-pointer) touch // start multi (2-pointer) touch
mPreviewZoomOnly = true;
float x0 = ev.getX(0); float x0 = ev.getX(0);
float y0 = ev.getY(0); float y0 = ev.getY(0);
float x1 = ev.getX(1); float x1 = ev.getX(1);
float y1 = ev.getY(1); float y1 = ev.getY(1);
mLastTouchTime = ev.getEventTime();
mPinchDistance = Math.sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) mPinchDistance = Math.sqrt((x0 - x1) * (x0 - x1) + (y0 - y1)
* (y0 - y1)); * (y0 - y1));
mZoomCenterX = mZoomCenterY = 0;
} else if ((action & 0xff) == MotionEvent.ACTION_POINTER_UP) { } else if ((action & 0xff) == MotionEvent.ACTION_POINTER_UP) {
mPreviewZoomOnly = false; if (mPreviewZoomOnly) {
// for testing only, default don't reflow now mPreviewZoomOnly = false;
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)) {
mAnchorX = viewToContentX((int) mZoomCenterX + mScrollX); mAnchorX = viewToContentX((int) mZoomCenterX + mScrollX);
mAnchorY = viewToContentY((int) mZoomCenterY + mScrollY); 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 // adjust the edit text view if needed
if (inEditingMode()) { if (inEditingMode()) {
adjustTextView(true); adjustTextView(true);
@@ -3763,12 +3765,11 @@ public class WebView extends AbsoluteLayout
* (y0 - y1)); * (y0 - y1));
float scale = (float) (Math.round(distance / mPinchDistance float scale = (float) (Math.round(distance / mPinchDistance
* mActualScale * 100) / 100.0); * mActualScale * 100) / 100.0);
long time = ev.getEventTime(); float pressure = ev.getPressure(0) + ev.getPressure(1);
// add distance/time checking to avoid the minor shift right before if (Math.abs(scale - mActualScale) >= SCALE_INCREMENT
// lifting the fingers after a pause && (!mPreviewZoomOnly
if (Math.abs(scale - mActualScale) >= 0.01f || (pressure / mLastPressure) > PRESSURE_THRESHOLD)) {
&& ((time - mLastTouchTime) < 300 || Math.abs(distance mPreviewZoomOnly = true;
- mPinchDistance) > (10 * mDefaultScale))) {
// limit the scale change per step // limit the scale change per step
if (scale > mActualScale) { if (scale > mActualScale) {
scale = Math.min(scale, mActualScale * 1.25f); scale = Math.min(scale, mActualScale * 1.25f);
@@ -3780,7 +3781,7 @@ public class WebView extends AbsoluteLayout
setNewZoomScale(scale, false, false); setNewZoomScale(scale, false, false);
invalidate(); invalidate();
mPinchDistance = distance; mPinchDistance = distance;
mLastTouchTime = time; mLastPressure = pressure;
} }
} else { } else {
Log.w(LOGTAG, action + " should not happen during doMultiTouch"); Log.w(LOGTAG, action + " should not happen during doMultiTouch");
@@ -3801,7 +3802,7 @@ public class WebView extends AbsoluteLayout
} }
if (mSupportMultiTouch && getSettings().supportZoom() if (mSupportMultiTouch && getSettings().supportZoom()
&& ev.getPointerCount() > 1) { && mMinZoomScale < mMaxZoomScale && ev.getPointerCount() > 1) {
return doMultiTouch(ev); return doMultiTouch(ev);
} }

View File

@@ -1518,7 +1518,7 @@ final class WebViewCore {
} else if (mViewportWidth > 0) { } else if (mViewportWidth > 0) {
width = Math.max(w, mViewportWidth); width = Math.max(w, mViewportWidth);
} else { } else {
width = Math.max(w, nativeGetContentMinPrefWidth()); width = Math.max(w, textwrapWidth);
} }
} }
nativeSetSize(width, width == w ? h : Math.round((float) width * h / w), nativeSetSize(width, width == w ? h : Math.round((float) width * h / w),