bool InputQueue::MaybeHandleCurrentBlock(CancelableBlockState *block, const InputData& aEvent) { if (block == CurrentBlock() && block->IsReadyForHandling()) { const RefPtr<AsyncPanZoomController>& target = block->GetTargetApzc(); INPQ_LOG("current block is ready with target %p preventdefault %d\n", target.get(), block->IsDefaultPrevented()); if (!target || block->IsDefaultPrevented()) { return true; } UpdateActiveApzc(block->GetTargetApzc()); block->DispatchImmediate(aEvent); return true; } return false; }
void InputQueue::ProcessQueue() { APZThreadUtils::AssertOnControllerThread(); while (!mQueuedInputs.IsEmpty()) { CancelableBlockState* curBlock = mQueuedInputs[0]->Block(); if (!curBlock->IsReadyForHandling()) { break; } INPQ_LOG("processing input from block %p; preventDefault %d target %p\n", curBlock, curBlock->IsDefaultPrevented(), curBlock->GetTargetApzc().get()); RefPtr<AsyncPanZoomController> target = curBlock->GetTargetApzc(); // target may be null here if the initial target was unconfirmed and then // we later got a confirmed null target. in that case drop the events. if (target) { if (curBlock->IsDefaultPrevented()) { if (curBlock->AsTouchBlock()) { target->ResetTouchInputState(); } } else { UpdateActiveApzc(target); curBlock->DispatchEvent(*(mQueuedInputs[0]->Input())); } } mQueuedInputs.RemoveElementAt(0); } if (CanDiscardBlock(mActiveTouchBlock)) { mActiveTouchBlock = nullptr; } if (CanDiscardBlock(mActiveWheelBlock)) { mActiveWheelBlock = nullptr; } if (CanDiscardBlock(mActiveDragBlock)) { mActiveDragBlock = nullptr; } if (CanDiscardBlock(mActivePanGestureBlock)) { mActivePanGestureBlock = nullptr; } }
void InputQueue::ProcessInputBlocks() { APZThreadUtils::AssertOnControllerThread(); do { CancelableBlockState* curBlock = CurrentBlock(); if (!curBlock->IsReadyForHandling()) { break; } INPQ_LOG("processing input block %p; preventDefault %d target %p\n", curBlock, curBlock->IsDefaultPrevented(), curBlock->GetTargetApzc().get()); RefPtr<AsyncPanZoomController> target = curBlock->GetTargetApzc(); // target may be null here if the initial target was unconfirmed and then // we later got a confirmed null target. in that case drop the events. if (!target) { curBlock->DropEvents(); } else if (curBlock->IsDefaultPrevented()) { curBlock->DropEvents(); target->ResetInputState(); } else { UpdateActiveApzc(curBlock->GetTargetApzc()); curBlock->HandleEvents(); } MOZ_ASSERT(!curBlock->HasEvents()); if (mInputBlockQueue.Length() == 1 && curBlock->MustStayActive()) { // Some types of blocks (e.g. touch blocks) accumulate events until the // next input block is started. Therefore we cannot remove the block from // the queue until we have started another block. This block will be // removed by SweepDeletedBlocks() whenever a new block is added. break; } // If we get here, we know there are more touch blocks in the queue after // |curBlock|, so we can remove |curBlock| and try to process the next one. INPQ_LOG("discarding processed %s block %p\n", curBlock->Type(), curBlock); mInputBlockQueue.RemoveElementAt(0); } while (!mInputBlockQueue.IsEmpty()); }