am f6aed0e0: Merge "DO NOT MERGE" into eclair
Merge commit 'f6aed0e0a7c96094b66f5426baad78032b794497' into eclair-plus-aosp * commit 'f6aed0e0a7c96094b66f5426baad78032b794497': DO NOT MERGE
This commit is contained in:
@@ -536,8 +536,10 @@ public class WebView extends AbsoluteLayout
|
|||||||
static int DEFAULT_SCALE_PERCENT;
|
static int DEFAULT_SCALE_PERCENT;
|
||||||
private float mDefaultScale;
|
private float mDefaultScale;
|
||||||
|
|
||||||
// set to true temporarily while the zoom control is being dragged
|
// set to true temporarily during ScaleGesture triggered zoom
|
||||||
private boolean mPreviewZoomOnly = false;
|
private boolean mPreviewZoomOnly = false;
|
||||||
|
// extra scale during zoom preview
|
||||||
|
private float mPreviewExtraZoomScale = 1.0f;
|
||||||
|
|
||||||
// computed scale and inverse, from mZoomWidth.
|
// computed scale and inverse, from mZoomWidth.
|
||||||
private float mActualScale;
|
private float mActualScale;
|
||||||
@@ -2810,7 +2812,9 @@ public class WebView extends AbsoluteLayout
|
|||||||
nativeRecordButtons(hasFocus() && hasWindowFocus(),
|
nativeRecordButtons(hasFocus() && hasWindowFocus(),
|
||||||
mTouchMode == TOUCH_SHORTPRESS_START_MODE
|
mTouchMode == TOUCH_SHORTPRESS_START_MODE
|
||||||
|| mTrackballDown || mGotCenterDown, false);
|
|| mTrackballDown || mGotCenterDown, false);
|
||||||
drawCoreAndCursorRing(canvas, mBackgroundColor, mDrawCursorRing);
|
// use the DKGRAY as background when drawing zoom preview
|
||||||
|
drawCoreAndCursorRing(canvas, mPreviewZoomOnly ? Color.DKGRAY
|
||||||
|
: mBackgroundColor, mDrawCursorRing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2820,6 +2824,12 @@ public class WebView extends AbsoluteLayout
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int saveCount = canvas.save();
|
int saveCount = canvas.save();
|
||||||
|
if (mPreviewZoomOnly) {
|
||||||
|
// scale after canvas.save() so that the child, like titlebar, will
|
||||||
|
// not be scaled.
|
||||||
|
canvas.scale(mPreviewExtraZoomScale, mPreviewExtraZoomScale,
|
||||||
|
mZoomCenterX + mScrollX, mZoomCenterY + mScrollY);
|
||||||
|
}
|
||||||
if (mTitleBar != null) {
|
if (mTitleBar != null) {
|
||||||
canvas.translate(0, (int) mTitleBar.getHeight());
|
canvas.translate(0, (int) mTitleBar.getHeight());
|
||||||
}
|
}
|
||||||
@@ -2828,8 +2838,8 @@ public class WebView extends AbsoluteLayout
|
|||||||
}
|
}
|
||||||
canvas.restoreToCount(saveCount);
|
canvas.restoreToCount(saveCount);
|
||||||
|
|
||||||
// Now draw the shadow.
|
// Now draw the shadow, skip if it is in zoom preview mode.
|
||||||
if (mTitleBar != null) {
|
if ((mTitleBar != null && !mPreviewZoomOnly)) {
|
||||||
int y = mScrollY + getVisibleTitleHeight();
|
int y = mScrollY + getVisibleTitleHeight();
|
||||||
int height = (int) (5f * getContext().getResources()
|
int height = (int) (5f * getContext().getResources()
|
||||||
.getDisplayMetrics().density);
|
.getDisplayMetrics().density);
|
||||||
@@ -3734,6 +3744,8 @@ public class WebView extends AbsoluteLayout
|
|||||||
private class ScaleDetectorListener implements
|
private class ScaleDetectorListener implements
|
||||||
ScaleGestureDetector.OnScaleGestureListener {
|
ScaleGestureDetector.OnScaleGestureListener {
|
||||||
|
|
||||||
|
float mStartX, mStartY;
|
||||||
|
|
||||||
public boolean onScaleBegin(ScaleGestureDetector detector) {
|
public boolean onScaleBegin(ScaleGestureDetector detector) {
|
||||||
// cancel the single touch handling
|
// cancel the single touch handling
|
||||||
cancelTouch();
|
cancelTouch();
|
||||||
@@ -3747,6 +3759,9 @@ public class WebView extends AbsoluteLayout
|
|||||||
if (inEditingMode() && nativeFocusCandidateIsPassword()) {
|
if (inEditingMode() && nativeFocusCandidateIsPassword()) {
|
||||||
mWebTextView.setInPassword(false);
|
mWebTextView.setInPassword(false);
|
||||||
}
|
}
|
||||||
|
mPreviewExtraZoomScale = 1.0f;
|
||||||
|
mStartX = detector.getFocusX();
|
||||||
|
mStartY = detector.getFocusY();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3755,13 +3770,12 @@ public class WebView extends AbsoluteLayout
|
|||||||
mPreviewZoomOnly = false;
|
mPreviewZoomOnly = false;
|
||||||
mAnchorX = viewToContentX((int) mZoomCenterX + mScrollX);
|
mAnchorX = viewToContentX((int) mZoomCenterX + mScrollX);
|
||||||
mAnchorY = viewToContentY((int) mZoomCenterY + mScrollY);
|
mAnchorY = viewToContentY((int) mZoomCenterY + mScrollY);
|
||||||
|
float scale = mPreviewExtraZoomScale * mActualScale;
|
||||||
// don't reflow when zoom in; when zoom out, do reflow if the
|
// don't reflow when zoom in; when zoom out, do reflow if the
|
||||||
// new scale is almost minimum scale;
|
// new scale is almost minimum scale;
|
||||||
boolean reflowNow = (mActualScale - mMinZoomScale <= 0.01f)
|
boolean reflowNow = (scale - mMinZoomScale <= 0.01f)
|
||||||
|| ((mActualScale <= 0.8 * mTextWrapScale));
|
|| ((scale <= 0.8 * mTextWrapScale));
|
||||||
// force zoom after mPreviewZoomOnly is set to false so that the
|
setNewZoomScale(scale, reflowNow, false);
|
||||||
// new view size will be passed to the WebKit
|
|
||||||
setNewZoomScale(mActualScale, reflowNow, true);
|
|
||||||
// call invalidate() to draw without zoom filter
|
// call invalidate() to draw without zoom filter
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
@@ -3778,19 +3792,34 @@ public class WebView extends AbsoluteLayout
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean onScale(ScaleGestureDetector detector) {
|
public boolean onScale(ScaleGestureDetector detector) {
|
||||||
|
float currScale = mPreviewExtraZoomScale * mActualScale;
|
||||||
float scale = (float) (Math.round(detector.getScaleFactor()
|
float scale = (float) (Math.round(detector.getScaleFactor()
|
||||||
* mActualScale * 100) / 100.0);
|
* currScale * 100) / 100.0);
|
||||||
if (Math.abs(scale - mActualScale) >= PREVIEW_SCALE_INCREMENT) {
|
// limit the scale change per step
|
||||||
|
if (scale > currScale) {
|
||||||
|
scale = Math.min(scale, currScale * 1.25f);
|
||||||
|
} else {
|
||||||
|
// the preview scale can be 80% of mMinZoomScale for feedback
|
||||||
|
scale = Math.max(Math.max(scale, currScale * 0.8f),
|
||||||
|
mMinZoomScale * 0.8f);
|
||||||
|
}
|
||||||
|
if (Math.abs(scale - currScale) >= PREVIEW_SCALE_INCREMENT) {
|
||||||
mPreviewZoomOnly = true;
|
mPreviewZoomOnly = true;
|
||||||
// limit the scale change per step
|
// FIXME: mZoomCenterX/Y need to be relative to mActualScale.
|
||||||
if (scale > mActualScale) {
|
// Ideally the focusX/Y should be a fixed point. But currently
|
||||||
scale = Math.min(scale, mActualScale * 1.25f);
|
// it just returns the center of the two pointers. If only one
|
||||||
|
// pointer is moving, the center is shifting. Currently we only
|
||||||
|
// adjust it for zoom in case to get better result.
|
||||||
|
if (mPreviewExtraZoomScale > 1.0f) {
|
||||||
|
mZoomCenterX = mStartX - (mStartX - detector.getFocusX())
|
||||||
|
/ mPreviewExtraZoomScale;
|
||||||
|
mZoomCenterY = mStartY - (mStartY - detector.getFocusY())
|
||||||
|
/ mPreviewExtraZoomScale;
|
||||||
} else {
|
} else {
|
||||||
scale = Math.max(scale, mActualScale * 0.8f);
|
mZoomCenterX = detector.getFocusX();
|
||||||
|
mZoomCenterY = detector.getFocusY();
|
||||||
}
|
}
|
||||||
mZoomCenterX = detector.getFocusX();
|
mPreviewExtraZoomScale = scale / mActualScale;
|
||||||
mZoomCenterY = detector.getFocusY();
|
|
||||||
setNewZoomScale(scale, false, false);
|
|
||||||
invalidate();
|
invalidate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -3971,8 +4000,7 @@ public class WebView extends AbsoluteLayout
|
|||||||
|
|
||||||
// FIXME: we may consider to give WebKit an option to handle multi-touch
|
// FIXME: we may consider to give WebKit an option to handle multi-touch
|
||||||
// events later.
|
// events later.
|
||||||
if (mSupportMultiTouch && mMinZoomScale < mMaxZoomScale
|
if (mSupportMultiTouch && ev.getPointerCount() > 1) {
|
||||||
&& ev.getPointerCount() > 1) {
|
|
||||||
mScaleDetector.onTouchEvent(ev);
|
mScaleDetector.onTouchEvent(ev);
|
||||||
if (mScaleDetector.isInProgress()) {
|
if (mScaleDetector.isInProgress()) {
|
||||||
mLastTouchTime = eventTime;
|
mLastTouchTime = eventTime;
|
||||||
|
|||||||
Reference in New Issue
Block a user