Bug 947321 - Set all actionmode icons to show if room. r=margaret, a=lsblakk
authorWes Johnston <wjohnston@mozilla.com>
Tue, 10 Dec 2013 10:46:08 -0800
changeset 175314 87e5014a5befd351d7d6785c8cc6a201c6ea705c
parent 175313 5cd46f9b875ac9b426e9a9b9495f4c92b3834581
child 175315 ca9a4160af036a3e795e56a0b20c073c6dea69ff
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, lsblakk
bugs947321
milestone28.0a2
Bug 947321 - Set all actionmode icons to show if room. r=margaret, a=lsblakk
mobile/android/chrome/content/SelectionHandler.js
--- a/mobile/android/chrome/content/SelectionHandler.js
+++ b/mobile/android/chrome/content/SelectionHandler.js
@@ -310,21 +310,24 @@ var SelectionHandler = {
     for (let type in this.actions) {
       let action = this.actions[type];
       if (action.selector.matches(this._targetElement, aX, aY)) {
         let a = {
           id: action.id,
           label: this._getValue(action, "label", ""),
           icon: this._getValue(action, "icon", "drawable://ic_status_logo"),
           showAsAction: this._getValue(action, "showAsAction", true),
+          order: this._getValue(action, "order", 0)
         };
         actions.push(a);
       }
     }
 
+    actions.sort((a, b) => b.order - a.order);
+
     sendMessageToJava({
       type: type,
       handles: handles,
       actions: actions,
     });
   },
 
   _updateMenu: function() {
@@ -335,81 +338,77 @@ var SelectionHandler = {
     SELECT_ALL: {
       label: Strings.browser.GetStringFromName("contextmenu.selectAll"),
       id: "selectall_action",
       icon: "drawable://select_all",
       action: function(aElement) {
         SelectionHandler.selectAll(aElement);
       },
       selector: ClipboardHelper.selectAllContext,
+      order: 1,
     },
 
     CUT: {
       label: Strings.browser.GetStringFromName("contextmenu.cut"),
       id: "cut_action",
       icon: "drawable://cut",
       action: function(aElement) {
         let start = aElement.selectionStart;
         let end   = aElement.selectionEnd;
 
         SelectionHandler.copySelection();
         aElement.value = aElement.value.substring(0, start) + aElement.value.substring(end)
 
         // copySelection closes the selection. Show a caret where we just cut the text.
         SelectionHandler.attachCaret(aElement);
       },
+      order: 1,
       selector: ClipboardHelper.cutContext,
     },
 
     COPY: {
       label: Strings.browser.GetStringFromName("contextmenu.copy"),
       id: "copy_action",
       icon: "drawable://copy",
       action: function() {
         SelectionHandler.copySelection();
       },
+      order: 1,
       selector: ClipboardHelper.getCopyContext(false)
     },
 
     PASTE: {
       label: Strings.browser.GetStringFromName("contextmenu.paste"),
       id: "paste_action",
       icon: "drawable://paste",
       action: function(aElement) {
         ClipboardHelper.paste(aElement);
         SelectionHandler._positionHandles();
         SelectionHandler._updateMenu();
       },
+      order: 1,
       selector: ClipboardHelper.pasteContext,
     },
 
     SHARE: {
       label: Strings.browser.GetStringFromName("contextmenu.share"),
       id: "share_action",
       icon: "drawable://ic_menu_share",
       action: function() {
         SelectionHandler.shareSelection();
       },
-      showAsAction: function(aElement) {
-        return !((aElement instanceof HTMLInputElement && aElement.mozIsTextField(false)) ||
-                 (aElement instanceof HTMLTextAreaElement));
-      },
       selector: ClipboardHelper.shareContext,
     },
 
     SEARCH: {
       label: function() {
         return Strings.browser.formatStringFromName("contextmenu.search", [Services.search.defaultEngine.name], 1);
       },
       id: "search_action",
       icon: "drawable://ic_url_bar_search",
-      showAsAction: function(aElement) {
-        return !((aElement instanceof HTMLInputElement && aElement.mozIsTextField(false)) ||
-                 (aElement instanceof HTMLTextAreaElement));
-      },
       action: function() {
         SelectionHandler.searchSelection();
         SelectionHandler._closeSelection();
       },
       selector: ClipboardHelper.searchWithContext,
     },
 
   },