Bug 1306645 - Don't add application/x-moz-file entries from the clipboard to dataTransfer with e10s, r=enndeakin a=ritu
☠☠ backed out by 4131f9c0b0c7 ☠ ☠
authorMichael Layzell <michael@thelayzells.com>
Tue, 18 Oct 2016 16:41:51 -0400
changeset 350773 46279a9e334d86823bc5b68c834b8dd138f8d38d
parent 350772 91e9715a7065bbc541660646047a3db6260fc86b
child 350774 c788d7486d9fa88d6c8ac787e4c4683f31dd0258
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenndeakin, ritu
bugs1306645, 1308007
milestone50.0
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
@@ -1429,16 +1429,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) {
@@ -1447,16 +1455,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