Bug 655529 - Make use of contentAreaContext in message compose window r=neil
authorIan Neal <iann_cvs@blueyonder.co.uk>
Fri, 13 May 2011 21:21:27 +0100
changeset 7769 ac811b06e1c20135bee17e3ad3a9c81d8c1b1f8f
parent 7768 ffc7c66a1797dfe188c902c482dee3ef5155b9ca
child 7770 9e9715602ab60728f4afd822025c1cd1c1be2c2c
push idunknown
push userunknown
push dateunknown
reviewersneil
bugs655529
Bug 655529 - Make use of contentAreaContext in message compose window r=neil
suite/mailnews/compose/MsgComposeCommands.js
suite/mailnews/compose/messengercompose.xul
suite/mailnews/compose/msgComposeContextOverlay.xul
suite/mailnews/jar.mn
--- a/suite/mailnews/compose/MsgComposeCommands.js
+++ b/suite/mailnews/compose/MsgComposeCommands.js
@@ -623,30 +623,32 @@ function updateComposeItems()
 
     // Options Menu
     goUpdateCommand("cmd_spelling");
   } catch(e) {}
 }
 
 function openEditorContextMenu(popup)
 {
-  // if we have a mispelled word, show spellchecker context
-  // menuitems as well as the usual context menu
-  InlineSpellCheckerUI.clearSuggestionsFromMenu();
-  InlineSpellCheckerUI.initFromEvent(document.popupRangeParent, document.popupRangeOffset);
-  var onMisspelling = InlineSpellCheckerUI.overMisspelling;
-  document.getElementById('spellCheckSuggestionsSeparator').hidden = !onMisspelling;
-  document.getElementById('spellCheckAddToDictionary').hidden = !onMisspelling;
-  document.getElementById('spellCheckIgnoreWord').hidden = !onMisspelling;
-  var separator = document.getElementById('spellCheckAddSep');
-  separator.hidden = !onMisspelling;
-  document.getElementById('spellCheckNoSuggestions').hidden = !onMisspelling ||
-      InlineSpellCheckerUI.addSuggestionsToMenu(popup, separator, 5);
-
-  updateEditItems();
+  gContextMenu = new nsContextMenu(popup);
+  if (gContextMenu.shouldDisplay)
+  {
+    // If message body context menu then focused element should be content.
+    var showPasteExtra =
+        top.document.commandDispatcher.focusedWindow == content;
+    gContextMenu.showItem("context-pasteNoFormatting", showPasteExtra);
+    gContextMenu.showItem("context-pasteQuote", showPasteExtra);
+    if (showPasteExtra)
+    {
+      goUpdateCommand("cmd_pasteNoFormatting");
+      goUpdateCommand("cmd_pasteQuote");
+    }
+    return true;
+  }
+  return false;
 }
 
 function updateEditItems()
 {
   goUpdateCommand("cmd_pasteNoFormatting");
   goUpdateCommand("cmd_pasteQuote");
   goUpdateCommand("cmd_delete");
   goUpdateCommand("cmd_renameAttachment");
--- a/suite/mailnews/compose/messengercompose.xul
+++ b/suite/mailnews/compose/messengercompose.xul
@@ -42,18 +42,19 @@
 
 <?xml-stylesheet href="chrome://messenger/skin/messengercompose/messengercompose.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/folderMenus.css" type="text/css"?>
 <?xml-stylesheet href="chrome://editor/skin/editorFormatToolbar.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/addressingWidget.css" type="text/css"?>
 
 <?xul-overlay href="chrome://global/content/charsetOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/tasksOverlay.xul"?>
+<?xul-overlay href="chrome://communicator/content/sidebar/sidebarOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/contentAreaContextOverlay.xul"?>
-<?xul-overlay href="chrome://communicator/content/sidebar/sidebarOverlay.xul"?>
+<?xul-overlay href="chrome://messenger/content/messengercompose/msgComposeContextOverlay.xul"?>
 <?xul-overlay href="chrome://messenger/content/messengercompose/addressingWidgetOverlay.xul"?>
 <?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
 <?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
 <?xul-overlay href="chrome://editor/content/editorOverlay.xul"?>
 <?xul-overlay href="chrome://editor/content/editorSmileyOverlay.xul"?>
 <?xul-overlay href="chrome://messenger/content/messengercompose/mailComposeExtrasOverlay.xul"?>
 
 <!DOCTYPE window [
@@ -185,64 +186,24 @@
   <key keycode="VK_TAB" oncommand="SwitchElementFocus(event);" modifiers="control,shift"/>
   <key keycode="VK_F6" oncommand="SwitchElementFocus(event);" modifiers="control"/>
   <key keycode="VK_F6" oncommand="SwitchElementFocus(event);" modifiers="control,shift"/>
   <key keycode="VK_F6" oncommand="SwitchElementFocus(event);" modifiers="shift"/>
   <key keycode="VK_F6" oncommand="SwitchElementFocus(event);"/>
 </keyset>
 <keyset id="editorKeys"/>
 
+  <popupset id="contentAreaContextSet"/>
+
   <popupset id="msgComposePopupSet">
     <menupopup id="sidebarPopup"/>
     <menupopup id="popupNotificationMenu"/>
     <menupopup id="toolbar-context-menu"/>
     <panel id="customizeToolbarSheetPopup"/>
 
-    <menupopup id="msgComposeContext"
-               onpopupshowing="openEditorContextMenu(this);">
-      <menuitem id="spellCheckNoSuggestions"
-                label="&spellCheckNoSuggestions.label;"
-                disabled="true"/>
-      <menuseparator id="spellCheckAddSep"/>
-      <menuitem id="spellCheckAddToDictionary"
-                label="&spellCheckAddToDictionary.label;"
-                accesskey="&spellCheckAddToDictionary.accesskey;"
-                oncommand="InlineSpellCheckerUI.addToDictionary();"/>
-      <menuitem id="spellCheckIgnoreWord"
-                label="&spellCheckIgnoreWord.label;"
-                accesskey="&spellCheckIgnoreWord.accesskey;"
-                oncommand="InlineSpellCheckerUI.ignoreWord()"/>
-      <menuseparator id="spellCheckSuggestionsSeparator"/>
-
-      <menuitem label="&undo.label;"
-                accesskey="&undo.accesskey;"
-                command="cmd_undo"/>
-      <menuseparator/>
-      <menuitem label="&cut.label;"
-                accesskey="&cut.accesskey;"
-                command="cmd_cut"/>
-      <menuitem label="&copy.label;"
-                accesskey="&copy.accesskey;"
-                command="cmd_copy"/>
-      <menuitem label="&paste.label;"
-                accesskey="&paste.accesskey;"
-                command="cmd_paste"/>
-      <menuitem command="cmd_pasteNoFormatting"/>
-      <menuitem label="&pasteQuote.label;"
-                accesskey="&pasteQuote.accesskey;"
-                command="cmd_pasteQuote"/>
-      <menuitem label="&delete.label;"
-                accesskey="&delete.accesskey;"
-                command="cmd_delete"/>
-      <menuseparator/>
-      <menuitem label="&selectAll.label;"
-                accesskey="&selectAll.accesskey;"
-                command="cmd_selectAll"/>
-    </menupopup>
-
     <menupopup id="msgComposeAttachmentContext"
                onpopupshowing="updateEditItems();">
       <menuitem label="&openAttachment.label;"
                 accesskey="&openAttachment.accesskey;"
                 command="cmd_openAttachment"/>
       <menuitem label="&delete.label;"
                 accesskey="&delete.accesskey;"
                 command="cmd_delete"/>
@@ -749,17 +710,17 @@
 <hbox id="sidebar-parent" flex="1">
   <!-- From sidebarOverlay.xul -->
   <vbox id="sidebar-box" class="chromeclass-extrachrome" hidden="true"/>
   <splitter id="sidebar-splitter" class="chromeclass-extrachrome" hidden="true"/>
 
   <!-- The mail message body frame -->
   <vbox id="appcontent" flex="1">
     <editor type="content-primary" id="content-frame" src="about:blank" name="browser.message.body" flex="1"
-            context="msgComposeContext"/>
+            context="contentAreaContextMenu"/>
   </vbox>
 </hbox>
 
   <statusbar id="status-bar" class="chromeclass-status">
     <statusbarpanel id="component-bar"/>
     <statusbarpanel id="statusText" flex="1"/>
     <statusbarpanel class="statusbarpanel-progress" id="statusbar-progresspanel" collapsed="true">
       <progressmeter id="compose-progressmeter" class="progressmeter-statusbar" mode="normal" value="0"/>
new file mode 100644
--- /dev/null
+++ b/suite/mailnews/compose/msgComposeContextOverlay.xul
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<!-- ***** BEGIN LICENSE BLOCK *****
+ Version: MPL 1.1/GPL 2.0/LGPL 2.1
+
+ The contents of this file are subject to the Mozilla Public License Version
+ 1.1 (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
+
+ Software distributed under the License is distributed on an "AS IS" basis,
+ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ for the specific language governing rights and limitations under the
+ License.
+
+ The Original Code is SeaMonkey internet suite code.
+
+ The Initial Developer of the Original Code is
+ the SeaMonkey project at mozilla.org.
+ Portions created by the Initial Developer are Copyright (C) 2011
+ the Initial Developer. All Rights Reserved.
+
+ Contributor(s):
+   Ian Neal <iann_bugzilla@blueyonder.co.uk>
+
+ Alternatively, the contents of this file may be used under the terms of
+ either of the GNU General Public License Version 2 or later (the "GPL"),
+ or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ in which case the provisions of the GPL or the LGPL are applicable instead
+ of those above. If you wish to allow use of your version of this file only
+ under the terms of either the GPL or the LGPL, and not to allow others to
+ use your version of this file under the terms of the MPL, indicate your
+ decision by deleting the provisions above and replace them with the notice
+ and other provisions required by the GPL or the LGPL. If you do not delete
+ the provisions above, a recipient may use your version of this file under
+ the terms of any one of the MPL, the GPL or the LGPL.
+
+ ***** END LICENSE BLOCK ***** -->
+
+<!DOCTYPE overlay [
+<!ENTITY % messengercomposeDTD SYSTEM "chrome://messenger/locale/messengercompose/messengercompose.dtd" >
+%messengercomposeDTD;
+]>
+
+<overlay id="msgComposeContextOverlay"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+  <menupopup id="contentAreaContextMenu"
+             onpopupshowing="return event.target != this ||
+                                    openEditorContextMenu(this);">
+    <!-- Hide the menuitems by default so they do not to show up
+         in the sidebar context menu. -->
+    <menuitem id="context-pasteNoFormatting"
+              insertafter="context-paste"
+              hidden="true"
+              command="cmd_pasteNoFormatting"/>
+    <menuitem id="context-pasteQuote"
+              insertafter="context-pasteNoFormatting"
+              label="&pasteQuote.label;"
+              accesskey="&pasteQuote.accesskey;"
+              hidden="true"
+              command="cmd_pasteQuote"/>
+  </menupopup>
+</overlay>
--- a/suite/mailnews/jar.mn
+++ b/suite/mailnews/jar.mn
@@ -85,16 +85,17 @@ messenger.jar:
     content/messenger/ABSearchDialog.js                                        (search/ABSearchDialog.js)
     content/messenger/FilterListDialog.xul                                     (search/FilterListDialog.xul)
     content/messenger/FilterListDialog.js                                      (search/FilterListDialog.js)
     content/messenger/messengercompose/pref-composing_messages.xul             (compose/prefs/pref-composing_messages.xul)
     content/messenger/messengercompose/pref-composing_messages.js              (compose/prefs/pref-composing_messages.js)
     content/messenger/messengercompose/pref-formatting.xul                     (compose/prefs/pref-formatting.xul)
     content/messenger/messengercompose/pref-formatting.js                      (compose/prefs/pref-formatting.js)
     content/messenger/messengercompose/messengercompose.xul                    (compose/messengercompose.xul)
+    content/messenger/messengercompose/msgComposeContextOverlay.xul            (compose/msgComposeContextOverlay.xul)
     content/messenger/messengercompose/MsgComposeCommands.js                   (compose/MsgComposeCommands.js)
     content/messenger/messengercompose/addressingWidgetOverlay.js              (compose/addressingWidgetOverlay.js)
     content/messenger/messengercompose/addressingWidgetOverlay.xul             (compose/addressingWidgetOverlay.xul)
     content/messenger/messengercompose/mailComposeExtrasOverlay.xul            (compose/mailComposeExtrasOverlay.xul)
     content/messenger/addressbook/addressbook.js                               (addrbook/addressbook.js)
     content/messenger/addressbook/addressbook.xul                              (addrbook/addressbook.xul)
     content/messenger/addressbook/abCommon.js                                  (addrbook/abCommon.js)
     content/messenger/addressbook/abCardOverlay.js                             (addrbook/abCardOverlay.js)