Bug 1272757 - Fix drag handling so that drag inputs don't get stuck waiting for content response while running tests. r=rbarker
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 13 May 2016 21:48:23 -0400
changeset 367078 db473770c2eb45fb5fe70342571f7152f44a00fb
parent 367077 837ef3fa5ae3b80d86081a2d00ae464a5ccdfc51
child 367079 962463926b903521f4872a4e810da4eb20d7ad6c
push id18132
push userkevin.m.wern@gmail.com
push dateSat, 14 May 2016 04:10:50 +0000
reviewersrbarker
bugs1272757
milestone49.0a1
Bug 1272757 - Fix drag handling so that drag inputs don't get stuck waiting for content response while running tests. r=rbarker 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,