diff --git a/widget/gonk/nsWindow.cpp b/widget/gonk/nsWindow.cpp index 509dc5b05d5..20f6d912123 100644 --- a/widget/gonk/nsWindow.cpp +++ b/widget/gonk/nsWindow.cpp @@ -326,7 +326,7 @@ nsWindow::DispatchTouchEventForAPZ(const MultiTouchInput& aInput, // for "normal" flow. The event might get sent to the child process still, // but if it doesn't we need to notify the APZ of various things. All of // that happens in DispatchEventForAPZ - DispatchEventForAPZ(&event, aGuid, aInputBlockId); + ProcessUntransformedAPZEvent(&event, aGuid, aInputBlockId); } class DispatchTouchInputOnControllerThread : public Task diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index 49066bef883..a91b63515a2 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -3255,19 +3255,7 @@ nsWindow::OnScrollEvent(GdkEventScroll *aEvent) wheelEvent.time = aEvent->time; - if (mAPZC) { - uint64_t inputBlockId = 0; - ScrollableLayerGuid guid; - - nsEventStatus result = mAPZC->ReceiveInputEvent(*wheelEvent.AsWheelEvent(), &guid, &inputBlockId); - if (result == nsEventStatus_eConsumeNoDefault) { - return; - } - DispatchEventForAPZ(&wheelEvent, guid, inputBlockId); - } else { - nsEventStatus status; - DispatchEvent(&wheelEvent, status); - } + DispatchAPZAwareEvent(&wheelEvent); } void diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 5675f20a1a5..9eb28e189bb 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -973,9 +973,9 @@ void nsBaseWidget::ConfigureAPZCTreeManager() } nsEventStatus -nsBaseWidget::DispatchEventForAPZ(WidgetGUIEvent* aEvent, - const ScrollableLayerGuid& aGuid, - uint64_t aInputBlockId) +nsBaseWidget::ProcessUntransformedAPZEvent(WidgetInputEvent* aEvent, + const ScrollableLayerGuid& aGuid, + uint64_t aInputBlockId) { MOZ_ASSERT(NS_IsMainThread()); InputAPZContext context(aGuid, aInputBlockId); @@ -1015,6 +1015,25 @@ nsBaseWidget::DispatchEventForAPZ(WidgetGUIEvent* aEvent, return status; } +nsEventStatus +nsBaseWidget::DispatchAPZAwareEvent(WidgetInputEvent* aEvent) +{ + if (mAPZC) { + uint64_t inputBlockId = 0; + ScrollableLayerGuid guid; + + nsEventStatus result = mAPZC->ReceiveInputEvent(*aEvent, &guid, &inputBlockId); + if (result == nsEventStatus_eConsumeNoDefault) { + return result; + } + return ProcessUntransformedAPZEvent(aEvent, guid, inputBlockId); + } + + nsEventStatus status; + DispatchEvent(aEvent, status); + return status; +} + void nsBaseWidget::GetPreferredCompositorBackends(nsTArray& aHints) { diff --git a/widget/nsBaseWidget.h b/widget/nsBaseWidget.h index 5dbf2430f1e..220197d5637 100644 --- a/widget/nsBaseWidget.h +++ b/widget/nsBaseWidget.h @@ -232,6 +232,9 @@ public: NS_IMETHOD UnregisterTouchWindow() MOZ_OVERRIDE; NS_IMETHOD_(TextEventDispatcher*) GetTextEventDispatcher() MOZ_OVERRIDE MOZ_FINAL; + // Dispatch an event that must be first be routed through APZ. + nsEventStatus DispatchAPZAwareEvent(mozilla::WidgetInputEvent* aEvent) MOZ_OVERRIDE; + void NotifyWindowDestroyed(); void NotifySizeMoveDone(); void NotifyWindowMoved(int32_t aX, int32_t aY); @@ -327,11 +330,10 @@ protected: virtual void ConfigureAPZCTreeManager(); virtual already_AddRefed CreateRootContentController(); - // Dispatch an event that has been routed through APZ directly from the - // widget. - nsEventStatus DispatchEventForAPZ(mozilla::WidgetGUIEvent* aEvent, - const ScrollableLayerGuid& aGuid, - uint64_t aInputBlockId); + // Dispatch an event that has already been routed through APZ. + nsEventStatus ProcessUntransformedAPZEvent(mozilla::WidgetInputEvent* aEvent, + const ScrollableLayerGuid& aGuid, + uint64_t aInputBlockId); const nsIntRegion RegionFromArray(const nsTArray& aRects); void ArrayFromRegion(const nsIntRegion& aRegion, nsTArray& aRects); diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index 10bde973a5d..ebc13959482 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -1687,6 +1687,13 @@ class nsIWidget : public nsISupports { NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* event, nsEventStatus & aStatus) = 0; + /** + * Dispatches an event that must be handled by APZ first, when APZ is + * enabled. If invoked in the child process, it is forwarded to the + * parent process synchronously. + */ + virtual nsEventStatus DispatchAPZAwareEvent(mozilla::WidgetInputEvent* aEvent) = 0; + /** * Enables the dropping of files to a widget (XXX this is temporary) * diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index b0ad604e4bb..e964e49345e 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -3666,20 +3666,13 @@ bool nsWindow::DispatchKeyboardEvent(WidgetGUIEvent* event) bool nsWindow::DispatchScrollEvent(WidgetGUIEvent* aEvent) { - nsEventStatus status; - - if (mAPZC && aEvent->mClass == eWheelEventClass) { - uint64_t inputBlockId = 0; - ScrollableLayerGuid guid; - - nsEventStatus result = mAPZC->ReceiveInputEvent(*aEvent->AsWheelEvent(), &guid, &inputBlockId); - if (result == nsEventStatus_eConsumeNoDefault) { - return true; - } - status = DispatchEventForAPZ(aEvent, guid, inputBlockId); - } else { + if (aEvent->mClass != eWheelEventClass) { + nsEventStatus status; DispatchEvent(aEvent, status); + return ConvertStatus(status); } + + nsEventStatus status = DispatchAPZAwareEvent(aEvent->AsInputEvent()); return ConvertStatus(status); }