mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
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:
parent
ebadfda552
commit
713c58caee
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user