Bug 1016035 - Put PanGestureInput events into a queue if they can end up as a swipe. r=kats
authorMarkus Stange <mstange@themasta.com>
Wed, 12 Aug 2015 00:15:32 -0400
changeset 292584 5eab0486d697d0c3971f499208ffd5af8e1a49a5
parent 292583 e3ac3f09448389bb62e8052e26b07f82cc26a80e
child 292585 b88fbd7853b61b374746f983332cd0e56f96a117
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1016035
milestone43.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 1016035 - Put PanGestureInput events into a queue if they can end up as a swipe. r=kats
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -40,16 +40,17 @@ namespace {
 class GLPresenter;
 class RectTextureImage;
 } // namespace
 
 namespace mozilla {
 class InputData;
 class PanGestureInput;
 class SwipeTracker;
+struct SwipeEventQueue;
 class VibrancyManager;
 namespace layers {
 class GLManager;
 class APZCTreeManager;
 } // namespace layers
 } // namespace mozilla
 
 @interface NSEvent (Undocumented)
@@ -667,15 +668,16 @@ protected:
   bool mPluginFocused;
 
   // Used in OMTC BasicLayers mode. Presents the BasicCompositor result
   // surface to the screen using an OpenGL context.
   nsAutoPtr<GLPresenter> mGLPresenter;
 
   mozilla::UniquePtr<mozilla::VibrancyManager> mVibrancyManager;
   nsRefPtr<mozilla::SwipeTracker> mSwipeTracker;
+  mozilla::UniquePtr<mozilla::SwipeEventQueue> mSwipeEventQueue;
 
   static uint32_t sLastInputEventCount;
 
   void ReleaseTitlebarCGContext();
 };
 
 #endif // nsChildView_h_
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -368,16 +368,31 @@ protected:
   nsRefPtr<mozilla::gl::GLContext> mGLContext;
   nsAutoPtr<mozilla::layers::ShaderProgramOGL> mRGBARectProgram;
   gfx::Matrix4x4 mProjMatrix;
   GLuint mQuadVBO;
 };
 
 } // unnamed namespace
 
+namespace mozilla {
+
+struct SwipeEventQueue {
+  SwipeEventQueue(uint32_t aAllowedDirections, uint64_t aInputBlockId)
+    : allowedDirections(aAllowedDirections)
+    , inputBlockId(aInputBlockId)
+  {}
+
+  nsTArray<PanGestureInput> queuedEvents;
+  uint32_t allowedDirections;
+  uint64_t inputBlockId;
+};
+
+} // namespace mozilla
+
 #pragma mark -
 
 nsChildView::nsChildView() : nsBaseWidget()
 , mView(nullptr)
 , mParentView(nullptr)
 , mParentWidget(nullptr)
 , mViewTearDownLock("ChildViewTearDown")
 , mEffectsLock("WidgetEffects")
@@ -2739,16 +2754,24 @@ nsChildView::DispatchAPZWheelInputEvent(
     switch(aEvent.mInputType) {
       case PANGESTURE_INPUT: {
         PanGestureInput& panInput = aEvent.AsPanGestureInput();
 
         event = panInput.ToWidgetWheelEvent(this);
         if (aCanTriggerSwipe) {
           SwipeInfo swipeInfo = SendMayStartSwipe(panInput);
           event.mCanTriggerSwipe = swipeInfo.wantsSwipe;
+          if (swipeInfo.wantsSwipe) {
+            mSwipeEventQueue = MakeUnique<SwipeEventQueue>(swipeInfo.allowedDirections,
+                                                           inputBlockId);
+          }
+        }
+
+        if (mSwipeEventQueue && mSwipeEventQueue->inputBlockId == inputBlockId) {
+          mSwipeEventQueue->queuedEvents.AppendElement(panInput);
         }
         break;
       }
       case SCROLLWHEEL_INPUT: {
         event = aEvent.AsScrollWheelInput().ToWidgetWheelEvent(this);
         break;
       };
       default: