Bug 1389314 Part3: Temporarily disable the input priority events when dnd is active. r=smaug.
authorStone Shih <sshih@mozilla.com>
Wed, 02 Aug 2017 15:23:35 +0800
changeset 428275 949525c39b95d9aa6e9c51c4e50b108bf4f39de5
parent 428274 5f6a7c8712b3c69ed0f099f385ae462b7fb1354b
child 428276 f57e58155599157fec08c72676817576eb50e997
push id1567
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 12:36:05 +0000
treeherdermozilla-release@e512c14a0406 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1389314
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1389314 Part3: Temporarily disable the input priority events when dnd is active. r=smaug. MozReview-Commit-ID: AWfYmhjjsq0
dom/ipc/ContentParent.cpp
dom/ipc/TabParent.cpp
widget/nsBaseDragService.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -4446,16 +4446,24 @@ ContentParent::RecvSetOfflinePermission(
   nsIPrincipal* principal = aPrincipal;
   nsContentUtils::MaybeAllowOfflineAppByDefault(principal);
   return IPC_OK();
 }
 
 void
 ContentParent::MaybeInvokeDragSession(TabParent* aParent)
 {
+  // dnd uses IPCBlob to transfer data to the content process and the IPC
+  // message is sent as normal priority. When sending input events with input
+  // priority, the message may be preempted by the later dnd events. To make
+  // sure the input events and the blob message are processed in time order
+  // on the content process, we temporarily send the input events with normal
+  // priority when there is an active dnd session.
+  SetInputPriorityEventEnabled(false);
+
   nsCOMPtr<nsIDragService> dragService =
     do_GetService("@mozilla.org/widget/dragservice;1");
   if (dragService && dragService->MaybeAddChildProcess(this)) {
     // We need to send transferable data to child process.
     nsCOMPtr<nsIDragSession> session;
     dragService->GetCurrentSession(getter_AddRefs(session));
     if (session) {
       nsTArray<IPCDataTransfer> dataTransfers;
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -3303,16 +3303,19 @@ TabParent::RecvInvokeDragSession(nsTArra
 {
   mInitialDataTransferItems.Clear();
   nsIPresShell* shell = mFrameElement->OwnerDoc()->GetShell();
   if (!shell) {
     if (Manager()->IsContentParent()) {
       Unused << Manager()->AsContentParent()->SendEndDragSession(true, true,
                                                                  LayoutDeviceIntPoint(),
                                                                  0);
+      // Continue sending input events with input priority when stopping the dnd
+      // session.
+      Manager()->AsContentParent()->SetInputPriorityEventEnabled(true);
     }
     return IPC_OK();
   }
 
   EventStateManager* esm = shell->GetPresContext()->EventStateManager();
   for (uint32_t i = 0; i < aTransfers.Length(); ++i) {
     mInitialDataTransferItems.AppendElement(mozilla::Move(aTransfers[i].items()));
   }
--- a/widget/nsBaseDragService.cpp
+++ b/widget/nsBaseDragService.cpp
@@ -397,16 +397,19 @@ nsBaseDragService::EndDragSession(bool a
     }
   }
 
   for (uint32_t i = 0; i < mChildProcesses.Length(); ++i) {
     mozilla::Unused << mChildProcesses[i]->SendEndDragSession(aDoneDrag,
                                                               mUserCancelled,
                                                               mEndDragPoint,
                                                               aKeyModifiers);
+    // Continue sending input events with input priority when stopping the dnd
+    // session.
+    mChildProcesses[i]->SetInputPriorityEventEnabled(true);
   }
   mChildProcesses.Clear();
 
   // mDataTransfer and the items it owns are going to die anyway, but we
   // explicitly deref the contained data here so that we don't have to wait for
   // CC to reclaim the memory.
   if (XRE_IsParentProcess()) {
     DiscardInternalTransferData();