WheelBlockState* InputQueue::GetActiveWheelTransaction() const { WheelBlockState* block = mActiveWheelBlock.get(); if (!block || !block->InTransaction()) { return nullptr; } return block; }
WheelBlockState* InputQueue::GetCurrentWheelTransaction() const { if (mInputBlockQueue.IsEmpty()) { return nullptr; } WheelBlockState* block = CurrentBlock()->AsWheelBlock(); if (!block || !block->InTransaction()) { return nullptr; } return block; }
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; } } MOZ_ASSERT(!block || block->InTransaction()); if (!block) { block = new WheelBlockState(aTarget, aTargetConfirmed, aEvent); INPQ_LOG("started new scroll wheel block %p for target %p\n", block, aTarget.get()); SweepDepletedBlocks(); mInputBlockQueue.AppendElement(block); CancelAnimationsForNewBlock(block); MaybeRequestContentResponse(aTarget, block); } else { INPQ_LOG("received new event in block %p\n", block); } if (aOutInputBlockId) { *aOutInputBlockId = block->GetBlockId(); } block->Update(aEvent); // Note that the |aTarget| the APZCTM sent us may contradict the confirmed // target set on the block. In this case the confirmed target (which may be // null) should take priority. This is equivalent to just always using the // target (confirmed or not) from the block, which is what // MaybeHandleCurrentBlock() does. if (!MaybeHandleCurrentBlock(block, aEvent)) { block->AddEvent(aEvent.AsScrollWheelInput()); } return nsEventStatus_eConsumeDoDefault; }
nsEventStatus InputQueue::ReceiveScrollWheelInput(const RefPtr<AsyncPanZoomController>& aTarget, bool aTargetConfirmed, const ScrollWheelInput& aEvent, uint64_t* aOutInputBlockId) { 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()); mActiveWheelBlock = block; CancelAnimationsForNewBlock(block); MaybeRequestContentResponse(aTarget, block); } else { INPQ_LOG("received new event in block %p\n", block); } if (aOutInputBlockId) { *aOutInputBlockId = block->GetBlockId(); } // Note that the |aTarget| the APZCTM sent us may contradict the confirmed // target set on the block. In this case the confirmed target (which may be // null) should take priority. This is equivalent to just always using the // target (confirmed or not) from the block, which is what // ProcessQueue() does. mQueuedInputs.AppendElement(MakeUnique<QueuedInput>(aEvent, *block)); // The WheelBlockState needs to affix a counter to the event before we process // it. Note that the counter is affixed to the copy in the queue rather than // |aEvent|. block->Update(mQueuedInputs.LastElement()->Input()->AsScrollWheelInput()); ProcessQueue(); return nsEventStatus_eConsumeDoDefault; }