Bug 1240917 - Tweak ActionBar behavior when selection is collapsed. r=snorp draft
authorTing-Yu Lin <tlin@mozilla.com>
Tue, 02 Feb 2016 14:32:31 +0800
changeset 327834 04066a72acfe0f75a36cb52068284f9d7e3c8284
parent 327833 54479f3a72e9fa7779c31da3cb49f026d59308a4
child 513770 1804ff1cb050a0805f3869e5dd3977115943c252
push id10313
push usertlin@mozilla.com
push dateTue, 02 Feb 2016 06:34:05 +0000
reviewerssnorp
bugs1240917
milestone47.0a1
Bug 1240917 - Tweak ActionBar behavior when selection is collapsed. r=snorp * Long pressing on empty input -> show the ActionBar. * Single tapping on input (either empty or non-empty) -> do not show the ActionBar.
mobile/android/chrome/content/ActionBarHandler.js
--- a/mobile/android/chrome/content/ActionBarHandler.js
+++ b/mobile/android/chrome/content/ActionBarHandler.js
@@ -30,16 +30,37 @@ var ActionBarHandler = {
    */
   caretStateChangedHandler: function(e) {
     // Close an open ActionBar, if carets no longer logically visible.
     if (this._selectionID && !e.caretVisible) {
       this._uninit(false);
       return;
     }
 
+    if (!this._selectionID && e.collapsed) {
+      switch (e.reason) {
+        case 'longpressonemptycontent':
+        // case 'taponcaret':
+          // Show ActionBar when long pressing on an empty input.
+          // XXX: If we ever want to show ActionBar when single tapping on the
+          // caret, uncomment the above case 'taponcaret'.
+          this._init();
+          break;
+
+        case 'updateposition':
+          // Do not show ActionBar when single tapping on an non-empty editable
+          // input.
+          break;
+
+        default:
+          break;
+      }
+      return;
+    }
+
     // Open a closed ActionBar if carets actually visible.
     if (!this._selectionID && e.caretVisuallyVisible) {
       this._init();
       return;
     }
 
     // Else, update an open ActionBar.
     if (this._selectionID) {