Bug 1289432 - Switch over to using the mActiveXXXBlock in some places instead of fishing around in mInputBlockQueue. r?botond draft
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 12 Sep 2016 22:42:17 -0400
changeset 412857 494cbf7104e52726d47d15e92cd04f2d57b7523d
parent 412856 3f2e93c1c88709d499e2db8c7bf93118f12e6581
child 412858 cd4a6dd405544674ef45e856e6cfc6c9f3a9c0e7
push id29274
push userkgupta@mozilla.com
push dateTue, 13 Sep 2016 02:44:31 +0000
reviewersbotond
bugs1289432
milestone51.0a1
Bug 1289432 - Switch over to using the mActiveXXXBlock in some places instead of fishing around in mInputBlockQueue. r?botond MozReview-Commit-ID: 89ENbxVxXrt
gfx/layers/apz/src/InputQueue.cpp
--- a/gfx/layers/apz/src/InputQueue.cpp
+++ b/gfx/layers/apz/src/InputQueue.cpp
@@ -89,23 +89,23 @@ InputQueue::ReceiveTouchInput(const RefP
                               const MultiTouchInput& aEvent,
                               uint64_t* aOutInputBlockId) {
   TouchBlockState* block = nullptr;
   if (aEvent.mType == MultiTouchInput::MULTITOUCH_START) {
     nsTArray<TouchBehaviorFlags> currentBehaviors;
     bool haveBehaviors = false;
     if (!gfxPrefs::TouchActionEnabled()) {
       haveBehaviors = true;
-    } else if (!mInputBlockQueue.IsEmpty() && CurrentBlock()->AsTouchBlock()) {
-      haveBehaviors = CurrentTouchBlock()->GetAllowedTouchBehaviors(currentBehaviors);
+    } else if (mActiveTouchBlock) {
+      haveBehaviors = mActiveTouchBlock->GetAllowedTouchBehaviors(currentBehaviors);
       // If the behaviours aren't set, but the main-thread response timer on
       // the block is expired we still treat it as though it has behaviors,
       // because in that case we still want to interrupt the fast-fling and
       // use the default behaviours.
-      haveBehaviors |= CurrentTouchBlock()->IsContentResponseTimerExpired();
+      haveBehaviors |= mActiveTouchBlock->IsContentResponseTimerExpired();
     }
 
     block = StartNewTouchBlock(aTarget, aTargetConfirmed, false);
     INPQ_LOG("started new touch block %p id %" PRIu64 " for target %p\n",
         block, block->GetBlockId(), aTarget.get());
 
     // XXX using the chain from |block| here may be wrong in cases where the
     // target isn't confirmed and the real target turns out to be something
@@ -127,20 +127,17 @@ InputQueue::ReceiveTouchInput(const RefP
       }
       INPQ_LOG("block %p tagged as fast-motion\n", block);
     }
 
     CancelAnimationsForNewBlock(block);
 
     MaybeRequestContentResponse(aTarget, block);
   } else {
-    if (!mInputBlockQueue.IsEmpty()) {
-      block = mInputBlockQueue.LastElement().get()->AsTouchBlock();
-    }
-
+    block = mActiveTouchBlock.get();
     if (!block) {
       NS_WARNING("Received a non-start touch event while no touch blocks active!");
       return nsEventStatus_eIgnore;
     }
 
     INPQ_LOG("received new event in block %p\n", block);
   }
 
@@ -184,21 +181,17 @@ nsEventStatus
 InputQueue::ReceiveMouseInput(const RefPtr<AsyncPanZoomController>& aTarget,
                               bool aTargetConfirmed,
                               const MouseInput& aEvent,
                               uint64_t* aOutInputBlockId) {
   // 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();
-  }
-
+  DragBlockState* block = newBlock ? nullptr : mActiveDragBlock.get();
   if (block && block->HasReceivedMouseUp()) {
     block = nullptr;
   }
 
   if (!block && mDragTracker.InDrag()) {
     // If there's no current drag block, but we're getting a move with a button
     // down, we need to start a new drag block because we're obviously already
     // in the middle of a drag (it probably got interrupted by something else).
@@ -247,28 +240,24 @@ InputQueue::ReceiveMouseInput(const RefP
   return nsEventStatus_eConsumeDoDefault;
 }
 
 nsEventStatus
 InputQueue::ReceiveScrollWheelInput(const RefPtr<AsyncPanZoomController>& aTarget,
                                     bool aTargetConfirmed,
                                     const ScrollWheelInput& aEvent,
                                     uint64_t* aOutInputBlockId) {
-  WheelBlockState* block = nullptr;
-  if (!mInputBlockQueue.IsEmpty()) {
-    block = mInputBlockQueue.LastElement()->AsWheelBlock();
-
-    // If the block is not accepting new events we'll create a new input block
-    // (and therefore a new wheel transaction).
-    if (block &&
-        (!block->ShouldAcceptNewEvent() ||
-         block->MaybeTimeout(aEvent)))
-    {
-      block = nullptr;
-    }
+  WheelBlockState* block = mActiveWheelBlock.get();
+  // If the block is not accepting new events we'll create a new input block
+  // (and therefore a new wheel transaction).
+  if (block &&
+      (!block->ShouldAcceptNewEvent() ||
+       block->MaybeTimeout(aEvent)))
+  {
+    block = nullptr;
   }
 
   MOZ_ASSERT(!block || block->InTransaction());
 
   if (!block) {
     block = new WheelBlockState(aTarget, aTargetConfirmed, aEvent);
     INPQ_LOG("started new scroll wheel block %p id %" PRIu64 " for target %p\n",
         block, block->GetBlockId(), aTarget.get());
@@ -322,19 +311,18 @@ InputQueue::ReceivePanGestureInput(const
                                    uint64_t* aOutInputBlockId) {
   if (aEvent.mType == PanGestureInput::PANGESTURE_MAYSTART ||
       aEvent.mType == PanGestureInput::PANGESTURE_CANCELLED) {
     // Ignore these events for now.
     return nsEventStatus_eConsumeDoDefault;
   }
 
   PanGestureBlockState* block = nullptr;
-  if (!mInputBlockQueue.IsEmpty() &&
-      aEvent.mType != PanGestureInput::PANGESTURE_START) {
-    block = mInputBlockQueue.LastElement()->AsPanGestureBlock();
+  if (aEvent.mType != PanGestureInput::PANGESTURE_START) {
+    block = mActivePanGestureBlock.get();
   }
 
   PanGestureInput event = aEvent;
   nsEventStatus result = nsEventStatus_eConsumeDoDefault;
 
   if (!block || block->WasInterrupted()) {
     if (event.mType != PanGestureInput::PANGESTURE_START) {
       // Only PANGESTURE_START events are allowed to start a new pan gesture
@@ -520,20 +508,17 @@ InputQueue::CurrentPanGestureBlock() con
   PanGestureBlockState* block = CurrentBlock()->AsPanGestureBlock();
   MOZ_ASSERT(block);
   return block;
 }
 
 WheelBlockState*
 InputQueue::GetCurrentWheelTransaction() const
 {
-  if (mInputBlockQueue.IsEmpty()) {
-    return nullptr;
-  }
-  WheelBlockState* block = CurrentBlock()->AsWheelBlock();
+  WheelBlockState* block = mActiveWheelBlock.get();
   if (!block || !block->InTransaction()) {
     return nullptr;
   }
   return block;
 }
 
 bool
 InputQueue::HasReadyTouchBlock() const