Bug 870063 - Make context menus use async prompt service. r=mfinkle
☠☠ backed out by b11bffd58de9 ☠ ☠
authorWes Johnston <wjohnston@mozilla.com>
Mon, 03 Jun 2013 09:20:44 -0700
changeset 133815 4fd2ae88da98cfedf769694222509952956c2b91
parent 133814 1797dc46e8622a12ce5e3a1c2f12ea335650e415
child 133816 d3106edd4a5a31029afad97c1c3fa4bf13eb2fd6
push id28907
push userwjohnston@mozilla.com
push dateMon, 03 Jun 2013 16:22:12 +0000
treeherdermozilla-inbound@8904d2bf5da0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs870063
milestone24.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 870063 - Make context menus use async prompt service. r=mfinkle
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -1907,20 +1907,18 @@ var NativeWindow = {
           getValue: function(aElt) {
             if (item.hasAttribute("hidden"))
               return null;
 
             return {
               icon: item.icon,
               label: item.label,
               id: id,
-              isGroup: false,
-              inGroup: false,
               disabled: item.disabled,
-              isParent: item instanceof Ci.nsIDOMHTMLMenuElement
+              parent: item instanceof Ci.nsIDOMHTMLMenuElement
             }
           }
         };
 
         this.menuitems.splice(this._nativeItemsSeparator, 0, menuitem);
         this._nativeItemsSeparator++;
       }
     },
@@ -2035,46 +2033,46 @@ var NativeWindow = {
         // hidden menu items will return null from getValue
         if (val)
           itemArray.push(val);
       }
 
       if (itemArray.length == 0)
         return;
 
-      let msg = {
-        type: "Prompt:Show",
-        title: title,
-        listitems: itemArray
-      };
-      let data = JSON.parse(sendMessageToJava(msg));
-      if (data.button == -1) {
-        // prompt was cancelled
-        return;
-      }
-
-      let selectedId = itemArray[data.button].id;
-      let selectedItem = this._getMenuItemForId(selectedId);
-
-      this.menuitems = null;
-      if (selectedItem && selectedItem.callback) {
-        if (selectedItem.matches) {
-          // for menuitems added using the native UI, pass the dom element that matched that item to the callback
-          while (aTarget) {
-            if (selectedItem.matches(aTarget, aX, aY)) {
-              selectedItem.callback.call(selectedItem, aTarget, aX, aY);
-              break;
+      let prompt = new Promt({
+        window: aTarget.ownerDocument.defaultView,
+        title: title
+      }).setSingleChoiceItems(itemArray)
+      .show(function(data) {
+        if (data.button == -1) {
+          // prompt was cancelled
+          return;
+        }
+
+        let selectedId = itemArray[data.button].id;
+        let selectedItem = this._getMenuItemForId(selectedId);
+
+        this.menuitems = null;
+        if (selectedItem && selectedItem.callback) {
+          if (selectedItem.matches) {
+            // for menuitems added using the native UI, pass the dom element that matched that item to the callback
+            while (aTarget) {
+              if (selectedItem.matches(aTarget, aX, aY)) {
+                selectedItem.callback.call(selectedItem, aTarget, aX, aY);
+                break;
+              }
+              aTarget = aTarget.parentNode;
             }
-            aTarget = aTarget.parentNode;
+          } else {
+            // if this was added using the html5 context menu api, just click on the context menu item
+            selectedItem.callback.call(selectedItem, aTarget, aX, aY);
           }
-        } else {
-          // if this was added using the html5 context menu api, just click on the context menu item
-          selectedItem.callback.call(selectedItem, aTarget, aX, aY);
         }
-      }
+      });
     },
 
     handleEvent: function(aEvent) {
       BrowserEventHandler._cancelTapHighlight();
       aEvent.target.ownerDocument.defaultView.removeEventListener("contextmenu", this, false);
       this._show(aEvent);
     },