Bug 1446729 - 3. Move GeckoEditable/InputConnection to o.m.geckoview; r?esawin draft
authorJim Chen <nchen@mozilla.com>
Sun, 18 Mar 2018 05:38:55 -0400
changeset 769093 787378a76bafe68cf23b83d5c752943ffb8ef9c0
parent 769092 605375eea828da85adbeeeeb625b17d41fb75c70
child 769094 cf93ef8c324e3831acf3af427a88226c4a358d98
push id103035
push userbmo:nchen@mozilla.com
push dateSun, 18 Mar 2018 09:44:48 +0000
reviewersesawin
bugs1446729
milestone61.0a1
Bug 1446729 - 3. Move GeckoEditable/InputConnection to o.m.geckoview; r?esawin Moving GeckoEditable and GeckoInputConnection to o.m.geckoview lets us make the interfaces inside SessionTextInput package-private, so they don't show up in the docs. MozReview-Commit-ID: 1C8olyqj4sX
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoEditable.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoEditableChild.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoInputConnection.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoEditable.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoInputConnection.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/SessionTextInput.java
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testANRReporter.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoEditableChild.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoEditableChild.java
@@ -3,17 +3,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
 import org.mozilla.gecko.annotation.WrapForJNI;
 import org.mozilla.gecko.mozglue.JNIObject;
 import org.mozilla.gecko.util.ThreadUtils;
