Bug 970054 - Close selection if you tap outside it. r=margaret,capella
authorWes Johnston <wjohnston@mozilla.com>
Wed, 19 Feb 2014 13:01:51 -0800
changeset 170009 f43ffc6a3076fa8e8b9bc55e23e474752024818d
parent 170008 575335837ed5e48fbbc50cc962d8041b941df63d
child 170010 6c387fa25e618d5fdbb6b95bb9bf8349166bf617
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersmargaret, capella
bugs970054
milestone30.0a1
Bug 970054 - Close selection if you tap outside it. r=margaret,capella
mobile/android/chrome/content/SelectionHandler.js
--- a/mobile/android/chrome/content/SelectionHandler.js
+++ b/mobile/android/chrome/content/SelectionHandler.js
@@ -70,17 +70,21 @@ var SelectionHandler = {
     Services.obs.removeObserver(this, "TextSelection:End");
     Services.obs.removeObserver(this, "TextSelection:Action");
     BrowserApp.deck.removeEventListener("compositionend", this);
   },
 
   observe: function sh_observe(aSubject, aTopic, aData) {
     switch (aTopic) {
       case "Gesture:SingleTap": {
-        if (this._activeType == this.TYPE_CURSOR) {
+        if (this._activeType == this.TYPE_SELECTION) {
+          let data = JSON.parse(aData);
+          if (!this._pointInSelection(data.x, data.y))
+            this._closeSelection();
+        } else if (this._activeType == this.TYPE_CURSOR) {
           // attachCaret() is called in the "Gesture:SingleTap" handler in BrowserEventHandler
           // We're guaranteed to call this first, because this observer was added last
           this._deactivate();
         }
         break;
       }
       case "Tab:Selected":
       case "TextSelection:End":