Bug 702019 - Port UI parts of |Bug 617528 - implement the HTML5 "context menu" feature (contextmenu attribute)|. r=Neil a=IanN SEAMONKEY_2_6b2_BUILD1 SEAMONKEY_2_6b2_RELEASE
authorJens Hatlak <jh@junetz.de>
Sat, 26 Nov 2011 14:31:24 +0100
changeset 9385 a03506c2ab9fbd2004f0583a14df33fb0f7dc8fa
parent 9384 2f77787a4916f666c13e3d24fe5d91cf4365064b
child 9386 0146a1f973e2269d9781012ec4435ca0b8b4a7ea
child 9390 a94289f0fe2e1236bde03f06b06d3427c998dc86
push idunknown
push userunknown
push dateunknown
reviewersNeil, IanN
bugs702019, 617528
Bug 702019 - Port UI parts of |Bug 617528 - implement the HTML5 "context menu" feature (contextmenu attribute)|. r=Neil a=IanN
suite/common/contentAreaContextOverlay.xul
suite/common/nsContextMenu.js
suite/installer/package-manifest.in
--- a/suite/common/contentAreaContextOverlay.xul
+++ b/suite/common/contentAreaContextOverlay.xul
@@ -55,18 +55,20 @@
   </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); return gContextMenu.shouldDisplay;"
-           onpopuphiding="if (event.target == this) gContextMenu = null;">
+               pagemenu="start"
+               onpopupshowing="if (event.target != this) return true; gContextMenu = new nsContextMenu(this, gBrowser, event.shiftKey); return gContextMenu.shouldDisplay;"
+               onpopuphiding="if (event.target == this) gContextMenu = null;">
+      <menuseparator id="page-menu-separator"/>
       <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;"
                 oncommand="gContextMenu.allowPopupWindows();"/>
--- a/suite/common/nsContextMenu.js
+++ b/suite/common/nsContextMenu.js
@@ -48,52 +48,68 @@
 |   For usage, see references to this class in navigator.xul.                  |
 |                                                                              |
 |   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) {
+XPCOMUtils.defineLazyGetter(this, "PageMenu", function() {
+  let tmp = {};
+  Components.utils.import("resource://gre/modules/PageMenu.jsm", tmp);
+  return new tmp.PageMenu();
+});
+
+function nsContextMenu(aXulMenu, aBrowser, aIsShift) {
   this.shouldDisplay = true;
-  this.initMenu();
+  this.initMenu(aBrowser, aXulMenu, aIsShift);
 }
 
 // Prototype for nsContextMenu "class."
 nsContextMenu.prototype = {
-  initMenu: function() {
+  initMenu: function(aBrowser, aXulMenu, aIsShift) {
     // Get contextual info.
     this.setTarget(document.popupNode, document.popupRangeParent,
                    document.popupRangeOffset);
 
     if (!this.shouldDisplay)
       return;
 
+    this.hasPageMenu = false;
+    if (!aIsShift && aXulMenu.hasAttribute("pagemenu"))
+      this.hasPageMenu = PageMenu.maybeBuildAndAttachMenu(this.target,
+                                                          aXulMenu);
+
     this.isTextSelected = this.isTextSelection();
     this.isContentSelected = this.isContentSelection();
 
     this.initPopupURL();
 
     // Initialize (disable/remove) menu items.
     this.initItems();
   },
 
   initItems: function() {
+    this.initPageMenuSeparator();
     this.initOpenItems();
     this.initNavigationItems();
     this.initViewItems();
     this.initMiscItems();
     this.initSpellingItems();
     this.initSaveItems();
     this.initClipboardItems();
     this.initMetadataItems();
     this.initMediaPlayerItems();
   },
 
+  initPageMenuSeparator: function() {
+    this.showItem("page-menu-separator", this.hasPageMenu);
+  },
+
   initOpenItems: function() {
     var showOpen = this.onSaveableLink || (this.inDirList && this.onLink);
     this.showItem("context-openlink", showOpen);
     this.showItem("context-openlinkintab", showOpen);
     this.showItem("context-sep-open", showOpen);
   },
 
   initNavigationItems: function() {
--- a/suite/installer/package-manifest.in
+++ b/suite/installer/package-manifest.in
@@ -295,16 +295,17 @@
 @BINPATH@/components/xpcom_components.xpt
 @BINPATH@/components/xpcom_ds.xpt
 @BINPATH@/components/xpcom_io.xpt
 @BINPATH@/components/xpcom_system.xpt
 @BINPATH@/components/xpcom_threads.xpt
 @BINPATH@/components/xpcom_xpti.xpt
 @BINPATH@/components/xpconnect.xpt
 @BINPATH@/components/xulapp.xpt
+@BINPATH@/components/xul.xpt
 @BINPATH@/components/xuldoc.xpt
 @BINPATH@/components/xultmpl.xpt
 @BINPATH@/components/zipwriter.xpt
 
 ; JavaScript components
 @BINPATH@/components/addonManager.js
 @BINPATH@/components/amContentHandler.js
 @BINPATH@/components/amWebInstallListener.js