void InputQueue::ContentReceivedInputBlock(uint64_t aInputBlockId, bool aPreventDefault) { APZThreadUtils::AssertOnControllerThread(); INPQ_LOG("got a content response; block=%" PRIu64 "\n", aInputBlockId); bool success = false; CancelableBlockState* block = FindBlockForId(aInputBlockId, nullptr); if (block) { success = block->SetContentResponse(aPreventDefault); block->RecordContentResponseTime(); } if (success) { ProcessQueue(); } }
void InputQueue::ContentReceivedInputBlock(uint64_t aInputBlockId, bool aPreventDefault) { APZThreadUtils::AssertOnControllerThread(); INPQ_LOG("got a content response; block=%" PRIu64 "\n", aInputBlockId); bool success = false; for (size_t i = 0; i < mInputBlockQueue.Length(); i++) { if (mInputBlockQueue[i]->GetBlockId() == aInputBlockId) { CancelableBlockState* block = mInputBlockQueue[i].get(); success = block->SetContentResponse(aPreventDefault); break; } } if (success) { ProcessInputBlocks(); } }
void InputQueue::SetAllowedTouchBehavior(uint64_t aInputBlockId, const nsTArray<TouchBehaviorFlags>& aBehaviors) { APZThreadUtils::AssertOnControllerThread(); INPQ_LOG("got allowed touch behaviours; block=%" PRIu64 "\n", aInputBlockId); bool success = false; CancelableBlockState* block = FindBlockForId(aInputBlockId, nullptr); if (block && block->AsTouchBlock()) { success = block->AsTouchBlock()->SetAllowedTouchBehaviors(aBehaviors); block->RecordContentResponseTime(); } else if (block) { NS_WARNING("input block is not a touch block"); } if (success) { ProcessQueue(); } }
void InputQueue::SetConfirmedTargetApzc(uint64_t aInputBlockId, const RefPtr<AsyncPanZoomController>& aTargetApzc) { APZThreadUtils::AssertOnControllerThread(); INPQ_LOG("got a target apzc; block=%" PRIu64 " guid=%s\n", aInputBlockId, aTargetApzc ? Stringify(aTargetApzc->GetGuid()).c_str() : ""); bool success = false; InputData* firstInput = nullptr; CancelableBlockState* block = FindBlockForId(aInputBlockId, &firstInput); if (block) { success = block->SetConfirmedTargetApzc(aTargetApzc, InputBlockState::TargetConfirmationState::eConfirmed, firstInput); block->RecordContentResponseTime(); } if (success) { ProcessQueue(); } }
void InputQueue::MainThreadTimeout(uint64_t aInputBlockId) { APZThreadUtils::AssertOnControllerThread(); INPQ_LOG("got a main thread timeout; block=%" PRIu64 "\n", aInputBlockId); bool success = false; InputData* firstInput = nullptr; CancelableBlockState* block = FindBlockForId(aInputBlockId, &firstInput); if (block) { // time out the touch-listener response and also confirm the existing // target apzc in the case where the main thread doesn't get back to us // fast enough. success = block->TimeoutContentResponse(); success |= block->SetConfirmedTargetApzc( block->GetTargetApzc(), InputBlockState::TargetConfirmationState::eTimedOut, firstInput); } if (success) { ProcessQueue(); } }
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()); }
PanGestureBlockState* InputQueue::GetCurrentPanGestureBlock() const { CancelableBlockState* block = GetCurrentBlock(); return block ? block->AsPanGestureBlock() : mActivePanGestureBlock.get(); }
DragBlockState* InputQueue::GetCurrentDragBlock() const { CancelableBlockState* block = GetCurrentBlock(); return block ? block->AsDragBlock() : mActiveDragBlock.get(); }