Bug 1058136 - Refactor GeckoEditable; r=cpeterson
☠☠ backed out by 7991f98b920b ☠ ☠
authorJim Chen <nchen@mozilla.com>
Fri, 29 Aug 2014 14:56:41 -0400
changeset 224130 d9f97b62e3c4c97a069b97e6fa388444c6391778
parent 224129 fc9f83afab316d2463d4bd993f0e922c54f2788b
child 224131 37addbdb5cd1fec8cbf9c0ed453f489d02fb7423
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpeterson
bugs1058136
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1058136 - Refactor GeckoEditable; r=cpeterson
mobile/android/base/GeckoEditable.java
--- a/mobile/android/base/GeckoEditable.java
+++ b/mobile/android/base/GeckoEditable.java
@@ -224,36 +224,43 @@ final class GeckoEditable
             if (mActions.isEmpty()) {
                 mActionsActive.acquireUninterruptibly();
                 mActions.offer(action);
             } else synchronized(this) {
                 // tryAcquire here in case Gecko thread has just released it
                 mActionsActive.tryAcquire();
                 mActions.offer(action);
             }
+
             switch (action.mType) {
             case Action.TYPE_EVENT:
             case Action.TYPE_SET_SELECTION:
             case Action.TYPE_SET_SPAN:
             case Action.TYPE_REMOVE_SPAN:
             case Action.TYPE_SET_HANDLER:
                 GeckoAppShell.sendEventToGecko(GeckoEvent.createIMEEvent(
                         GeckoEvent.ImeAction.IME_SYNCHRONIZE));
                 break;
+
             case Action.TYPE_REPLACE_TEXT:
                 // try key events first
                 sendCharKeyEvents(action);
                 GeckoAppShell.sendEventToGecko(GeckoEvent.createIMEReplaceEvent(
                         action.mStart, action.mEnd, action.mSequence.toString()));
                 break;
+
             case Action.TYPE_ACKNOWLEDGE_FOCUS:
                 GeckoAppShell.sendEventToGecko(GeckoEvent.createIMEEvent(
                         GeckoEvent.ImeAction.IME_ACKNOWLEDGE_FOCUS));
                 break;
+
+            default:
+                throw new IllegalStateException("Action not processed");
             }
+
             ++mIcUpdateSeqno;
         }
 
         private KeyEvent [] synthesizeKeyEvents(CharSequence cs) {
             try {
                 if (mKeyMap == null) {
                     mKeyMap = KeyCharacterMap.load(
                         Versions.preHC ? KeyCharacterMap.ALPHA :
@@ -302,22 +309,20 @@ final class GeckoEditable
         void poll() {
             if (DEBUG) {
                 ThreadUtils.assertOnGeckoThread();
             }
             if (mActions.isEmpty()) {
                 throw new IllegalStateException("empty actions queue");
             }
             mActions.poll();
-            // Don't bother locking if queue is not empty yet
-            if (mActions.isEmpty()) {
-                synchronized(this) {
-                    if (mActions.isEmpty()) {
-                        mActionsActive.release();
-                    }
+
+            synchronized(this) {
+                if (mActions.isEmpty()) {
+                    mActionsActive.release();
                 }
             }
         }
 
         Action peek() {
             if (DEBUG) {
                 ThreadUtils.assertOnGeckoThread();
             }