Bug 656886 Context menu broken in non-browser sidebars r=IanN
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Fri, 13 May 2011 20:33:14 +0100
changeset 7768 ffc7c66a1797dfe188c902c482dee3ef5155b9ca
parent 7767 330a00287b90a67ae44cacd8391fa533d6bc6baa
child 7769 ac811b06e1c20135bee17e3ad3a9c81d8c1b1f8f
push idunknown
push userunknown
push dateunknown
reviewersIanN
bugs656886
Bug 656886 Context menu broken in non-browser sidebars r=IanN
suite/common/contentAreaContextOverlay.xul
suite/common/nsContextMenu.js
--- a/suite/common/contentAreaContextOverlay.xul
+++ b/suite/common/contentAreaContextOverlay.xul
@@ -55,17 +55,17 @@
   </stringbundleset>
 
   <popupset id="contentAreaContextSet">
     <!-- This is a generic context menu for a content area. It contains
          each and every possible menu choice.  The appropriate items are
          hidden/shown upon display, based on what the user has clicked-on.
      -->
     <menupopup id="contentAreaContextMenu"
-           onpopupshowing="if (event.target != this) return true; gContextMenu = new nsContextMenu(this, window.getBrowser()); return gContextMenu.shouldDisplay;"
+           onpopupshowing="if (event.target != this) return true; gContextMenu = new nsContextMenu(this); return gContextMenu.shouldDisplay;"
            onpopuphiding="if (event.target == this) gContextMenu = null;">
       <menuitem id="popupwindow-reject"
                 label="&popupWindowRejectCmd.label;"
                 accesskey="&popupWindowRejectCmd.accesskey;"
                 oncommand="gContextMenu.rejectPopupWindows(event.shiftKey);"/>
       <menuitem id="popupwindow-allow"
                 label="&popupWindowAllowCmd.label;"
                 accesskey="&popupWindowAllowCmd.accesskey;"
--- a/suite/common/nsContextMenu.js
+++ b/suite/common/nsContextMenu.js
@@ -50,30 +50,29 @@
 |   Currently, this code is relatively useless for any other purpose.  In the  |
 |   longer term, this code will be restructured to make it more reusable.      |
 ------------------------------------------------------------------------------*/
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 function nsContextMenu(aXulMenu, aBrowser) {
   this.shouldDisplay = true;
-  this.initMenu(aBrowser);
+  this.initMenu();
 }
 
 // Prototype for nsContextMenu "class."
 nsContextMenu.prototype = {
-  initMenu: function(aBrowser) {
+  initMenu: function() {
     // Get contextual info.
     this.setTarget(document.popupNode, document.popupRangeParent,
                    document.popupRangeOffset);
 
     if (!this.shouldDisplay)
       return;
 
-    this.browser = aBrowser;
     this.isTextSelected = this.isTextSelection();
     this.isContentSelected = this.isContentSelection();
 
     this.initPopupURL();
 
     // Initialize (disable/remove) menu items.
     this.initItems();
   },
@@ -414,20 +413,22 @@ nsContextMenu.prototype = {
     InlineSpellCheckerUI.clearSuggestionsFromMenu();
     InlineSpellCheckerUI.clearDictionaryListFromMenu();
 
     InlineSpellCheckerUI.uninit();
 
     // if the document is editable, show context menu like in text inputs
     var win = this.target.ownerDocument.defaultView;
     if (win) {
-      var editingSession = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
-                              .getInterface(Components.interfaces.nsIWebNavigation)
-                              .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
-                              .getInterface(Components.interfaces.nsIEditingSession);
+      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)
+                                 .getInterface(Components.interfaces.nsIEditingSession);
       if (editingSession.windowIsEditable(win) && this.isTargetEditable()) {
         this.onTextInput           = true;
         this.possibleSpellChecking = true;
         InlineSpellCheckerUI.init(editingSession.getEditorForWindow(win));
         var canSpell = InlineSpellCheckerUI.canSpellCheck;
         InlineSpellCheckerUI.initFromEvent(aRangeParent, aRangeOffset);
         this.showItem("spell-check-enabled", canSpell);
         this.showItem("spell-separator", canSpell);