From acbe123ece6c1eeda06c9fe6fe5965e1f1171a81 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Wed, 6 Nov 2013 12:06:46 -0800 Subject: [PATCH] Bug 934750 - Don't cancel content touch events unless APZC consumes them [r=jimm,kats] This is necessary for our "cross-slide" hack to work. We need to send input to both content and APZC until the input passes the pan threshold, so that the start page can use touch events without disabling async panning. In the long run we hope to use "touch-action: pan-x" for this and no longer rely on this hack. --- gfx/layers/ipc/AsyncPanZoomController.cpp | 2 +- widget/windows/winrt/MetroInput.cpp | 32 +++++++++++++++-------- widget/windows/winrt/MetroInput.h | 1 + 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/gfx/layers/ipc/AsyncPanZoomController.cpp b/gfx/layers/ipc/AsyncPanZoomController.cpp index 0d363b509c4..45dfb11e80b 100644 --- a/gfx/layers/ipc/AsyncPanZoomController.cpp +++ b/gfx/layers/ipc/AsyncPanZoomController.cpp @@ -383,7 +383,7 @@ nsEventStatus AsyncPanZoomController::ReceiveInputEvent(const InputData& aEvent) PostDelayedTask(mTouchListenerTimeoutTask, gTouchListenerTimeout); } } - return nsEventStatus_eConsumeNoDefault; + return nsEventStatus_eIgnore; } return HandleInputEvent(aEvent); diff --git a/widget/windows/winrt/MetroInput.cpp b/widget/windows/winrt/MetroInput.cpp index a9ace45f9d9..65947328f78 100644 --- a/widget/windows/winrt/MetroInput.cpp +++ b/widget/windows/winrt/MetroInput.cpp @@ -491,6 +491,7 @@ MetroInput::OnPointerPressed(UI::Core::ICoreWindow* aSender, // If this is the first touchstart of a touch session reset some // tracking flags. mContentConsumingTouch = false; + mApzConsumingTouch = false; mRecognizerWantsEvents = true; mCancelable = true; mCanceledIds.Clear(); @@ -1096,7 +1097,9 @@ MetroInput::DeliverNextQueuedTouchEvent() * 3) If mContentConsumingTouch is true: deliver touch to content after * transforming through the apz. Also let the apz know content is * consuming touch. - * 4) If mContentConsumingTouch is false: send a touchcancel to content + * 4) If mContentConsumingTouch is false: check the result from the apz and + * set mApzConsumingTouch appropriately. + * 5) If mApzConsumingTouch is true: send a touchcancel to content * and deliver all events to the apz. If the apz is doing something with * the events we can save ourselves the overhead of delivering dom events. * @@ -1149,7 +1152,6 @@ MetroInput::DeliverNextQueuedTouchEvent() mWidget->ApzContentConsumingTouch(); } else { mWidget->ApzContentIgnoringTouch(); - DispatchTouchCancel(&transformedEvent); } } // If content is consuming touch don't generate any gesture based @@ -1160,22 +1162,30 @@ MetroInput::DeliverNextQueuedTouchEvent() return; } + // Forward event data to apz. Even if content is consuming input, we still + // need APZC to transform the coordinates. It won't actually react to the + // event if ContentReceivedTouch was called previously. + DUMP_TOUCH_IDS("APZC(2)", event); + status = mWidget->ApzReceiveInputEvent(event); + // If content called preventDefault on touchstart or first touchmove send - // the event to content. + // the event to content only. if (mContentConsumingTouch) { - // ContentReceivedTouch has already been called in the mCancelable block - // above so this shouldn't cause the apz to react. We still need to - // transform our coordinates though. - DUMP_TOUCH_IDS("APZC(2)", event); - mWidget->ApzReceiveInputEvent(event); DUMP_TOUCH_IDS("DOM(3)", event); mWidget->DispatchEvent(event, status); return; } - // Forward event data to apz. - DUMP_TOUCH_IDS("APZC(3)", event); - mWidget->ApzReceiveInputEvent(event); + // Send the event to content unless APZC is consuming it. + if (!mApzConsumingTouch) { + if (status == nsEventStatus_eConsumeNoDefault) { + mApzConsumingTouch = true; + DispatchTouchCancel(event); + return; + } + DUMP_TOUCH_IDS("DOM(4)", event); + mWidget->DispatchEvent(event, status); + } } void diff --git a/widget/windows/winrt/MetroInput.h b/widget/windows/winrt/MetroInput.h index d0e2ab0a913..e7383ba47a4 100644 --- a/widget/windows/winrt/MetroInput.h +++ b/widget/windows/winrt/MetroInput.h @@ -203,6 +203,7 @@ private: // For example, a set of mousemove, mousedown, and mouseup events might // be sent if a tap is detected. bool mContentConsumingTouch; + bool mApzConsumingTouch; bool mCancelable; bool mRecognizerWantsEvents; nsTArray mCanceledIds;