Bug 660501 - Fix Threadpane context menu after nsContextMenu clean up r=neil a=kairo CLOSED TREE
authorIan Neal <iann_cvs@blueyonder.co.uk>
Fri, 03 Jun 2011 21:26:28 +0100
changeset 7801 f3cc36e1725ea8b49d560e6405cbbfe8b8d31a2e
parent 7800 5733b7ca78cf1d9f78147af511f9546abbd9729b
child 7802 20b1e25ed4ae8ddba1d3780aad34e960b6491917
push id7
push useriann_cvs@blueyonder.co.uk
push dateFri, 03 Jun 2011 20:26:02 +0000
treeherdercomm-beta@f3cc36e1725e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersneil, kairo
bugs660501
Bug 660501 - Fix Threadpane context menu after nsContextMenu clean up r=neil a=kairo CLOSED TREE
suite/common/nsContextMenu.js
suite/mailnews/mailContextMenus.js
--- a/suite/common/nsContextMenu.js
+++ b/suite/common/nsContextMenu.js
@@ -362,21 +362,16 @@ nsContextMenu.prototype = {
         this.setItemAttr("context-video-fullscreen",  "disabled", hasError);
     }
     this.showItem("context-media-sep-commands", onMedia);
   },
 
   // Set various context menu attributes based on the state of the world.
   setTarget: function(aNode, aRangeParent, aRangeOffset) {
     const xulNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
-    if (aNode.namespaceURI == xulNS ||
-        this.isTargetAFormControl(aNode)) {
-      this.shouldDisplay = false;
-      return;
-    }
 
     // Initialize contextual info.
     this.onImage               = false;
     this.onLoadedImage         = false;
     this.onStandaloneImage     = false;
     this.onCanvas              = false;
     this.onVideo               = false;
     this.onAudio               = false;
@@ -391,35 +386,44 @@ nsContextMenu.prototype = {
     this.link                  = null;
     this.linkURL               = "";
     this.linkURI               = null;
     this.linkProtocol          = "";
     this.onMathML              = false;
     this.inFrame               = false;
     this.hasBGImage            = false;
     this.bgImageURL            = "";
+    this.popupURL              = null;
+    this.autoDownload          = false;
+    this.isTextSelected        = false;
+    this.isContentSelected     = false;
     this.possibleSpellChecking = false;
 
     // Remember the node that was clicked.
     this.target = aNode;
 
-    this.autoDownload = Components.classes["@mozilla.org/preferences-service;1"]
-                                  .getService(Components.interfaces.nsIPrefBranch)
-                                  .getBoolPref("browser.download.useDownloadDir");
-
     // Clear any old spellchecking items from the menu, this used to
     // be in the menu hiding code but wasn't getting called in all
     // situations. Here, we can ensure it gets cleaned up any time the
     // menu is shown. Note: must be before uninit because that clears the
     // internal vars
     InlineSpellCheckerUI.clearSuggestionsFromMenu();
     InlineSpellCheckerUI.clearDictionaryListFromMenu();
 
     InlineSpellCheckerUI.uninit();
 
+    if (aNode.namespaceURI == xulNS || this.isTargetAFormControl(aNode)) {
+      this.shouldDisplay = false;
+      return;
+    }
+
+    this.autoDownload = Components.classes["@mozilla.org/preferences-service;1"]
+                                  .getService(Components.interfaces.nsIPrefBranch)
+                                  .getBoolPref("browser.download.useDownloadDir");
+
     // if the document is editable, show context menu like in text inputs
     var win = this.target.ownerDocument.defaultView;
     if (win) {
       var webNav = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                       .getInterface(Components.interfaces.nsIWebNavigation);
       this.browser = webNav.QueryInterface(Components.interfaces.nsIDocShell)
                            .chromeEventHandler;
       var editingSession = webNav.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
@@ -601,17 +605,16 @@ nsContextMenu.prototype = {
           }
         }
       }
       elem = elem.parentNode;
     }
   },
 
   initPopupURL: function() {
-    this.popupURL = null;
     // quick check: if no opener, it can't be a popup
     if (!window.content.opener)
       return;
     try {
       var show = false;
       // is it a popup window?
       const CI = Components.interfaces;
       var xulwin = window
--- a/suite/mailnews/mailContextMenus.js
+++ b/suite/mailnews/mailContextMenus.js
@@ -112,16 +112,18 @@ function InThreadPane()
   }
   return false;
 }
 
 function FillMailContextMenu(aTarget)
 {
   var inThreadPane = InThreadPane();
   gContextMenu = new nsContextMenu(aTarget, getBrowser());
+  // Need to call nsContextMenu's initItems to hide what is not used.
+  gContextMenu.initItems();
   var numSelected = GetNumSelectedMessages();
   var oneOrMore = (numSelected > 0);
   var single = (numSelected == 1);
 
   var isNewsgroup = false;
   var selectedMessage = null;
 
   // Clear the global var used to keep track if a 'Delete Message' or 'Move