Bug 1058127 - Properly implement removeSpan synchronization; r=cpeterson
authorJim Chen <nchen@mozilla.com>
Tue, 26 Aug 2014 11:50:19 -0400
changeset 201583 5efbfff98372042e9575ce02312627f458fcad36
parent 201582 2b5bc470740d596527596a57943a1f424c5df5d2
child 201584 c850f3af9f2cfda325fc2bf6c25bf6a854bb8f97
child 201691 55f027c764be0289213e7d4dfd3e2af5aea9c75e
push id27374
push userryanvm@gmail.com
push dateTue, 26 Aug 2014 18:16:27 +0000
treeherdermozilla-central@c850f3af9f2c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpeterson
bugs1058127
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 1058127 - Properly implement removeSpan synchronization; r=cpeterson
mobile/android/base/GeckoEditable.java
--- a/mobile/android/base/GeckoEditable.java
+++ b/mobile/android/base/GeckoEditable.java
@@ -178,16 +178,22 @@ final class GeckoEditable
             final Action action = new Action(TYPE_SET_SPAN);
             action.mSpanObject = object;
             action.mStart = start;
             action.mEnd = end;
             action.mSpanFlags = flags;
             return action;
         }
 
+        static Action newRemoveSpan(Object object) {
+            final Action action = new Action(TYPE_REMOVE_SPAN);
+            action.mSpanObject = object;
+            return action;
+        }
+
         static Action newSetHandler(Handler handler) {
             final Action action = new Action(TYPE_SET_HANDLER);
             action.mHandler = handler;
             return action;
         }
     }
 
     /* Queue of editing actions sent to Gecko thread that
@@ -696,19 +702,25 @@ final class GeckoEditable
                     if (selStart == start && selEnd == end) {
                         // There has not been another new selection in the mean time that
                         // made this notification out-of-date
                         mListener.onSelectionChange(start, end);
                     }
                 }
             });
             break;
+
         case Action.TYPE_SET_SPAN:
             mText.setSpan(action.mSpanObject, action.mStart, action.mEnd, action.mSpanFlags);
             break;
+
+        case Action.TYPE_REMOVE_SPAN:
+            mText.removeSpan(action.mSpanObject);
+            break;
+
         case Action.TYPE_SET_HANDLER:
             geckoSetIcHandler(action.mHandler);
             break;
         }
         if (action.mShouldUpdate) {
             geckoUpdateGecko(false);
         }
     }
@@ -1041,21 +1053,17 @@ final class GeckoEditable
     // Spannable interface
 
     @Override
     public void removeSpan(Object what) {
         if (what == Selection.SELECTION_START ||
                 what == Selection.SELECTION_END) {
             Log.w(LOGTAG, "selection removed with removeSpan()");
         }
-        if (mText.getSpanStart(what) >= 0) { // only remove if it's there
-            // Okay to remove immediately
-            mText.removeSpan(what);
-            mActionQueue.offer(new Action(Action.TYPE_REMOVE_SPAN));
-        }
+        mActionQueue.offer(Action.newRemoveSpan(what));
     }
 
     @Override
     public void setSpan(Object what, int start, int end, int flags) {
         if (what == Selection.SELECTION_START) {
             if ((flags & Spanned.SPAN_INTERMEDIATE) != 0) {
                 // We will get the end offset next, just save the start for now
                 mSavedSelectionStart = start;