From 537e832f5ac7345d9d2ee29c09c27b31867f21a2 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 15 Dec 2014 23:31:12 -0800 Subject: [PATCH] Forward Windows events to APZ directly from nsWindow. (bug 1109985 part 2, r=kats) --- dom/ipc/TabParent.cpp | 15 +++++++++++++++ gfx/layers/apz/src/InputQueue.cpp | 6 +++--- widget/windows/nsWindow.cpp | 13 +++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 919230f1a9e1..e0dcb057a7a3 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -19,6 +19,7 @@ #include "mozilla/Hal.h" #include "mozilla/ipc/DocumentRendererParent.h" #include "mozilla/layers/CompositorParent.h" +#include "mozilla/layers/InputAPZContext.h" #include "mozilla/layout/RenderFrameParent.h" #include "mozilla/MouseEvents.h" #include "mozilla/net/NeckoChild.h" @@ -2103,6 +2104,20 @@ TabParent::MaybeForwardEventToRenderFrame(WidgetInputEvent& aEvent, ScrollableLayerGuid* aOutTargetGuid, uint64_t* aOutInputBlockId) { + if (aEvent.mClass == eWheelEventClass) { + // Wheel events must be sent to APZ directly from the widget. New APZ- + // aware events should follow suit and move there as well. However, we + // do need to inform the child process of the correct target and block + // id. + if (aOutTargetGuid) { + *aOutTargetGuid = InputAPZContext::GetTargetLayerGuid(); + } + if (aOutInputBlockId) { + *aOutInputBlockId = InputAPZContext::GetInputBlockId(); + } + return nsEventStatus_eIgnore; + } + if (RenderFrameParent* rfp = GetRenderFrame()) { return rfp->NotifyInputEvent(aEvent, aOutTargetGuid, aOutInputBlockId); } diff --git a/gfx/layers/apz/src/InputQueue.cpp b/gfx/layers/apz/src/InputQueue.cpp index 3cc424aafe19..51275ab69be2 100644 --- a/gfx/layers/apz/src/InputQueue.cpp +++ b/gfx/layers/apz/src/InputQueue.cpp @@ -55,8 +55,8 @@ InputQueue::ReceiveInputEvent(const nsRefPtr& aTarget, bool InputQueue::MaybeHandleCurrentBlock(const nsRefPtr& aTarget, - CancelableBlockState *block, - const InputData& aEvent) { + CancelableBlockState *block, + const InputData& aEvent) { if (block == CurrentBlock() && block->IsReadyForHandling()) { INPQ_LOG("current block is ready with target %p preventdefault %d\n", aTarget.get(), block->IsDefaultPrevented()); @@ -162,7 +162,7 @@ InputQueue::ReceiveScrollWheelInput(const nsRefPtr& aTar block->AddEvent(aEvent.AsScrollWheelInput()); } - return nsEventStatus_eIgnore; + return nsEventStatus_eConsumeDoDefault; } void diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index d0b9820f8217..1d56e9533f77 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -187,6 +187,7 @@ #endif #include "mozilla/layers/APZCTreeManager.h" +#include "mozilla/layers/InputAPZContext.h" using namespace mozilla; using namespace mozilla::dom; @@ -3741,6 +3742,18 @@ bool nsWindow::DispatchKeyboardEvent(WidgetGUIEvent* event) bool nsWindow::DispatchScrollEvent(WidgetGUIEvent* aEvent) { + uint64_t inputBlockId = 0; + ScrollableLayerGuid guid; + + if (mAPZC && aEvent->mClass == eWheelEventClass) { + nsEventStatus status = mAPZC->ReceiveInputEvent(*aEvent->AsWheelEvent(), &guid, &inputBlockId); + if (status == nsEventStatus_eConsumeNoDefault) { + return true; + } + } + + InputAPZContext context(guid, inputBlockId); + nsEventStatus status; DispatchEvent(aEvent, status); return ConvertStatus(status);