Bug 1144324 - Try to register for, and handle, touch events when APZ is enabled. r=dvander,jimm
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 19 Mar 2015 06:37:38 -0400
changeset 234423 d3dadcb1022670ad8a57d426b8b7b70a9c53400d
parent 234422 01abf38a6a4db728f2603395fcbc2edffca1cc45
child 234424 33c30e283fa806e0917e09b54e7bd0c59a328c0e
push id57131
push userkgupta@mozilla.com
push dateThu, 19 Mar 2015 10:37:59 +0000
treeherdermozilla-inbound@83c5d1c58506 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander, jimm
bugs1144324
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1144324 - Try to register for, and handle, touch events when APZ is enabled. r=dvander,jimm
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -1296,16 +1296,29 @@ void nsWindow::SetThemeRegion()
  *
  * SECTION: nsIWidget::RegisterTouchWindow,
  * nsIWidget::UnregisterTouchWindow, and helper functions
  *
  * Used to register the native window to receive touch events
  *
  **************************************************************/
 
+void nsWindow::ConfigureAPZCTreeManager()
+{
+  nsBaseWidget::ConfigureAPZCTreeManager();
+
+  // When APZ is enabled, we can actually enable raw touch events because we
+  // have code that can deal with them properly. If APZ is not enabled, this
+  // function doesn't get called, and |mGesture| will take care of touch-based
+  // scrolling. Note that RegisterTouchWindow may still do nothing depending
+  // on touch/pointer events prefs, and so it is possible to enable APZ without
+  // also enabling touch support.
+  RegisterTouchWindow();
+}
+
 NS_METHOD nsWindow::RegisterTouchWindow() {
   if (Preferences::GetInt("dom.w3c_touch_events.enabled", 0) ||
       gIsPointerEventsEnabled) {
     mTouchWindow = true;
     mGesture.RegisterTouchWindow(mWnd);
     ::EnumChildWindows(mWnd, nsWindow::RegisterTouchForDescendants, 0);
   }
   return NS_OK;
@@ -6203,23 +6216,23 @@ bool nsWindow::OnTouch(WPARAM wParam, LP
         touchEventToSend->touches.AppendElement(touch);
       } else {
         touchEndEventToSend->touches.AppendElement(touch);
       }
     }
 
     // Dispatch touch start and move event if we have one.
     if (touchEventToSend) {
-      DispatchEvent(touchEventToSend, status);
+      status = DispatchAPZAwareEvent(touchEventToSend);
       delete touchEventToSend;
     }
 
     // Dispatch touch end event if we have one.
     if (touchEndEventToSend) {
-      DispatchEvent(touchEndEventToSend, status);
+      status = DispatchAPZAwareEvent(touchEndEventToSend);
       delete touchEndEventToSend;
     }
   }
 
   delete [] pInputs;
   mGesture.CloseTouchInputHandle((HTOUCHINPUT)lParam);
   return true;
 }
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -279,16 +279,17 @@ public:
   virtual void GetPreferredCompositorBackends(nsTArray<mozilla::layers::LayersBackend>& aHints);
 
   virtual bool ShouldUseOffMainThreadCompositing();
 
 protected:
   virtual ~nsWindow();
 
   virtual void WindowUsesOMTC() MOZ_OVERRIDE;
+  virtual void ConfigureAPZCTreeManager() MOZ_OVERRIDE;
 
   virtual nsresult NotifyIMEInternal(
                      const IMENotification& aIMENotification) MOZ_OVERRIDE;
 
   // A magic number to identify the FAKETRACKPOINTSCROLLABLE window created
   // when the trackpoint hack is enabled.
   enum { eFakeTrackPointScrollableID = 0x46545053 };