diff options
| author | 2011-01-19 12:49:57 -0500 | |
|---|---|---|
| committer | 2011-01-19 13:18:59 -0500 | |
| commit | 3be1ffab08728ed0f36677e4499d70fbd591f999 (patch) | |
| tree | 28e410d25055a0b7fd9ec467df99c46446ca104c | |
| parent | 4061c9aa6d77bd7ad3b43d898b3e55fd62f57f18 (diff) | |
Only scroll on screen when necessary.
Bug:3367446
bringPointIntoView was called by TextView in onPreDraw. This was
passing a message to the webcore thread to change the scroll
position. This is unnecessary, because typically the scroll
position will be changed by webkit when keys are pressed. The
one situation where this helped was when the user taps on a
textfield, which brings up the IME, which may cover it. A better
solution is to tell webkit to scroll it on screen once the
screen size changes. I have a CL in external/webkit to do that:
https://android-git.corp.google.com/g/#change,91095
Change-Id: I6e06ad59e1a1c99365bb5be635a43d1b88658c0d
| -rw-r--r-- | core/java/android/webkit/WebTextView.java | 15 | ||||
| -rw-r--r-- | core/java/android/webkit/WebView.java | 3 |
2 files changed, 4 insertions, 14 deletions
diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java index bd5ec7944473..72b0023a2432 100644 --- a/core/java/android/webkit/WebTextView.java +++ b/core/java/android/webkit/WebTextView.java @@ -135,6 +135,7 @@ import junit.framework.Assert; // Used to determine whether onFocusChanged was called as a result of // calling remove(). private boolean mInsideRemove; + private boolean mInPassword; // Types used with setType. Keep in sync with CachedInput.h private static final int NORMAL_TEXT_FIELD = 0; @@ -784,22 +785,11 @@ import junit.framework.Assert; mInsideRemove = false; } - /** - * Move the caret/selection into view. - */ - /* package */ void bringIntoView() { - bringPointIntoView(Selection.getSelectionEnd(getText())); - } - @Override public boolean bringPointIntoView(int offset) { - if (mWebView == null) return false; - if (mWebView.nativeFocusCandidateIsPassword()) { + if (mInPassword) { return getLayout() != null && super.bringPointIntoView(offset); } - // For non password text input, tell webkit to move the caret/selection - // on screen, since webkit draws them. - mWebView.revealSelection(); return true; } @@ -914,6 +904,7 @@ import junit.framework.Assert; * @param inPassword True if the textfield is a password field. */ /* package */ void setInPassword(boolean inPassword) { + mInPassword = inPassword; if (inPassword) { setInputType(EditorInfo.TYPE_CLASS_TEXT | EditorInfo. TYPE_TEXT_VARIATION_WEB_PASSWORD); diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index ebf33050471f..9e09c286f1d0 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -4268,7 +4268,7 @@ public class WebView extends AbsoluteLayout Rect vBox = contentToViewRect(bounds); mWebTextView.setRect(vBox.left, vBox.top, vBox.width(), vBox.height()); if (!Rect.intersects(bounds, visibleRect)) { - mWebTextView.bringIntoView(); + revealSelection(); } String text = nativeFocusCandidateText(); int nodePointer = nativeFocusCandidatePointer(); @@ -7274,7 +7274,6 @@ public class WebView extends AbsoluteLayout // this is sent after finishing resize in WebViewCore. Make // sure the text edit box is still on the screen. if (inEditingMode() && nativeCursorIsTextInput()) { - mWebTextView.bringIntoView(); rebuildWebTextView(); } break; |