Bug 1140979 - Change SelectionHandler/TextSelection to use UUID vs. simple selectionID, r=wesj
authorMark Capella <markcapella@twcny.rr.com>
Tue, 24 Mar 2015 01:34:31 -0400
changeset 265614 1ee3f4cdae47999ac8319171fb92f537b36e3031
parent 265613 525cb4328c4a9248165337e4e7fba370a29971b8
child 265615 d9241a4e3c5c1bcdbe0d7b4b73cb753e019a3b2a
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs1140979
milestone39.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 1140979 - Change SelectionHandler/TextSelection to use UUID vs. simple selectionID, r=wesj
mobile/android/base/TextSelection.java
mobile/android/chrome/content/SelectionHandler.js
--- a/mobile/android/base/TextSelection.java
+++ b/mobile/android/base/TextSelection.java
@@ -38,17 +38,17 @@ class TextSelection extends Layer implem
 
     private final TextSelectionHandle anchorHandle;
     private final TextSelectionHandle caretHandle;
     private final TextSelectionHandle focusHandle;
 
     private final DrawListener mDrawListener;
     private boolean mDraggingHandles;
 
-    private int selectionID; // Unique ID provided for each selection action.
+    private String selectionID; // Unique ID provided for each selection action.
     private float mViewLeft;
     private float mViewTop;
     private float mViewZoom;
 
     private String mCurrentItems;
 
     private TextSelectionActionModeCallback mCallback;
 
@@ -127,17 +127,17 @@ class TextSelection extends Layer implem
             return;
         }
 
         ThreadUtils.postToUiThread(new Runnable() {
             @Override
             public void run() {
                 try {
                     if (event.equals("TextSelection:ShowHandles")) {
-                        selectionID = message.getInt("selectionID");
+                        selectionID = message.getString("selectionID");
                         final JSONArray handles = message.getJSONArray("handles");
                         for (int i=0; i < handles.length(); i++) {
                             String handle = handles.getString(i);
                             getHandle(handle).setVisibility(View.VISIBLE);
                         }
 
                         mViewLeft = 0.0f;
                         mViewTop = 0.0f;
--- a/mobile/android/chrome/content/SelectionHandler.js
+++ b/mobile/android/chrome/content/SelectionHandler.js
@@ -40,17 +40,17 @@ var SelectionHandler = {
   // stored here are relative to the _contentWindow window.
   _cache: { anchorPt: {}, focusPt: {} },
   _targetIsRTL: false,
   _anchorIsRTL: false,
   _focusIsRTL: false,
 
   _activeType: 0, // TYPE_NONE
   _selectionPrivate: null, // private selection reference
-  _selectionID: 0, // Unique Selection ID
+  _selectionID: null, // Unique Selection ID
 
   _draggingHandles: false, // True while user drags text selection handles
   _dragStartAnchorOffset: null, // Editables need initial pos during HandleMove events
   _dragStartFocusOffset: null, // Editables need initial pos during HandleMove events
 
   _ignoreCompositionChanges: false, // Persist caret during IME composition updates
   _prevHandlePositions: [], // Avoid issuing duplicate "TextSelection:Position" messages
   _deferCloseTimer: null, // Used to defer _closeSelection() actions during programmatic changes
@@ -79,16 +79,23 @@ var SelectionHandler = {
     this._targetElementRef = Cu.getWeakReference(aTargetElement);
   },
 
   get _domWinUtils() {
     return BrowserApp.selectedBrowser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).
                                                     getInterface(Ci.nsIDOMWindowUtils);
   },
 
+  // Provides UUID service for selection ID's.
+  get _idService() {
+    delete this._idService;
+    return this._idService = Cc["@mozilla.org/uuid-generator;1"].
+      getService(Ci.nsIUUIDGenerator);
+  },
+
   _addObservers: function sh_addObservers() {
     Services.obs.addObserver(this, "Gesture:SingleTap", false);
     Services.obs.addObserver(this, "Tab:Selected", false);
     Services.obs.addObserver(this, "TextSelection:Move", false);
     Services.obs.addObserver(this, "TextSelection:Position", false);
     Services.obs.addObserver(this, "TextSelection:End", false);
     Services.obs.addObserver(this, "TextSelection:Action", false);
     Services.obs.addObserver(this, "TextSelection:LayerReflow", false);
@@ -823,17 +830,17 @@ var SelectionHandler = {
         // Blur the targetElement to force IME code to undo previous style compositions
         // (visible underlines / etc generated by autoCorrection, autoSuggestion)
         aElement.blur();
       }
       // Ensure targetElement is now focused normally
       aElement.focus();
     }
 
-    this._selectionID++;
+    this._selectionID = this._idService.generateUUID().toString();
     this._stopDraggingHandles();
     this._contentWindow = aElement.ownerDocument.defaultView;
     this._targetIsRTL = (this._contentWindow.getComputedStyle(aElement, "").direction == "rtl");
 
     this._addObservers();
   },
 
   _getSelection: function sh_getSelection() {