Forward Windows events to APZ directly from nsWindow. (bug 1109985 part 2, r=kats)
authorDavid Anderson <danderson@mozilla.com>
Mon, 15 Dec 2014 23:31:12 -0800
changeset 220221 358dc1ca192b0a4629c409867ea7db34a4e1c3e3
parent 220220 91fd3f8df7edaa5a63d01f3843fafeae14ad7b1a
child 220222 9bfe7b78b4c5f3953b3e6e4930d6c77963d6d32e
push id10457
push userryanvm@gmail.com
push dateThu, 18 Dec 2014 01:54:25 +0000
treeherderfx-team@0e441ff66c5e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1109985
milestone37.0a1
Forward Windows events to APZ directly from nsWindow. (bug 1109985 part 2, r=kats)
dom/ipc/TabParent.cpp
gfx/layers/apz/src/InputQueue.cpp
widget/windows/nsWindow.cpp
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -14,16 +14,17 @@
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/PContentPermissionRequestParent.h"
 #include "mozilla/dom/indexedDB/ActorsParent.h"
 #include "mozilla/plugins/PluginWidgetParent.h"
 #include "mozilla/EventStateManager.h"
 #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"
 #include "mozilla/Preferences.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TouchEvents.h"
 #include "mozilla/unused.h"
 #include "nsCOMPtr.h"
@@ -2098,16 +2099,30 @@ TabParent::UseAsyncPanZoom()
           GetScrollingBehavior() == ASYNC_PAN_ZOOM);
 }
 
 nsEventStatus
 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);
   }
   return nsEventStatus_eIgnore;
 }
 
 bool
 TabParent::RecvBrowserFrameOpenWindow(PBrowserParent* aOpener,
--- a/gfx/layers/apz/src/InputQueue.cpp
+++ b/gfx/layers/apz/src/InputQueue.cpp
@@ -50,18 +50,18 @@ InputQueue::ReceiveInputEvent(const nsRe
       // TODO (bug 1098430): we will eventually need to have smarter handling for
       // non-touch events as well.
       return aTarget->HandleInputEvent(aEvent);
   }
 }
 
 bool
 InputQueue::MaybeHandleCurrentBlock(const nsRefPtr<AsyncPanZoomController>& 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());
     if (!aTarget || block->IsDefaultPrevented()) {
       return true;
     }
     aTarget->HandleInputEvent(aEvent);
     return true;
@@ -157,17 +157,17 @@ InputQueue::ReceiveScrollWheelInput(cons
   // null) should take priority. This is equivalent to just always using the
   // target (confirmed or not) from the block.
   nsRefPtr<AsyncPanZoomController> target = block->GetTargetApzc();
 
   if (!MaybeHandleCurrentBlock(target, block, aEvent)) {
     block->AddEvent(aEvent.AsScrollWheelInput());
   }
 
-  return nsEventStatus_eIgnore;
+  return nsEventStatus_eConsumeDoDefault;
 }
 
 void
 InputQueue::CancelAnimationsForNewBlock(CancelableBlockState* aBlock)
 {
   // We want to cancel animations here as soon as possible (i.e. without waiting for
   // content responses) because a finger has gone down and we don't want to keep moving
   // the content under the finger. However, to prevent "future" touchstart events from
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -182,16 +182,17 @@
 
 #include <d3d11.h>
 
 #if !defined(SM_CONVERTIBLESLATEMODE)
 #define SM_CONVERTIBLESLATEMODE 0x2003
 #endif
 
 #include "mozilla/layers/APZCTreeManager.h"
+#include "mozilla/layers/InputAPZContext.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 using namespace mozilla::layers;
 using namespace mozilla::widget;
 
 namespace mozilla {
@@ -3736,16 +3737,28 @@ bool nsWindow::DispatchKeyboardEvent(Wid
 {
   nsEventStatus status;
   DispatchEvent(event, status);
   return ConvertStatus(status);
 }
 
 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);
 }
 
 bool nsWindow::DispatchWindowEvent(WidgetGUIEvent* event)
 {
   nsEventStatus status;