Bug 666977 - [backout] Panning ends selection in progress r=mbrubeck
authorMark Finkle <mfinkle@mozilla.com>
Wed, 07 Sep 2011 10:48:15 -0400
changeset 77983 e3ce5dcd24831cbc8c271046abc4c9a93f12e747
parent 77982 ac5813b1196e5ec0d04152894a1fc4dab046cb31
child 77984 aebd7d72106d7cc225d8493455aa4d53c9a75264
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
bugs666977
milestone9.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 666977 - [backout] Panning ends selection in progress r=mbrubeck
mobile/chrome/content/common-ui.js
mobile/chrome/content/content.js
--- a/mobile/chrome/content/common-ui.js
+++ b/mobile/chrome/content/common-ui.js
@@ -1344,54 +1344,31 @@ var SelectionHelper = {
     window.removeEventListener("keypress", this, true);
     Elements.browsers.removeEventListener("URLChanged", this, true);
     Elements.browsers.removeEventListener("SizeChanged", this, true);
     Elements.browsers.removeEventListener("ZoomChanged", this, true);
   },
 
   handleEvent: function handleEvent(aEvent) {
     switch (aEvent.type) {
-      case "PanBegin":
-        window.removeEventListener("PanBegin", this, true);
-        window.removeEventListener("TapUp", this, true);
-        window.addEventListener("PanFinished", this, true);
-        this._start.hidden = true;
-        this._end.hidden = true;
-        break;
-      case "PanFinished":
-        window.removeEventListener("PanFinished", this, true);
-        try {
-          this.popupState.target.messageManager.sendAsyncMessage("Browser:SelectionMeasure", {});
-        } catch (e) {
-          Cu.reportError(e);
-        }
-        break
       case "TapDown":
         if (aEvent.target == this._start || aEvent.target == this._end) {
           this.target = aEvent.target;
           this.deltaX = (aEvent.clientX - this.target.left);
           this.deltaY = (aEvent.clientY - this.target.top);
           window.addEventListener("TapMove", this, true);
         } else {
-          window.addEventListener("PanBegin", this, true);
-          window.addEventListener("TapUp", this, true);
-          this.target = null;
+          this.hide(aEvent);
         }
         break;
       case "TapUp":
-        if (this.target) {
-          window.removeEventListener("TapMove", this, true);
-          this.target = null;
-          this.deltaX = -1;
-          this.deltaY = -1;
-        } else {
-          window.removeEventListener("PanBegin", this, true);
-          window.removeEventListener("TapUp", this, true);
-          this.hide(aEvent);
-        }
+        window.removeEventListener("TapMove", this, true);
+        this.target = null;
+        this.deltaX = -1;
+        this.deltaY = -1;
         break;
       case "TapMove":
         if (this.target) {
           this.target.left = aEvent.clientX - this.deltaX;
           this.target.top = aEvent.clientY - this.deltaY;
           let rect = this.target.getBoundingClientRect();
           let data = this.target == this._start ? { x: rect.right, y: rect.top, type: "start" } : { x: rect.left, y: rect.top, type: "end" };
           let pos = this.popupState.target.transformClientToBrowser(data.x || 0, data.y || 0);
@@ -1401,24 +1378,16 @@ var SelectionHelper = {
             y: pos.y
           };
           this.popupState.target.messageManager.sendAsyncMessage("Browser:SelectionMove", json);
         }
         break;
       case "resize":
       case "SizeChanged":
       case "ZoomChanged":
-      {
-        try {
-          this.popupState.target.messageManager.sendAsyncMessage("Browser:SelectionMeasure", {});
-        } catch (e) {
-          Cu.reportError(e);
-        }
-        break        
-      }
       case "URLChanged":
       case "keypress":
         this.hide(aEvent);
         break;
     }
   },
 
   receiveMessage: function sh_receiveMessage(aMessage) {
--- a/mobile/chrome/content/content.js
+++ b/mobile/chrome/content/content.js
@@ -1348,17 +1348,16 @@ var SelectionHandler = {
   cache: {},
   selectedText: "",
   contentWindow: null,
   
   init: function sh_init() {
     addMessageListener("Browser:SelectionStart", this);
     addMessageListener("Browser:SelectionEnd", this);
     addMessageListener("Browser:SelectionMove", this);
-    addMessageListener("Browser:SelectionMeasure", this);
   },
 
   getCurrentWindowAndOffset: function(x, y, offset) {
     let utils = Util.getWindowUtils(content);
     let elem = utils.elementFromPoint(x, y, true, false);
     while (elem && (elem instanceof HTMLIFrameElement || elem instanceof HTMLFrameElement)) {
       // adjust client coordinates' origin to be top left of iframe viewport
       let rect = elem.getBoundingClientRect();
@@ -1458,17 +1457,17 @@ var SelectionHandler = {
           clipboard.copyString(this.selectedText);
           sendAsyncMessage("Browser:SelectionCopied", { succeeded: true });
         } else {
           sendAsyncMessage("Browser:SelectionCopied", { succeeded: false });
         }
         break;
       }
 
-      case "Browser:SelectionMove":
+      case "Browser:SelectionMove": {
         if (!this.contentWindow)
           return;
 
         // Hack to avoid setting focus in a textbox [Bugs 654352 & 667243]
         let elemUnder = elementFromPoint(json.x - scrollOffset.x, json.y - scrollOffset.y);
         if (elemUnder && elemUnder instanceof Ci.nsIDOMHTMLInputElement || elemUnder instanceof Ci.nsIDOMHTMLTextAreaElement)
 
         // Limit the selection to the initial content window (don't leave or enter iframes)
@@ -1498,38 +1497,16 @@ var SelectionHandler = {
         // Cache the selected text since the selection might be gone by the time we get the "end" message
         let selection = this.contentWindow.getSelection()
         this.selectedText = selection.toString().trim();
 
         // Update the rect we use to test when finishing the clipboard operation
         let range = selection.getRangeAt(0).QueryInterface(Ci.nsIDOMNSRange);
         this.cache.rect = this._extractFromRange(range, this.cache.offset).rect;
         break;
-      case "Browser:SelectionMeasure": {
-        if (!this.contentWindow)
-          return;
-
-        let selection = this.contentWindow.getSelection();
-        let range = selection.getRangeAt(0).QueryInterface(Ci.nsIDOMNSRange);
-        if (!range)
-          return;
-
-        // Cache the selected text since the selection might be gone by the time we get the "end" message
-        this.selectedText = selection.toString().trim();
-
-        // If the range didn't have any text, let's bail
-        if (!this.selectedText.length) {
-          selection.removeAllRanges();
-          return;
-        }
-
-        this.cache = this._extractFromRange(range, this.cache.offset);
-
-        sendAsyncMessage("Browser:SelectionRange", this.cache);
-        break;
       }
     }
   },
 
   _extractFromRange: function sh_extractFromRange(aRange, aOffset) {
     let cache = { start: {}, end: {}, rect: { left: Number.MAX_VALUE, top: Number.MAX_VALUE, right: 0, bottom: 0 } };
     let rects = aRange.getClientRects();
     for (let i=0; i<rects.length; i++) {