Bug 1354452 - set text/plain clipboard flavour in onCopyOrDragStart(). r=mkmelin a=jorgk
authorJorg K <jorgk@jorgk.com>
Fri, 07 Apr 2017 22:46:29 +0200
changeset 24458 bd921bdc8b03
parent 24457 14adadd2aca7
child 24459 3ba871050cc7
push id2055
push usermozilla@jorgk.com
push dateWed, 12 Apr 2017 15:22:52 +0000
treeherdercomm-aurora@d3970dc6cd9c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, jorgk
bugs1354452
Bug 1354452 - set text/plain clipboard flavour in onCopyOrDragStart(). r=mkmelin a=jorgk
mail/base/content/mailWindow.js
--- a/mail/base/content/mailWindow.js
+++ b/mail/base/content/mailWindow.js
@@ -121,22 +121,28 @@ function onCopyOrDragStart(e) {
   for (let img of images) {
     if (!imgMap.has(img.src)) {
       continue;
     }
     img.src = imgMap.get(img.src);
   }
 
   let html = div.innerHTML;
+  let parserUtils = Components.classes["@mozilla.org/parserutils;1"]
+                      .getService(Components.interfaces.nsIParserUtils);
+  let plain = parserUtils.convertToPlainText(html,
+    Components.interfaces.nsIDocumentEncoder.OutputForPlainTextClipboardCopy, 0);
   if ("clipboardData" in e) { // copy
     e.clipboardData.setData("text/html", html);
+    e.clipboardData.setData("text/plain", plain);
     e.preventDefault();
   }
   else if ("dataTransfer" in e) { // drag
     e.dataTransfer.setData("text/html", html);
+    e.dataTransfer.setData("text/plain", plain);
   }
 }
 
 function CreateMailWindowGlobals()
 {
   // get the messenger instance
   messenger = Components.classes["@mozilla.org/messenger;1"]
                         .createInstance(Components.interfaces.nsIMessenger);