Bug 857825 - houskeeping in SelectionHelperUI. r=mbrubeck
authorJim Mathies <jmathies@mozilla.com>
Fri, 05 Apr 2013 05:33:42 -0500
changeset 127784 d33c412d2be05ac950a35262a24c4cbd8444245b
parent 127783 9a0aa8302b9efccfbe1ea1aa73d6bc9896bf2d1a
child 127785 6a67ec142bb14b33aed989c1484c5d15c6846521
push id24512
push userryanvm@gmail.com
push dateFri, 05 Apr 2013 20:13:49 +0000
treeherdermozilla-central@139b6ba547fa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
bugs857825
milestone23.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 857825 - houskeeping in SelectionHelperUI. r=mbrubeck
browser/metro/base/content/helperui/SelectionHelperUI.js
--- a/browser/metro/base/content/helperui/SelectionHelperUI.js
+++ b/browser/metro/base/content/helperui/SelectionHelperUI.js
@@ -414,63 +414,53 @@ var SelectionHelperUI = {
     this._targetElementRect = Util.getCleanRect();
 
     // SelectionHandler messages
     messageManager.addMessageListener("Content:SelectionRange", this);
     messageManager.addMessageListener("Content:SelectionCopied", this);
     messageManager.addMessageListener("Content:SelectionFail", this);
     messageManager.addMessageListener("Content:SelectionDebugRect", this);
 
-    // selection related events
+    window.addEventListener("keypress", this, true);
     window.addEventListener("click", this, false);
     window.addEventListener("dblclick", this, false);
-
-    // Picking up scroll attempts
     window.addEventListener("touchstart", this, true);
     window.addEventListener("touchend", this, true);
     window.addEventListener("touchmove", this, true);
-
-    // context ui display events
     window.addEventListener("MozContextUIShow", this, true);
     window.addEventListener("MozContextUIDismiss", this, true);
+    window.addEventListener("MozPrecisePointer", this, true);
 
-    // cancellation related events
-    window.addEventListener("keypress", this, true);
     Elements.browsers.addEventListener("URLChanged", this, true);
     Elements.browsers.addEventListener("SizeChanged", this, true);
     Elements.browsers.addEventListener("ZoomChanged", this, true);
 
-    window.addEventListener("MozPrecisePointer", this, true);
-
     this.overlay.enabled = true;
   },
 
   _shutdown: function _shutdown() {
     messageManager.removeMessageListener("Content:SelectionRange", this);
     messageManager.removeMessageListener("Content:SelectionCopied", this);
     messageManager.removeMessageListener("Content:SelectionFail", this);
     messageManager.removeMessageListener("Content:SelectionDebugRect", this);
 
+    window.removeEventListener("keypress", this, true);
     window.removeEventListener("click", this, false);
     window.removeEventListener("dblclick", this, false);
-
     window.removeEventListener("touchstart", this, true);
     window.removeEventListener("touchend", this, true);
     window.removeEventListener("touchmove", this, true);
-
     window.removeEventListener("MozContextUIShow", this, true);
     window.removeEventListener("MozContextUIDismiss", this, true);
+    window.removeEventListener("MozPrecisePointer", this, true);
 
-    window.removeEventListener("keypress", this, true);
     Elements.browsers.removeEventListener("URLChanged", this, true);
     Elements.browsers.removeEventListener("SizeChanged", this, true);
     Elements.browsers.removeEventListener("ZoomChanged", this, true);
 
-    window.removeEventListener("MozPrecisePointer", this, true);
-
     this._shutdownAllMarkers();
 
     this._selectionMarkIds = [];
     this._msgTarget = null;
     this._activeSelectionRect = null;
     this._selectionHandlerActive = false;
 
     this.overlay.displayDebugLayer = false;
@@ -777,16 +767,40 @@ var SelectionHelperUI = {
       xPos: coords.x,
       yPos: coords.y,
     });
 
     aEvent.stopPropagation();
     aEvent.preventDefault();
   },
 
+  _onKeypress: function _onKeypress() {
+    this.closeEditSession();
+  },
+
+  _onResize: function _onResize() {
+    this._sendAsyncMessage("Browser:SelectionUpdate", {});
+  },
+
+  _onContextUIVisibilityEvent: function _onContextUIVisibilityEvent(aType) {
+    // Manage display of monocles when the context ui is displayed.
+    if (!this.isActive)
+      return;
+    this.overlay.hidden = (aType == "MozContextUIShow");
+  },
+
+  /*
+   * Event handlers for message manager
+   */
+
+  _onDebugRectRequest: function _onDebugRectRequest(aMsg) {
+    this.overlay.addDebugRect(aMsg.left, aMsg.top, aMsg.right, aMsg.bottom,
+                              aMsg.color, aMsg.fill, aMsg.id);
+  },
+
   _onSelectionCopied: function _onSelectionCopied(json) {
     this.closeEditSessionAndClear();
   },
 
   _onSelectionRangeChange: function _onSelectionRangeChange(json) {
     // start and end contain client coordinates.
     if (json.updateStart) {
       this.startMark.position(this._msgTarget.xbtoc(json.start.xPos, true),
@@ -819,36 +833,16 @@ var SelectionHelperUI = {
       this._msgTarget.rectBrowserToClient(json.element, true);
   },
 
   _onSelectionFail: function _onSelectionFail() {
     Util.dumpLn("failed to get a selection.");
     this.closeEditSession();
   },
 
-  _onKeypress: function _onKeypress() {
-    this.closeEditSession();
-  },
-
-  _onResize: function _onResize() {
-    this._sendAsyncMessage("Browser:SelectionUpdate", {});
-  },
-
-  _onContextUIVisibilityEvent: function _onContextUIVisibilityEvent(aType) {
-    // Manage display of monocles when the context ui is displayed.
-    if (!this.isActive)
-      return;
-    this.overlay.hidden = (aType == "MozContextUIShow");
-  },
-
-  _onDebugRectRequest: function _onDebugRectRequest(aMsg) {
-    this.overlay.addDebugRect(aMsg.left, aMsg.top, aMsg.right, aMsg.bottom,
-                              aMsg.color, aMsg.fill, aMsg.id);
-  },
-
   /*
    * Events
    */
 
   handleEvent: function handleEvent(aEvent) {
     if (this._debugEvents && aEvent.type != "touchmove") {
       Util.dumpLn("SelectionHelperUI:", aEvent.type);
     }
@@ -888,32 +882,32 @@ var SelectionHelperUI = {
             this.closeEditSessionAndClear();
           }
         }
         break;
       }
 
       case "keypress":
         this._onKeypress(aEvent);
-      break;
+        break;
 
       case "SizeChanged":
         this._onResize(aEvent);
-      break;
+        break;
 
       case "ZoomChanged":
       case "URLChanged":
       case "MozPrecisePointer":
         this.closeEditSessionAndClear();
-      break;
+        break;
 
       case "MozContextUIShow":
       case "MozContextUIDismiss":
         this._onContextUIVisibilityEvent(aEvent.type);
-      break;
+        break;
     }
   },
 
   receiveMessage: function sh_receiveMessage(aMessage) {
     if (this._debugEvents) Util.dumpLn("SelectionHelperUI:", aMessage.name);
     let json = aMessage.json;
     switch (aMessage.name) {
       case "Content:SelectionFail":