diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 50358c219d610..da040324c621a 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -2863,17 +2863,31 @@ public class WebView extends AbsoluteLayout invalidate(); if (mNeedToAdjustWebTextView) { mNeedToAdjustWebTextView = false; - mWebTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, - contentToViewDimension( - nativeFocusCandidateTextSize())); - Rect bounds = nativeFocusCandidateNodeBounds(); - Rect vBox = contentToViewRect(bounds); - mWebTextView.setRect(vBox.left, vBox.top, vBox.width(), - vBox.height()); - // If it is a password field, start drawing the - // WebTextView once again. - if (nativeFocusCandidateIsPassword()) { - mWebTextView.setInPassword(true); + Rect contentBounds = nativeFocusCandidateNodeBounds(); + Rect vBox = contentToViewRect(contentBounds); + Rect visibleRect = new Rect(); + calcOurVisibleRect(visibleRect); + if (visibleRect.contains(vBox)) { + // As a result of the zoom, the textfield is now on + // screen. Place the WebTextView in its new place, + // accounting for our new scroll/zoom values. + mWebTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, + contentToViewDimension( + nativeFocusCandidateTextSize())); + mWebTextView.setRect(vBox.left, vBox.top, vBox.width(), + vBox.height()); + // If it is a password field, start drawing the + // WebTextView once again. + if (nativeFocusCandidateIsPassword()) { + mWebTextView.setInPassword(true); + } + } else { + // The textfield is now off screen. The user probably + // was not zooming to see the textfield better. Remove + // the WebTextView. If the user types a key, and the + // textfield is still in focus, we will reconstruct + // the WebTextView and scroll it back on screen. + mWebTextView.remove(); } } }