Bug 1306645 - Don't add application/x-moz-file entries from the clipboard to dataTransfer with e10s, r=enndeakin a=ritu
authorMichael Layzell <michael@thelayzells.com>
Tue, 18 Oct 2016 16:41:51 -0400
changeset 358490 f023ef728d1a9599e6fcea2919657d7db61dd3c8
parent 358489 34354988012e165b0fd43c5fb2acd8ab0a44aa45
child 358491 bf9235ab0289e3fc88cc0fdba9f02ba7983aa695
push id1324
push usermtabara@mozilla.com
push dateMon, 16 Jan 2017 13:07:44 +0000
treeherdermozilla-release@a01c49833940 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenndeakin, ritu
bugs1306645, 1308007
milestone51.0a2
Bug 1306645 - Don't add application/x-moz-file entries from the clipboard to dataTransfer with e10s, r=enndeakin a=ritu application/x-moz-file entries on the clipboard are not able to be successfully transmitted across synchronous IPC due to bug 1308007, thus they appear as useless null files. This patch hides those useless null files, and thus unhides image data which may have been on the clipboard but was previously hidden by the presence of an application/x-moz-file file MozReview-Commit-ID: 4RmQe9kDZLe
dom/events/DataTransfer.cpp
--- a/dom/events/DataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -1417,16 +1417,24 @@ DataTransfer::CacheExternalClipboardForm
   nsCOMPtr<nsIPrincipal> sysPrincipal;
   ssm->GetSystemPrincipal(getter_AddRefs(sysPrincipal));
 
   // Check if the clipboard has any files
   bool hasFileData = false;
   const char *fileMime[] = { kFileMime };
   clipboard->HasDataMatchingFlavors(fileMime, 1, mClipboardType, &hasFileData);
 
+  // We will be ignoring any application/x-moz-file files found in the paste
+  // datatransfer within e10s, as they will fail to be sent over IPC. Because of
+  // that, we will unset hasFileData, whether or not it would have been set.
+  // (bug 1308007)
+  if (XRE_IsContentProcess()) {
+    hasFileData = false;
+  }
+
   // there isn't a way to get a list of the formats that might be available on
   // all platforms, so just check for the types that can actually be imported.
   // Note that the loop below assumes that kCustomTypesMime will be first.
   const char* formats[] = { kCustomTypesMime, kFileMime, kHTMLMime, kRTFMime,
                             kURLMime, kURLDataMime, kUnicodeMime, kPNGImageMime,
                             kJPEGImageMime, kGIFImageMime };
 
   for (uint32_t f = 0; f < mozilla::ArrayLength(formats); ++f) {
@@ -1435,16 +1443,24 @@ DataTransfer::CacheExternalClipboardForm
     clipboard->HasDataMatchingFlavors(&(formats[f]), 1, mClipboardType,
                                       &supported);
     // if the format is supported, add an item to the array with null as
     // the data. When retrieved, GetRealData will read the data.
     if (supported) {
       if (f == 0) {
         FillInExternalCustomTypes(0, sysPrincipal);
       } else {
+        // In non-e10s we support pasting files from explorer.exe.
+        // Unfortunately, we fail to send that data over IPC in e10s, so we
+        // don't want to add the item to the DataTransfer and end up producing a
+        // null `application/x-moz-file`. (bug 1308007)
+        if (XRE_IsContentProcess() && f == 1) {
+          continue;
+        }
+
         // If we aren't the file data, and we have file data, we want to be hidden
         CacheExternalData(formats[f], 0, sysPrincipal, /* hidden = */ f != 1 && hasFileData);
       }
     }
   }
 }
 
 void