-import org.mozilla.geckoview.SessionTextInput;
 
 import android.graphics.RectF;
 import android.os.IBinder;
 import android.os.RemoteException;
 import android.util.Log;
 import android.view.KeyEvent;
 
 /**
@@ -22,16 +21,18 @@ import android.view.KeyEvent;
  * process has an instance of GeckoEditableChild, which communicates with the
  * GeckoEditableParent instance in the main process.
  */
 public final class GeckoEditableChild extends JNIObject implements IGeckoEditableChild {
 
     private static final boolean DEBUG = false;
     private static final String LOGTAG = "GeckoEditableChild";
 
+    private static final int NOTIFY_IME_TO_CANCEL_COMPOSITION = 9;
+
     private final class RemoteChild extends IGeckoEditableChild.Stub {
         @Override // IGeckoEditableChild
         public void onKeyEvent(int action, int keyCode, int scanCode, int metaState,
                                int keyPressMetaState, long time, int domPrintableKeyValue,
                                int repeatCount, int flags, boolean isSynthesizedImeKey,
                                KeyEvent event) {
             GeckoEditableChild.this.onKeyEvent(
                     action, keyCode, scanCode, metaState, keyPressMetaState, time,
@@ -127,21 +128,19 @@ public final class GeckoEditableChild ex
         // Return the GeckoEditableParent's binder as our binder for comparison purposes.
         return mEditableParent.asBinder();
     }
 
     @WrapForJNI(calledFrom = "gecko")
     private void notifyIME(final int type) {
         if (DEBUG) {
             ThreadUtils.assertOnGeckoThread();
-            Log.d(LOGTAG, "notifyIME(" + GeckoEditable.getConstantName(
-                          SessionTextInput.EditableListener.class,
-                          "NOTIFY_IME_", type) + ")");
+            Log.d(LOGTAG, "notifyIME(" + type + ")");
         }
-        if (type == SessionTextInput.EditableListener.NOTIFY_IME_TO_CANCEL_COMPOSITION) {
+        if (type == NOTIFY_IME_TO_CANCEL_COMPOSITION) {
             // Composition should have been canceled on the parent side through text
             // update notifications. We cannot verify that here because we don't
             // keep track of spans on the child side, but it's simple to add the
             // check to the parent side if ever needed.
             return;
         }
 
         try {
@@ -153,19 +152,17 @@ public final class GeckoEditableChild ex
     }
 
     @WrapForJNI(calledFrom = "gecko")
     private void notifyIMEContext(final int state, final String typeHint,
                                   final String modeHint, final String actionHint,
                                   final int flags) {
         if (DEBUG) {
             ThreadUtils.assertOnGeckoThread();
-            Log.d(LOGTAG, "notifyIMEContext(" + GeckoEditable.getConstantName(
-                          SessionTextInput.EditableListener.class,
-                          "IME_STATE_", state) + ", \"" +
+            Log.d(LOGTAG, "notifyIMEContext(" + state + ", \"" +
                           typeHint + "\", \"" + modeHint + "\", \"" + actionHint +
                           "\", 0x" + Integer.toHexString(flags) + ")");
         }
 
         try {
             mEditableParent.notifyIMEContext(state, typeHint, modeHint, actionHint, flags);
         } catch (final RemoteException e) {
             Log.e(LOGTAG, "Remote call failed", e);
@@ -190,22 +187,18 @@ public final class GeckoEditableChild ex
     }
 
     @WrapForJNI(calledFrom = "gecko", exceptionMode = "ignore")
     private void onTextChange(final CharSequence text, final int start,
                               final int unboundedOldEnd, final int unboundedNewEnd)
             throws RemoteException {
         if (DEBUG) {
             ThreadUtils.assertOnGeckoThread();
-            StringBuilder sb = new StringBuilder("onTextChange(");
-            GeckoEditable.debugAppend(sb, text);
-            sb.append(", ").append(start).append(", ")
-                .append(unboundedOldEnd).append(", ")
-                .append(unboundedNewEnd).append(")");
-            Log.d(LOGTAG, sb.toString());
+            Log.d(LOGTAG, "onTextChange(" + text + ", " + start + ", " +
+                          unboundedOldEnd + ", " + unboundedNewEnd + ")");
         }
 
         if (start < 0 || start > unboundedOldEnd) {
             Log.e(LOGTAG, "invalid text notification range: " +
                   start + " to " + unboundedOldEnd);
             throw new IllegalArgumentException("invalid text notification range");
         }
 
rename from mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoEditable.java
rename to mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoEditable.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoEditable.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoEditable.java
@@ -1,36 +1,35 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-package org.mozilla.gecko;
+package org.mozilla.geckoview;
 
 import java.lang.reflect.Array;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
-import org.mozilla.gecko.annotation.WrapForJNI;
+import org.mozilla.gecko.GeckoEditableChild;
+import org.mozilla.gecko.IGeckoEditableChild;
+import org.mozilla.gecko.IGeckoEditableParent;
 import org.mozilla.gecko.util.ThreadUtils;
 import org.mozilla.gecko.util.ThreadUtils.AssertBehavior;
-import org.mozilla.geckoview.TextInputController;
 
 import android.graphics.RectF;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Looper;
 import android.os.RemoteException;
 import android.text.Editable;
 import android.text.InputFilter;
-import android.text.NoCopySpan;
 import android.text.Selection;
 import android.text.Spannable;
 import android.text.SpannableString;
 import android.text.SpannableStringBuilder;
 import android.text.Spanned;
 import android.text.TextPaint;
 import android.text.TextUtils;
 import android.text.style.CharacterStyle;
@@ -38,17 +37,17 @@ import android.util.Log;
 import android.view.KeyCharacterMap;
 import android.view.KeyEvent;
 
 /**
  * GeckoEditable implements only some functions of Editable
  * The field mText contains the actual underlying
  * SpannableStringBuilder/Editable that contains our text.
  */
-public final class GeckoEditable
+/* package */ final class GeckoEditable
     extends IGeckoEditableParent.Stub
     implements InvocationHandler,
                Editable,
                SessionTextInput.EditableClient {
 
     private static final boolean DEBUG = false;
     private static final String LOGTAG = "GeckoEditable";
 
rename from mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoInputConnection.java
rename to mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoInputConnection.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoInputConnection.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoInputConnection.java
@@ -1,24 +1,20 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-package org.mozilla.gecko;
+package org.mozilla.geckoview;
 
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-
+import org.mozilla.gecko.Clipboard;
+import org.mozilla.gecko.InputMethods;
 import org.mozilla.gecko.util.ActivityUtils;
 import org.mozilla.gecko.util.GamepadUtils;
 import org.mozilla.gecko.util.ThreadUtils;
-import org.mozilla.geckoview.GeckoSession;
-import org.mozilla.geckoview.SessionTextInput;
 
 import android.annotation.SuppressLint;
 import android.annotation.TargetApi;
 import android.app.Activity;
 import android.content.Context;
 import android.content.res.Configuration;
 import android.graphics.Matrix;
 import android.graphics.RectF;
@@ -41,17 +37,21 @@ import android.view.View;
 import android.view.inputmethod.BaseInputConnection;
 import android.view.inputmethod.CursorAnchorInfo;
 import android.view.inputmethod.EditorInfo;
 import android.view.inputmethod.ExtractedText;
 import android.view.inputmethod.ExtractedTextRequest;
 import android.view.inputmethod.InputConnection;
 import android.view.inputmethod.InputMethodManager;
 
-public class GeckoInputConnection
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+/* package */ final class GeckoInputConnection
     extends BaseInputConnection
     implements SessionTextInput.Delegate,
                SessionTextInput.EditableListener {
 
     private static final boolean DEBUG = false;
     protected static final String LOGTAG = "GeckoInputConnection";
 
     private static final String CUSTOM_HANDLER_TEST_METHOD = "testInputConnection";
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/SessionTextInput.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/SessionTextInput.java
@@ -1,19 +1,17 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.geckoview;
 
 import org.mozilla.gecko.annotation.WrapForJNI;
-import org.mozilla.gecko.GeckoEditable;
 import org.mozilla.gecko.GeckoEditableChild;
-import org.mozilla.gecko.GeckoInputConnection;
 import org.mozilla.gecko.IGeckoEditableParent;
 import org.mozilla.gecko.NativeQueue;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import android.graphics.RectF;
 import android.os.Handler;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
@@ -26,31 +24,31 @@ import android.view.inputmethod.InputCon
 /**
  * SessionTextInput handles text input for GeckoSession through key events or input
  * methods. It is typically used to implement certain methods in View such as {@code
  * onCreateInputConnection()}, by forwarding such calls to corresponding methods in
  * SessionTextInput.
  */
 public final class SessionTextInput {
 
-    // Interface to access GeckoInputConnection from TextInputController.
-    public interface Delegate {
+    // Interface to access GeckoInputConnection from SessionTextInput.
+    /* package */ interface Delegate {
         View getView();
         Handler getHandler(Handler defHandler);
         InputConnection onCreateInputConnection(EditorInfo attrs);
         boolean onKeyPreIme(int keyCode, KeyEvent event);
         boolean onKeyDown(int keyCode, KeyEvent event);
         boolean onKeyUp(int keyCode, KeyEvent event);
         boolean onKeyLongPress(int keyCode, KeyEvent event);
         boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event);
         boolean isInputActive();
     }
 
     // Interface to access GeckoEditable from GeckoInputConnection.
-    public interface EditableClient {
+    /* package */ interface EditableClient {
         // The following value is used by requestCursorUpdates
         // ONE_SHOT calls updateCompositionRects() after getting current composing
         // character rects.
         @WrapForJNI final int ONE_SHOT = 1;
         // START_MONITOR start the monitor for composing character rects.  If is is
         // updaed,  call updateCompositionRects()
         @WrapForJNI final int START_MONITOR = 2;
         // ENDT_MONITOR stops the monitor for composing character rects.
@@ -61,17 +59,17 @@ public final class SessionTextInput {
         void setBatchMode(boolean isBatchMode);
         void setSuppressKeyUp(boolean suppress);
         Handler setInputConnectionHandler(Handler handler);
         void postToInputConnection(Runnable runnable);
         void requestCursorUpdates(int requestMode);
     }
 
     // Interface to access GeckoInputConnection from GeckoEditable.
-    public interface EditableListener {
+    /* package */ interface EditableListener {
         // IME notification type for notifyIME(), corresponding to NotificationToIME enum.
         @WrapForJNI final int NOTIFY_IME_OF_TOKEN = -3;
         @WrapForJNI final int NOTIFY_IME_OPEN_VKB = -2;
         @WrapForJNI final int NOTIFY_IME_REPLY_EVENT = -1;
         @WrapForJNI final int NOTIFY_IME_OF_FOCUS = 1;
         @WrapForJNI final int NOTIFY_IME_OF_BLUR = 2;
         @WrapForJNI final int NOTIFY_IME_TO_COMMIT_COMPOSITION = 8;
         @WrapForJNI final int NOTIFY_IME_TO_CANCEL_COMPOSITION = 9;
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testANRReporter.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testANRReporter.java
@@ -35,19 +35,19 @@ public class testANRReporter extends Old
         + "DALVIK THREADS:\n"
         + "(mutexes: tll=0 tsl=0 tscl=0 ghl=0)\n"
         + "\n"
         + "\"main\" prio=5 tid=1 WAIT\n"
         + "  | group=\"main\" sCount=1 dsCount=0 obj=0x41d6bc90 self=0x41d5a3c8\n"
         + "  | sysTid=3485 nice=0 sched=0/0 cgrp=apps handle=1074852180\n"
         + "  | state=S schedstat=( 0 0 0 ) utm=1065 stm=152 core=0\n"
         + "  at java.lang.Object.wait(Native Method)\n"
-        + "  - waiting on <0x427ab340> (a org.mozilla.gecko.GeckoEditable$5)\n"
+        + "  - waiting on <0x427ab340> (a org.mozilla.geckoview.GeckoEditable$5)\n"
         + "  at java.lang.Object.wait(Object.java:364)\n"
-        + "  at org.mozilla.gecko.GeckoEditable$5.run(GeckoEditable.java:746)\n"
+        + "  at org.mozilla.geckoview.GeckoEditable$5.run(GeckoEditable.java:746)\n"
         + "  at android.os.Handler.handleCallback(Handler.java:733)\n"
         + "  at android.os.Handler.dispatchMessage(Handler.java:95)\n"
         + "  at android.os.Looper.loop(Looper.java:137)\n"
         + "  at android.app.ActivityThread.main(ActivityThread.java:4998)\n"
         + "  at java.lang.reflect.Method.invokeNative(Native Method)\n"
         + "  at java.lang.reflect.Method.invoke(Method.java:515)\n"
         + "  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)\n"
         + "  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)\n"