Bug 1272757 - Fix drag handling so that drag inputs don't get stuck waiting for content response while running tests. r=rbarker, a=sylvestre
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 13 May 2016 21:48:23 -0400
changeset 333122 0389431b7aad9c3d97d58e58f4ffc35ff2ac06d5
parent 333121 433520b687b76bc6332bf080db94b01ebf4ef881
child 333123 f2a42f8eda64ebda82a08b542df7d30082859b02
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrbarker, sylvestre
bugs1272757
milestone48.0a2
Bug 1272757 - Fix drag handling so that drag inputs don't get stuck waiting for content response while running tests. r=rbarker, a=sylvestre MozReview-Commit-ID: Lsn5nFNcP7k
gfx/layers/apz/src/APZCTreeManager.cpp
gfx/layers/apz/src/InputQueue.cpp
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -691,19 +691,25 @@ APZCTreeManager::ReceiveInputEvent(Input
 
       // When the mouse is outside the window we still want to handle dragging
       // but we won't find an APZC. Fallback to root APZC then.
       if (!apzc && mRootNode) {
         apzc = mRootNode->GetApzc();
       }
 
       if (apzc) {
+        bool targetConfirmed = (hitResult == HitLayer);
+        if (gfxPrefs::APZDragEnabled() && hitScrollbar) {
+          // If scrollbar dragging is enabled and we hit a scrollbar, wait
+          // for the main-thread confirmation because it contains drag metrics
+          // that we need.
+          targetConfirmed = false;
+        }
         result = mInputQueue->ReceiveInputEvent(
-          apzc,
-          /* aTargetConfirmed = */ false,
+          apzc, targetConfirmed,
           mouseInput, aOutInputBlockId);
 
         if (result == nsEventStatus_eConsumeDoDefault) {
           // This input event is part of a drag block, so whether or not it is
           // directed at a scrollbar depends on whether the drag block started
           // on a scrollbar.
           hitScrollbar = mInputQueue->IsDragOnScrollbar(hitScrollbar);
         }
--- a/gfx/layers/apz/src/InputQueue.cpp
+++ b/gfx/layers/apz/src/InputQueue.cpp
@@ -177,18 +177,16 @@ InputQueue::ReceiveTouchInput(const RefP
   return result;
 }
 
 nsEventStatus
 InputQueue::ReceiveMouseInput(const RefPtr<AsyncPanZoomController>& aTarget,
                               bool aTargetConfirmed,
                               const MouseInput& aEvent,
                               uint64_t* aOutInputBlockId) {
-  MOZ_ASSERT(!aTargetConfirmed); // We wont know the target until content tells us
-
   // On a new mouse down we can have a new target so we must force a new block
   // with a new target.
   bool newBlock = DragTracker::StartsDrag(aEvent);
 
   DragBlockState* block = nullptr;
   if (!newBlock && !mInputBlockQueue.IsEmpty()) {
     block = mInputBlockQueue.LastElement()->AsDragBlock();
   }
@@ -211,48 +209,40 @@ InputQueue::ReceiveMouseInput(const RefP
     // This input event is not in a drag block, so we're not doing anything
     // with it, return eIgnore.
     return nsEventStatus_eIgnore;
   }
 
   if (!block) {
     MOZ_ASSERT(newBlock);
     block = new DragBlockState(aTarget, aTargetConfirmed, aEvent);
-    if (aOutInputBlockId) {
-      *aOutInputBlockId = block->GetBlockId();
-    }
 
-    INPQ_LOG("started new drag block %p id %" PRIu64 " for target %p\n",
-        block, block->GetBlockId(), aTarget.get());
+    INPQ_LOG("started new drag block %p id %" PRIu64 " for %sconfirmed target %p\n",
+        block, block->GetBlockId(), aTargetConfirmed ? "" : "un", aTarget.get());
 
     SweepDepletedBlocks();
     mInputBlockQueue.AppendElement(block);
 
     CancelAnimationsForNewBlock(block);
     MaybeRequestContentResponse(aTarget, block);
-
-    block->AddEvent(aEvent.AsMouseInput());
-
-    // This input event created a new drag block, so return DoDefault.
-    return nsEventStatus_eConsumeDoDefault;
   }
 
   if (aOutInputBlockId) {
     *aOutInputBlockId = block->GetBlockId();
   }
 
   if (!MaybeHandleCurrentBlock(block, aEvent)) {
     block->AddEvent(aEvent.AsMouseInput());
   }
 
   if (DragTracker::EndsDrag(aEvent)) {
     block->MarkMouseUpReceived();
   }
 
-  // The event was added to the drag block and could potentially cause
+  // The event is part of a drag block and could potentially cause
   // scrolling, so return DoDefault.
   return nsEventStatus_eConsumeDoDefault;
 }
 
 nsEventStatus
 InputQueue::ReceiveScrollWheelInput(const RefPtr<AsyncPanZoomController>& aTarget,
                                     bool aTargetConfirmed,
                                     const ScrollWheelInput& aEvent,