From eaa18dec91b6dd0ce3191a9ab65cdc95ef68b935 Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Mon, 28 Sep 2009 12:50:42 -0400 Subject: scroll text field with touch Add a hidden public method to text/method/Touch.java that computes the maximum scroll amount for a text field. Remove 'faketouch' code; it causes a crash and is no longer required. Pass the percentage of the current scroll from the UI thread to webkit. One additional fix is to allow very small movements which are currently disallowed because they are smaller than 'smallerSlop' in WebTextView.java. Companion fix is in external/webkit. Fixes http://b/issue?id=2133049 --- core/java/android/webkit/WebTextView.java | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'core/java/android/webkit/WebTextView.java') diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java index 65ce158e11e6..f479124fbcbe 100644 --- a/core/java/android/webkit/WebTextView.java +++ b/core/java/android/webkit/WebTextView.java @@ -275,25 +275,6 @@ import java.util.ArrayList; return false; } - /** - * Create a fake touch up event at (x,y) with respect to this WebTextView. - * This is used by WebView to act as though a touch event which happened - * before we placed the WebTextView actually hit it, so that it can place - * the cursor accordingly. - */ - /* package */ void fakeTouchEvent(float x, float y) { - // We need to ensure that there is a Layout, since the Layout is used - // in determining where to place the cursor. - if (getLayout() == null) { - measure(mWidthSpec, mHeightSpec); - } - // Create a fake touch up, which is used to place the cursor. - MotionEvent ev = MotionEvent.obtain(0, 0, MotionEvent.ACTION_UP, - x, y, 0); - onTouchEvent(ev); - ev.recycle(); - } - /** * Determine whether this WebTextView currently represents the node * represented by ptr. @@ -457,7 +438,14 @@ import java.util.ArrayList; int smallerSlop = slop/2; if (dx > smallerSlop || dy > smallerSlop) { if (mWebView != null) { - mWebView.scrollFocusedTextInput(mScrollX, mScrollY); + 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); } mScrolled = true; return true; -- cgit v1.2.3