Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d3997e55 authored by Leon Scroggins's avatar Leon Scroggins
Browse files

Make scrolling textfields work better in the browser.

The touch slop seems to be too large for scrolling
a small textfield, so use a smaller number.  Also,
in WebView, create viewToContentDimension, and use
it for determining the scroll position of the text
field.

Partial fix for http://b/issue?id=2133049

Change-Id: I0ded3be264b179bad39301e6adce86851b649a42
parent 163be61c
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -448,8 +448,13 @@ import java.util.ArrayList;
            int initialScrollX = Touch.getInitialScrollX(this, buffer);
            int initialScrollY = Touch.getInitialScrollY(this, buffer);
            super.onTouchEvent(event);
            if (Math.abs(mScrollX - initialScrollX) > slop
                    || Math.abs(mScrollY - initialScrollY) > slop) {
            int dx = Math.abs(mScrollX - initialScrollX);
            int dy = Math.abs(mScrollY - initialScrollY);
            // Use a smaller slop when checking to see if we've moved far enough
            // to scroll the text, because experimentally, slop has shown to be
            // to big for the case of a small textfield.
            int smallerSlop = slop/2;
            if (dx > smallerSlop || dy > smallerSlop) {
                if (mWebView != null) {
                    mWebView.scrollFocusedTextInput(mScrollX, mScrollY);
                }
+17 −4
Original line number Diff line number Diff line
@@ -1781,13 +1781,23 @@ public class WebView extends AbsoluteLayout
        mTitleBar = v;
    }

    /**
     * Given a distance in view space, convert it to content space. Note: this
     * does not reflect translation, just scaling, so this should not be called
     * with coordinates, but should be called for dimensions like width or
     * height.
     */
    private int viewToContentDimension(int d) {
        return Math.round(d * mInvActualScale);
    }

    /**
     * Given an x coordinate in view space, convert it to content space.  Also
     * may be used for absolute heights (such as for the WebTextView's
     * textSize, which is unaffected by the height of the title bar).
     */
    /*package*/ int viewToContentX(int x) {
        return Math.round(x * mInvActualScale);
        return viewToContentDimension(x);
    }

    /**
@@ -1796,7 +1806,7 @@ public class WebView extends AbsoluteLayout
     * embedded into the WebView.
     */
    /*package*/ int viewToContentY(int y) {
        return viewToContentX(y - getTitleHeight());
        return viewToContentDimension(y - getTitleHeight());
    }

    /**
@@ -1811,7 +1821,7 @@ public class WebView extends AbsoluteLayout

    /**
     * Given an x coordinate in content space, convert it to view
     * space.  Also used for absolute heights.
     * space.
     */
    /*package*/ int contentToViewX(int x) {
        return contentToViewDimension(x);
@@ -4445,7 +4455,10 @@ public class WebView extends AbsoluteLayout
            return;
        }
        mWebViewCore.sendMessage(EventHub.SCROLL_TEXT_INPUT, viewToContentX(x),
                viewToContentY(y));
                // Since this position is relative to the top of the text input
                // field, we do not need to take the title bar's height into
                // consideration.
                viewToContentDimension(y));
    }

    /**