diff options
| author | Leon Scroggins <scroggo@google.com> | 2010-10-15 13:58:38 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-10-15 13:58:38 -0700 |
| commit | 36cb18cf0684cadb3736969ff96f37d5eb9bb1a4 (patch) | |
| tree | cd2c3a52675d050233b54ef3e3363c196016c22b /core/java/android/webkit/WebTextView.java | |
| parent | f8834f878fb6911cbd4719640cd2e6bf3a958a92 (diff) | |
| parent | 2a30744cd73233646173d05ebdb28f7829ec7a52 (diff) | |
Merge "Line up textfield with WebTextView more often." into gingerbread
Diffstat (limited to 'core/java/android/webkit/WebTextView.java')
| -rw-r--r-- | core/java/android/webkit/WebTextView.java | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java index e82ed9fa34a4..f7afdb96691c 100644 --- a/core/java/android/webkit/WebTextView.java +++ b/core/java/android/webkit/WebTextView.java @@ -288,6 +288,21 @@ import java.util.ArrayList; return ptr == mNodePointer; } + /** + * Ensure that the underlying textfield is lined up with the WebTextView. + */ + private void lineUpScroll() { + if (mWebView != null) { + float maxScrollX = Touch.getMaxScrollX(this, getLayout(), mScrollY); + if (DebugFlags.WEB_TEXT_VIEW) { + Log.v(LOGTAG, "onTouchEvent x=" + mScrollX + " y=" + + mScrollY + " maxX=" + maxScrollX); + } + mWebView.scrollFocusedTextInput(maxScrollX > 0 ? + mScrollX / maxScrollX : 0, mScrollY); + } + } + @Override public InputConnection onCreateInputConnection( EditorInfo outAttrs) { InputConnection connection = super.onCreateInputConnection(outAttrs); @@ -359,6 +374,12 @@ import java.util.ArrayList; } @Override + protected void onScrollChanged(int l, int t, int oldl, int oldt) { + super.onScrollChanged(l, t, oldl, oldt); + lineUpScroll(); + } + + @Override protected void onSelectionChanged(int selStart, int selEnd) { if (mInSetTextAndKeepSelection) return; // This code is copied from TextView.onDraw(). That code does not get @@ -378,6 +399,7 @@ import java.util.ArrayList; + " selEnd=" + selEnd); } mWebView.setSelection(selStart, selEnd); + lineUpScroll(); } } @@ -481,16 +503,7 @@ import java.util.ArrayList; // to big for the case of a small textfield. int smallerSlop = slop/2; if (dx > smallerSlop || dy > smallerSlop) { - if (mWebView != null) { - float maxScrollX = (float) Touch.getMaxScrollX(this, - getLayout(), mScrollY); - if (DebugFlags.WEB_TEXT_VIEW) { - Log.v(LOGTAG, "onTouchEvent x=" + mScrollX + " y=" - + mScrollY + " maxX=" + maxScrollX); - } - mWebView.scrollFocusedTextInput(maxScrollX > 0 ? - mScrollX / maxScrollX : 0, mScrollY); - } + // Scrolling is handled in onScrollChanged. mScrolled = true; cancelLongPress(); return true; |
