Bug 976605 - Have APZ notify GeckoCC on end of touch. r=kats
authorBotond Ballo <botond@mozilla.com>
Tue, 08 Apr 2014 15:41:11 -0400
changeset 197192 3802596aa078a86cb3ec4d03c42a99ca3f232129
parent 197191 14804946cd1349ed47168b4e5090dfed8c6d809f
child 197193 35dd4b9b5caa630367d6919aaedd5ef7ab492e30
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs976605
milestone31.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 976605 - Have APZ notify GeckoCC on end of touch. r=kats
gfx/layers/ipc/AsyncPanZoomController.cpp
gfx/layers/ipc/AsyncPanZoomController.h
gfx/layers/ipc/GeckoContentController.h
--- a/gfx/layers/ipc/AsyncPanZoomController.cpp
+++ b/gfx/layers/ipc/AsyncPanZoomController.cpp
@@ -700,16 +700,18 @@ nsEventStatus AsyncPanZoomController::On
   }
 
   return nsEventStatus_eConsumeNoDefault;
 }
 
 nsEventStatus AsyncPanZoomController::OnTouchEnd(const MultiTouchInput& aEvent) {
   APZC_LOG("%p got a touch-end in state %d\n", this, mState);
 
+  OnTouchEndOrCancel();
+
   // In case no touch behavior triggered previously we can avoid sending
   // scroll events or requesting content repaint. This condition is added
   // to make tests consistent - in case touch-action is NONE (and therefore
   // no pans/zooms can be performed) we expected neither scroll or repaint
   // events.
   if (mState != NOTHING) {
     ReentrantMonitorAutoEnter lock(mMonitor);
     SendAsyncScrollEvent();
@@ -766,16 +768,17 @@ nsEventStatus AsyncPanZoomController::On
     break;
   }
 
   return nsEventStatus_eConsumeNoDefault;
 }
 
 nsEventStatus AsyncPanZoomController::OnTouchCancel(const MultiTouchInput& aEvent) {
   APZC_LOG("%p got a touch-cancel in state %d\n", this, mState);
+  OnTouchEndOrCancel();
   SetState(NOTHING);
   return nsEventStatus_eConsumeNoDefault;
 }
 
 nsEventStatus AsyncPanZoomController::OnScaleBegin(const PinchGestureInput& aEvent) {
   APZC_LOG("%p got a scale-begin in state %d\n", this, mState);
 
   if (!TouchActionAllowZoom()) {
@@ -946,22 +949,28 @@ nsEventStatus AsyncPanZoomController::Ge
       // calling controller->HandleSingleTap directly might mean that content receives
       // the single tap message before the corresponding touch-up. To avoid that we
       // schedule the singletap message to run on the next spin of the event loop.
       // See bug 965381 for the issue this was causing.
       controller->PostDelayedTask(
         NewRunnableMethod(controller.get(), &GeckoContentController::HandleSingleTap,
                           geckoScreenPoint, modifiers, GetGuid()),
         0);
+      mTouchBlockState.mSingleTapOccurred = true;
       return nsEventStatus_eConsumeNoDefault;
     }
   }
   return nsEventStatus_eIgnore;
 }
 
+void AsyncPanZoomController::OnTouchEndOrCancel() {
+  mGeckoContentController->NotifyAPZStateChange(
+      GetGuid(), APZStateChange::EndTouch, mTouchBlockState.mSingleTapOccurred);
+}
+
 nsEventStatus AsyncPanZoomController::OnSingleTapUp(const TapGestureInput& aEvent) {
   APZC_LOG("%p got a single-tap-up in state %d\n", this, mState);
   // If mZoomConstraints.mAllowDoubleTapZoom is true we wait for a call to OnSingleTapConfirmed before
   // sending event to content
   if (!mZoomConstraints.mAllowDoubleTapZoom) {
     return GenerateSingleTap(aEvent.mPoint, aEvent.modifiers);
   }
   return nsEventStatus_eIgnore;
--- a/gfx/layers/ipc/AsyncPanZoomController.h
+++ b/gfx/layers/ipc/AsyncPanZoomController.h
@@ -563,17 +563,18 @@ private:
   };
 
   // State related to a single touch block. Does not persist across touch blocks.
   struct TouchBlockState {
 
     TouchBlockState()
       :  mAllowedTouchBehaviorSet(false),
          mPreventDefault(false),
-         mPreventDefaultSet(false)
+         mPreventDefaultSet(false),
+         mSingleTapOccurred(false)
     {}
 
     // Values of allowed touch behavior for touch points of this touch block.
     // Since there are maybe a few current active touch points per time (multitouch case)
     // and each touch point should have its own value of allowed touch behavior- we're
     // keeping an array of allowed touch behavior values, not the single value.
     nsTArray<TouchBehaviorFlags> mAllowedTouchBehaviors;
 
@@ -581,16 +582,19 @@ private:
     bool mAllowedTouchBehaviorSet;
 
     // Flag used to specify that content prevented the default behavior of this
     // touch events block.
     bool mPreventDefault;
 
     // Specifies whether mPreventDefault property is set for this touch events block.
     bool mPreventDefaultSet;
+
+    // Specifies whether a single tap event was generated during this touch block.
+    bool mSingleTapOccurred;
   };
 
   /*
    * Returns whether current touch behavior values allow zooming.
    */
   bool TouchActionAllowZoom();
 
   /*
@@ -646,16 +650,19 @@ private:
   // Update mFrameMetrics.mTransformScale. This should be called whenever
   // our CSS transform or the non-transient part of our async transform
   // changes, as it corresponds to the scale portion of those transforms.
   void UpdateTransformScale();
 
   // Helper function for OnSingleTapUp() and OnSingleTapConfirmed().
   nsEventStatus GenerateSingleTap(const ScreenIntPoint& aPoint, mozilla::Modifiers aModifiers);
 
+  // Common processing at the end of a touch block.
+  void OnTouchEndOrCancel();
+
   uint64_t mLayersId;
   nsRefPtr<CompositorParent> mCompositorParent;
   PCompositorParent* mCrossProcessCompositorParent;
   TaskThrottler mPaintThrottler;
 
   /* Access to the following two fields is protected by the mRefPtrMonitor,
      since they are accessed on the UI thread but can be cleared on the
      compositor thread. */
--- a/gfx/layers/ipc/GeckoContentController.h
+++ b/gfx/layers/ipc/GeckoContentController.h
@@ -126,16 +126,21 @@ public:
      * APZ started a touch.
      * |aArg| is 1 if touch can be a pan, 0 otherwise.
      */
     StartTouch,
     /**
      * APZ started a pan.
      */
     StartPanning,
+    /**
+     * APZ finished processing a touch.
+     * |aArg| is 1 if touch was a click, 0 otherwise.
+     */
+    EndTouch,
     APZStateChangeSentinel
   MOZ_END_NESTED_ENUM_CLASS(APZStateChange)
 
   /**
    * General notices of APZ state changes for consumers.
    * |aGuid| identifies the APZC originating the state change.
    * |aChange| identifies the type of state change
    * |aArg| is used by some state changes to pass extra information (see