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.
This commit is contained in:
Matt Brubeck 2013-11-06 12:06:46 -08:00
Родитель 54a63a2b83
Коммит ee433d829f
3 изменённых файлов: 23 добавлений и 12 удалений

Просмотреть файл

@ -383,7 +383,7 @@ nsEventStatus AsyncPanZoomController::ReceiveInputEvent(const InputData& aEvent)
PostDelayedTask(mTouchListenerTimeoutTask, gTouchListenerTimeout);
}
}
return nsEventStatus_eConsumeNoDefault;
return nsEventStatus_eIgnore;
}
return HandleInputEvent(aEvent);

Просмотреть файл

@ -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;
}
// If content called preventDefault on touchstart or first touchmove send
// the event to content.
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.
// 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);
mWidget->ApzReceiveInputEvent(event);
status = mWidget->ApzReceiveInputEvent(event);
// If content called preventDefault on touchstart or first touchmove send
// the event to content only.
if (mContentConsumingTouch) {
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

Просмотреть файл

@ -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<uint32_t> mCanceledIds;