Skip to content
Snippets Groups Projects
Commit e494dee6 authored by Kartikaya Gupta's avatar Kartikaya Gupta
Browse files

Bug 1289432 - Switch over to using the mActiveXXXBlock in some places instead...

Bug 1289432 - Switch over to using the mActiveXXXBlock in some places instead of fishing around in mInputBlockQueue. r=botond

Note that this patch has a subtle functional change because the mActiveXXXBlock
variables can remain non-null even if there are no blocks in mInputBlockQueue.
In fact, this patch contains the secret sauce that allows the input queue to
handle interleaved input events, because this ensures that the interleaved events
end up getting associated with the pre-existing active block rather than creating
a new one.

MozReview-Commit-ID: 7GkbSe9IaC4
parent 19ed146d
No related branches found
No related tags found
No related merge requests found
......@@ -94,13 +94,13 @@ InputQueue::ReceiveTouchInput(const RefPtr<AsyncPanZoomController>& aTarget,
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);
......@@ -132,10 +132,7 @@ InputQueue::ReceiveTouchInput(const RefPtr<AsyncPanZoomController>& aTarget,
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;
......@@ -189,11 +186,7 @@ InputQueue::ReceiveMouseInput(const RefPtr<AsyncPanZoomController>& aTarget,
// 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;
}
......@@ -252,18 +245,14 @@ InputQueue::ReceiveScrollWheelInput(const RefPtr<AsyncPanZoomController>& aTarge
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());
......@@ -327,9 +316,8 @@ InputQueue::ReceivePanGestureInput(const RefPtr<AsyncPanZoomController>& aTarget
}
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;
......@@ -525,10 +513,7 @@ InputQueue::CurrentPanGestureBlock() const
WheelBlockState*
InputQueue::GetCurrentWheelTransaction() const
{
if (mInputBlockQueue.IsEmpty()) {
return nullptr;
}
WheelBlockState* block = CurrentBlock()->AsWheelBlock();
WheelBlockState* block = mActiveWheelBlock.get();
if (!block || !block->InTransaction()) {
return nullptr;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment