void InputQueue::SweepDepletedBlocks() { // We're going to start a new block, so clear out any depleted blocks at the head of the queue. // See corresponding comment in ProcessInputBlocks. while (!mInputBlockQueue.IsEmpty()) { CancelableBlockState* block = mInputBlockQueue[0].get(); if (!block->IsReadyForHandling() || block->HasEvents()) { break; } INPQ_LOG("discarding depleted %s block %p\n", block->Type(), block); mInputBlockQueue.RemoveElementAt(0); } }
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()); }