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

Commit 718d69f9 authored by Derek Sollenberger's avatar Derek Sollenberger
Browse files

changing how plugins gain/lose focus.

Previously we were keeping our own state in the UI thread to
determine when to send events to the plugin. This change removes
that logic and uses the document focus to determine when events
are to be sent. This also fixes problems with the plugins
occasionally not receiving lose focus events.

see bug http://b/2033843
parent 09e383c9
Loading
Loading
Loading
Loading
+4 −24
Original line number Diff line number Diff line
@@ -3355,10 +3355,7 @@ public class WebView extends AbsoluteLayout
            }
        }

        if (nativeFocusCandidateIsPlugin()) {
            nativeUpdatePluginReceivesEvents();
            invalidate();
        } else if (nativeCursorIsTextInput()) {
        if (nativeCursorIsTextInput()) {
            // This message will put the node in focus, for the DOM's notion
            // of focus, and make the focuscontroller active
            mWebViewCore.sendMessage(EventHub.CLICK, nativeCursorFramePointer(),
@@ -3457,7 +3454,6 @@ public class WebView extends AbsoluteLayout
            if (!nativeCursorIntersects(visibleRect)) {
                return false;
            }
            nativeUpdatePluginReceivesEvents();
            WebViewCore.CursorData data = cursorData();
            mWebViewCore.sendMessage(EventHub.SET_MOVE_MOUSE, data);
            playSoundEffect(SoundEffectConstants.CLICK);
@@ -4793,19 +4789,6 @@ public class WebView extends AbsoluteLayout
        mCallbackProxy.uiOverrideUrlLoading(url);
    }

    // called by JNI
    private void sendPluginState(int state) {
        WebViewCore.PluginStateData psd = new WebViewCore.PluginStateData();
        psd.mFrame = nativeFocusCandidateFramePointer();
        psd.mNode = nativeFocusCandidatePointer();
        if (DebugFlags.WEB_VIEW) {
            Log.v(LOGTAG, "sendPluginState frame=" + psd.mFrame
                    + " node=" + psd.mNode);
        }
        psd.mState = state;
        mWebViewCore.sendMessage(EventHub.PLUGIN_STATE, psd);
    }

    @Override
    public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
        boolean result = false;
@@ -5201,9 +5184,7 @@ public class WebView extends AbsoluteLayout
                    }
                    break;
                case MOVE_OUT_OF_PLUGIN:
                    if (nativePluginEatsNavKey()) {
                    navHandledKey(msg.arg1, 1, false, 0, true);
                    }
                    break;
                case UPDATE_TEXT_ENTRY_MSG_ID:
                    // this is sent after finishing resize in WebViewCore. Make
@@ -5697,7 +5678,7 @@ public class WebView extends AbsoluteLayout
        if (mNativeClass == 0) {
            return false;
        }
        if (ignorePlugin == false && nativePluginEatsNavKey()) {
        if (ignorePlugin == false && nativeFocusIsPlugin()) {
            KeyEvent event = new KeyEvent(time, time, KeyEvent.ACTION_DOWN
                , keyCode, count, (mShiftIsPressed ? KeyEvent.META_SHIFT_ON : 0)
                | (false ? KeyEvent.META_ALT_ON : 0) // FIXME
@@ -5831,6 +5812,7 @@ public class WebView extends AbsoluteLayout
    /* package */ native int nativeFocusCandidatePointer();
    private native String   nativeFocusCandidateText();
    private native int      nativeFocusCandidateTextSize();
    private native boolean  nativeFocusIsPlugin();
    /* package */ native int nativeFocusNodePointer();
    private native Rect     nativeGetCursorRingBounds();
    private native Region   nativeGetSelection();
@@ -5848,7 +5830,6 @@ public class WebView extends AbsoluteLayout
    private native int      nativeMoveGeneration();
    private native void     nativeMoveSelection(int x, int y,
            boolean extendSelection);
    private native boolean  nativePluginEatsNavKey();
    // Like many other of our native methods, you must make sure that
    // mNativeClass is not null before calling this method.
    private native void     nativeRecordButtons(boolean focused,
@@ -5870,7 +5851,6 @@ public class WebView extends AbsoluteLayout
    // we always want to pass in our generation number.
    private native void     nativeUpdateCachedTextfield(String updatedText,
            int generation);
    private native void     nativeUpdatePluginReceivesEvents();
    // return NO_LEFTEDGE means failure.
    private static final int NO_LEFTEDGE = -1;
    private native int      nativeGetBlockLeftEdge(int x, int y, float scale);
+1 −15
Original line number Diff line number Diff line
@@ -560,8 +560,6 @@ final class WebViewCore {
     */
    private native void nativeSetNewStorageLimit(long limit);

    private native void nativeUpdatePluginState(int framePtr, int nodePtr, int state);

    /**
     * Provide WebCore with a Geolocation permission state for the specified
     * origin.
@@ -716,12 +714,6 @@ final class WebViewCore {
        int mY;
    }

    static class PluginStateData {
        int mFrame;
        int mNode;
        int mState;
    }

    static class GeolocationPermissionsData {
        String mOrigin;
        boolean mAllow;
@@ -758,7 +750,7 @@ final class WebViewCore {
            "SINGLE_LISTBOX_CHOICE", // = 124;
            "MESSAGE_RELAY", // = 125;
            "SET_BACKGROUND_COLOR", // = 126;
            "PLUGIN_STATE", // = 127;
            "127", // = 127
            "SAVE_DOCUMENT_STATE", // = 128;
            "GET_SELECTION", // = 129;
            "WEBKIT_DRAW", // = 130;
@@ -809,7 +801,6 @@ final class WebViewCore {
        static final int SINGLE_LISTBOX_CHOICE = 124;
        static final int MESSAGE_RELAY = 125;
        static final int SET_BACKGROUND_COLOR = 126;
        static final int PLUGIN_STATE = 127; // plugin notifications
        static final int SAVE_DOCUMENT_STATE = 128;
        static final int GET_SELECTION = 129;
        static final int WEBKIT_DRAW = 130;
@@ -1069,11 +1060,6 @@ final class WebViewCore {
                            nativeFreeMemory();
                            break;

                        case PLUGIN_STATE:
                            PluginStateData psd = (PluginStateData) msg.obj;
                            nativeUpdatePluginState(psd.mFrame, psd.mNode, psd.mState);
                            break;

                        case SET_NETWORK_STATE:
                            if (BrowserFrame.sJavaBridge == null) {
                                throw new IllegalStateException("No WebView " +