Bug 1289435 - Extract a helper function to dispatch MultiTouchInput to APZ if applicable and then to Gecko. r=mstange

This also modifies the windows widget code to use this new helper function, as
it avoids an unnecessary round-trip where a MultiTouchInput gets converted to
a WidgetTouchEvent (in nsWindow.cpp) and then back to a MultiTouchInput (in
APZCTreeManager.cpp)

MozReview-Commit-ID: 1WGbfINTW6c
This commit is contained in:
Kartikaya Gupta 2016-08-03 12:06:58 -04:00
parent ebadfda552
commit 713c58caee
4 changed files with 36 additions and 26 deletions

View File

@ -1211,26 +1211,8 @@ nsresult nsChildView::SynthesizeNativeTouchPoint(uint32_t aPointerId,
mSynthesizedTouchInput.get(), PR_IntervalNow(), TimeStamp::Now(),
aPointerId, aPointerState, pointInWindow, aPointerPressure,
aPointerOrientation);
if (mAPZC) {
uint64_t inputBlockId = 0;
ScrollableLayerGuid guid;
nsEventStatus result = mAPZC->ReceiveInputEvent(inputToDispatch, &guid, &inputBlockId);
if (result == nsEventStatus_eConsumeNoDefault) {
return NS_OK;
}
WidgetTouchEvent event = inputToDispatch.ToWidgetTouchEvent(this);
ProcessUntransformedAPZEvent(&event, guid, inputBlockId, result);
} else {
WidgetTouchEvent event = inputToDispatch.ToWidgetTouchEvent(this);
nsEventStatus status;
DispatchEvent(&event, status);
}
return NS_OK;;
DispatchTouchInput(inputToDispatch);
return NS_OK;
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
}

View File

@ -1213,6 +1213,30 @@ private:
ScrollableLayerGuid mGuid;
};
void
nsBaseWidget::DispatchTouchInput(MultiTouchInput& aInput)
{
MOZ_ASSERT(NS_IsMainThread());
if (mAPZC) {
MOZ_ASSERT(APZThreadUtils::IsControllerThread());
uint64_t inputBlockId = 0;
ScrollableLayerGuid guid;
nsEventStatus result = mAPZC->ReceiveInputEvent(aInput, &guid, &inputBlockId);
if (result == nsEventStatus_eConsumeNoDefault) {
return;
}
WidgetTouchEvent event = aInput.ToWidgetTouchEvent(this);
ProcessUntransformedAPZEvent(&event, guid, inputBlockId, result);
} else {
WidgetTouchEvent event = aInput.ToWidgetTouchEvent(this);
nsEventStatus status;
DispatchEvent(&event, status);
}
}
nsEventStatus
nsBaseWidget::DispatchInputEvent(WidgetInputEvent* aEvent)
{

View File

@ -576,6 +576,14 @@ protected:
double aPointerPressure,
uint32_t aPointerOrientation);
/**
* Dispatch the given MultiTouchInput through APZ to Gecko (if APZ is enabled)
* or directly to gecko (if APZ is not enabled). This function must only
* be called from the main thread, and if APZ is enabled, that must also be
* the APZ controller thread.
*/
void DispatchTouchInput(mozilla::MultiTouchInput& aInput);
#if defined(XP_WIN)
void UpdateScrollCapture() override;

View File

@ -6547,15 +6547,11 @@ bool nsWindow::OnTouch(WPARAM wParam, LPARAM lParam)
// Dispatch touch start and touch move event if we have one.
if (!touchInput.mTimeStamp.IsNull()) {
// Convert MultiTouchInput to WidgetTouchEvent interface.
WidgetTouchEvent widgetTouchEvent = touchInput.ToWidgetTouchEvent(this);
DispatchInputEvent(&widgetTouchEvent);
DispatchTouchInput(touchInput);
}
// Dispatch touch end event if we have one.
if (!touchEndInput.mTimeStamp.IsNull()) {
// Convert MultiTouchInput to WidgetTouchEvent interface.
WidgetTouchEvent widgetTouchEvent = touchEndInput.ToWidgetTouchEvent(this);
DispatchInputEvent(&widgetTouchEvent);
DispatchTouchInput(touchEndInput);
}
}