diff options
| author | Leon Scroggins <scroggo@google.com> | 2011-01-19 17:01:55 -0500 |
|---|---|---|
| committer | Leon Scroggins <scroggo@google.com> | 2011-01-21 15:42:03 -0500 |
| commit | d5188657dcde0f40a6954a00d569c0575bf6095a (patch) | |
| tree | a9212df979cf5b5a8d4ed7d676a15bfc6fc113ca /core/java/android/webkit/WebTextView.java | |
| parent | 276677f2ac821e5eb8a7f6a4204242ee47501d6e (diff) | |
Do a better job of lining up text with page text.
Bug:3085564
Bug:3196224
Bug:3321608
Remove Touch.getMaxScrollX(), which is incorrect for my
purpose, and is not used anywhere else. Instead use the
layout to determine the maximum horizontal scroll of a
textfield.
Now that textareas use layers, scroll the layer's picture
in the UI thread for vertical movement. When passing a
click to webcore, also pass a message to scroll the actual
textarea so the click will be in the correct place.
Lastly, do not override bringPointIntoView, which allows
moving the insertion handler beyond the edge of a field to
scroll it. Instead, override requestRectangleOnScreen to
do nothing, since my actual goal is to prevent the TextView
from changing the scroll of the WebView, which is done by
webkit.
Requires a change to external/webkit.
Change-Id: Ib91907599b792287c373d3678cb04e0cb5e34471
Diffstat (limited to 'core/java/android/webkit/WebTextView.java')
| -rw-r--r-- | core/java/android/webkit/WebTextView.java | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java index 72b0023a2432..59a239ab9563 100644 --- a/core/java/android/webkit/WebTextView.java +++ b/core/java/android/webkit/WebTextView.java @@ -135,7 +135,6 @@ 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; @@ -374,18 +373,24 @@ import junit.framework.Assert; } /** - * Ensure that the underlying textfield is lined up with the WebTextView. + * Ensure that the underlying text field/area is lined up with the WebTextView. */ private void lineUpScroll() { Layout layout = getLayout(); if (mWebView != null && layout != null) { - float maxScrollX = Touch.getMaxScrollX(this, layout, mScrollY); - if (DebugFlags.WEB_TEXT_VIEW) { - Log.v(LOGTAG, "onTouchEvent x=" + mScrollX + " y=" - + mScrollY + " maxX=" + maxScrollX); + if (mSingle) { + // textfields only need to be lined up horizontally. + float maxScrollX = layout.getLineRight(0) - getWidth(); + if (DebugFlags.WEB_TEXT_VIEW) { + Log.v(LOGTAG, "onTouchEvent x=" + mScrollX + " y=" + + mScrollY + " maxX=" + maxScrollX); + } + mWebView.scrollFocusedTextInputX(maxScrollX > 0 ? + mScrollX / maxScrollX : 0); + } else { + // textareas only need to be lined up vertically. + mWebView.scrollFocusedTextInputY(mScrollY); } - mWebView.scrollFocusedTextInput(maxScrollX > 0 ? - mScrollX / maxScrollX : 0, mScrollY); } } @@ -414,6 +419,7 @@ import junit.framework.Assert; mLayout.getSpacingAdd(), false, null, ellipsisWidth, lineHeight); } + lineUpScroll(); } /** @@ -786,10 +792,8 @@ import junit.framework.Assert; } @Override - public boolean bringPointIntoView(int offset) { - if (mInPassword) { - return getLayout() != null && super.bringPointIntoView(offset); - } + public boolean requestRectangleOnScreen(Rect rectangle, boolean immediate) { + // Do nothing, since webkit will put the textfield on screen. return true; } @@ -904,7 +908,6 @@ 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); |
