Bug 1645945 - Add context menu and other popups to composeAction panel. r=mkmelin a=wsmwk
authorGeoff Lankow <geoff@darktrojan.net>
Tue, 16 Jun 2020 14:51:51 +1200
changeset 39421 5dfeac89e568b2fe44baa99f03f36e932f5e016a
parent 39420 937baf187c832a4a2238f84499b5344e1d37c042
child 39422 bdc39dddf821f2c0c1a716f3d2051d176cae935a
push id402
push userclokep@gmail.com
push dateMon, 29 Jun 2020 20:48:04 +0000
reviewersmkmelin, wsmwk
bugs1645945
Bug 1645945 - Add context menu and other popups to composeAction panel. r=mkmelin a=wsmwk
mail/components/compose/content/MsgComposeCommands.js
mail/components/compose/content/messengercompose.xhtml
mail/themes/linux/mail/compose/messengercompose.css
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -174,16 +174,20 @@ var kComposeAttachDirPrefName = "mail.co
 
 // Observer for the autocomplete input.
 const inputObserver = {
   observe: (subject, topic, data) => {
     if (topic == "autocomplete-did-enter-text") {
       let input = subject.QueryInterface(Ci.nsIAutoCompleteInput)
         .wrappedJSObject;
 
+      if (!input) {
+        return;
+      }
+
       let element = document.getElementById(input.id);
       // The observer is triggered also from within an already existing pill.
       // Since the autocomplete-input inside a pill doesn't have an ID, we can
       // interrupt this method if no element was selected, or the element has
       // the .input-pill class.
       if (!element || element.classList.contains("input-pill")) {
         return;
       }
@@ -8945,8 +8949,18 @@ function loadBlockedImage(aURL, aReturnD
     if (img.src == aURL) {
       img.src = dataURL; // Swap to data URL.
       img.classList.remove("loading-internal");
     }
   }
 
   return null;
 }
+
+function mailContextOnContextMenu(event) {
+  document.getElementById("mailContext").target =
+    event.composedTarget || event.originalTarget;
+}
+function fillMailContextMenu(event) {
+  gContextMenu = new nsContextMenu(event.target, event.shiftKey);
+  return gContextMenu.shouldDisplay;
+}
+function mailContextOnPopupHiding() {}
--- a/mail/components/compose/content/messengercompose.xhtml
+++ b/mail/components/compose/content/messengercompose.xhtml
@@ -27,16 +27,18 @@
   %baseMenuOverlayDTD;
   <!ENTITY % msgCompSMIMEDTD SYSTEM "chrome://messenger-smime/locale/msgCompSMIMEOverlay.dtd">
   %msgCompSMIMEDTD;
   <!ENTITY % editorOverlayDTD SYSTEM "chrome://messenger/locale/messengercompose/editorOverlay.dtd">
   %editorOverlayDTD;
   <!ENTITY % utilityOverlayDTD SYSTEM
     "chrome://communicator/locale/utilityOverlay.dtd">
   %utilityOverlayDTD;
+  <!ENTITY % messengerDTD SYSTEM "chrome://messenger/locale/messenger.dtd">
+  %messengerDTD;
 ]>
 
 <window id="msgcomposeWindow"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         icon="msgcomposeWindow"
         onunload="ComposeUnload()"
         onload="ComposeLoad()"
@@ -76,16 +78,17 @@
 <script src="chrome://messenger/content/messengercompose/editorUtilities.js"/>
 <script src="chrome://messenger/content/messengercompose/ComposerCommands.js"/>
 <script src="chrome://messenger/content/button-menu-button.js"/>
 <script src="chrome://messenger/content/messengercompose/MsgComposeCommands.js"/>
 <script src="chrome://messenger/content/messengercompose/bigFileObserver.js"/>
 <script src="chrome://messenger/content/messengercompose/cloudAttachmentLinkManager.js"/>
 <script src="chrome://messenger/content/messenger-customization.js"/>
 <script src="chrome://messenger/content/customizable-toolbar.js"/>
+<script src="chrome://messenger/content/nsContextMenu.js"/>
 
 <!-- drag and drop -->
 <script src="chrome://messenger/content/addressbook/abDragDrop.js"/>
 
 <!-- move needed functions into a single js file -->
 <script src="chrome://messenger/content/messengercompose/addressingWidgetOverlay.js"/>
 <script src="chrome://global/content/contentAreaUtils.js"/>
 <script src="chrome://messenger/content/viewZoomOverlay.js"/>
@@ -371,16 +374,23 @@
 
   <command id="cmd_convertCloud" oncommand="convertSelectedToCloudAttachment(event.target.cloudFileAccount); event.stopPropagation();"/>
   <command id="cmd_convertAttachment" oncommand="goDoCommand('cmd_convertAttachment')"/>
   <command id="cmd_cancelUpload" oncommand="goDoCommand('cmd_cancelUpload')"/>
   <command id="cmd_customizeFromAddress" oncommand="MakeFromFieldEditable();"
            checked="false" label="&customizeFromAddress.label;"/>
 </commandset>
 
+  <commandset>
+    <command id="cmd_reload" oncommand="document.getElementById('requestFrame').reload()"/>
+    <command id="cmd_stop" oncommand="document.getElementById('requestFrame').stop()"/>
+    <command id="cmd_copyLink" oncommand="goDoCommand('cmd_copyLink')" disabled="false"/>
+    <command id="cmd_copyImage" oncommand="goCopyImage()" disabled="false"/>
+  </commandset>
+
   <command id="cmd_doNotRemindForAttachments" oncommand="disableAttachmentReminder();"/>
 
 <keyset id="tasksKeys">
   <!-- File Menu -->
 #ifdef XP_MACOSX
   <!-- Mac has Command+M as system shortcut to minimize current window, so we offer Command+Shift+M for New Message,
        in addition to cross-platform Command+N. With goOpenNewMessage(), pass null instead of event because
        we don't allow Shift in *keyboard shortcuts* for toggling HTML vs. plaintext format, see bug 672475.
@@ -540,17 +550,24 @@
 
   <key id="increasefontsizekb" key="&incrementFontSize.key;" observes="cmd_increaseFontStep" modifiers="accel"/>
   <key key="&incrementFontSize.key;" observes="cmd_increaseFontStep" modifiers="accel, shift"/>
   <key key="&incrementFontSize.key2;" observes="cmd_increaseFontStep" modifiers="accel"/>
 
   <key id="insertlinkkb" key="&insertLinkCmd2.key;" observes="cmd_link" modifiers="accel"/>
 </keyset>
 
-<popupset id="mainPopupSet"/>
+<popupset id="mainPopupSet">
+#define BROWSER_POPUPS_ONLY
+#include ../../../base/content/mainPopupSet.inc.xhtml
+  <panel is="autocomplete-richlistbox-popup" id="PopupAutoComplete"
+         type="autocomplete"
+         role="group"
+         noautofocus="true"/>
+</popupset>
 
 <!-- Reorder Attachments Panel -->
 <panel id="reorderAttachmentsPanel"
        orient="vertical"
        type="arrow"
        flip="slide"
        onpopupshowing="reorderAttachmentsPanelOnPopupShowing();"
        consumeoutsideclicks="false"
--- a/mail/themes/linux/mail/compose/messengercompose.css
+++ b/mail/themes/linux/mail/compose/messengercompose.css
@@ -117,17 +117,17 @@ menulist:-moz-locale-dir(rtl)::part(labe
 
 #subjectLabel {
   margin-bottom: 0;
   margin-inline-end: 6px;
 }
 
 /* ::::: autocomplete icons ::::: */
 
-.ac-site-icon {
+.autocomplete-richlistitem[type$="-abook"] > .ac-site-icon {
   display: -moz-box;
   margin: 1px 5px;
 }
 
 #composeContentBox {
   background-color: -moz-dialog;
   box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2) inset;
 }