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

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

Make a long press on a textfield work.

Bug:3268584

Even if the WebTextView has not been set up yet.

Change-Id: I8ec2c4ef8146006d6ee84d08e1ddbdb099125047
parent 96e6b8bf
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -353,6 +353,18 @@ import junit.framework.Assert;
        return false;
    }

    void ensureLayout() {
        if (getLayout() == null) {
            // Ensure we have a Layout
            measure(mWidthSpec, mHeightSpec);
            LayoutParams params = (LayoutParams) getLayoutParams();
            if (params != null) {
                layout(params.x, params.y, params.x + params.width,
                        params.y + params.height);
            }
        }
    }

    /**
     *  Determine whether this WebTextView currently represents the node
     *  represented by ptr.
+12 −0
Original line number Diff line number Diff line
@@ -3750,6 +3750,18 @@ public class WebView extends AbsoluteLayout
            clearTextEntry();
        }
        if (inEditingMode()) {
            // Since we just called rebuildWebTextView, the layout is not set
            // properly.  Update it so it can correctly find the word to select.
            mWebTextView.ensureLayout();
            // Provide a touch down event to WebTextView, which will allow it
            // to store the location to use in performLongClick.
            AbsoluteLayout.LayoutParams params
                    = (AbsoluteLayout.LayoutParams) mWebTextView.getLayoutParams();
            MotionEvent fake = MotionEvent.obtain(mLastTouchTime,
                    mLastTouchTime, MotionEvent.ACTION_DOWN,
                    mLastTouchX - params.x + mScrollX,
                    mLastTouchY - params.y + mScrollY, 0);
            mWebTextView.dispatchTouchEvent(fake);
            return mWebTextView.performLongClick();
        }
        if (mSelectingText) return false; // long click does nothing on selection