Bug 960565 - Reset touch counter with every touch start event. r=kats, a=bajaj
authorDmitry Rozhkov <dmitry.rozhkov@jolla.com>
Wed, 22 Jan 2014 16:06:35 +0200
changeset 175045 0d3f6deebf430ba0a3432c176dd0537713f42d5d
parent 175044 20e10d9d645f776ff11c268fd70b9b0826191b5d
child 175046 9bf1936426efc9e3d4940e74a0ea710878fd3bf2
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats, bajaj
bugs960565
milestone28.0a2
Bug 960565 - Reset touch counter with every touch start event. r=kats, a=bajaj
gfx/layers/composite/APZCTreeManager.cpp
--- a/gfx/layers/composite/APZCTreeManager.cpp
+++ b/gfx/layers/composite/APZCTreeManager.cpp
@@ -283,17 +283,19 @@ APZCTreeManager::ReceiveInputEvent(const
 {
   nsEventStatus result = nsEventStatus_eIgnore;
   gfx3DMatrix transformToApzc;
   gfx3DMatrix transformToGecko;
   switch (aEvent.mInputType) {
     case MULTITOUCH_INPUT: {
       const MultiTouchInput& multiTouchInput = aEvent.AsMultiTouchInput();
       if (multiTouchInput.mType == MultiTouchInput::MULTITOUCH_START) {
-        mTouchCount++;
+        // MULTITOUCH_START input contains all active touches of the current
+        // session thus resetting mTouchCount.
+        mTouchCount = multiTouchInput.mTouches.Length();
         mApzcForInputBlock = GetTargetAPZC(ScreenPoint(multiTouchInput.mTouches[0].mScreenPoint));
         if (multiTouchInput.mTouches.Length() == 1) {
           // If we have one touch point, this might be the start of a pan.
           // Prepare for possible overscroll handoff.
           BuildOverscrollHandoffChain(mApzcForInputBlock);
         }
         for (size_t i = 1; i < multiTouchInput.mTouches.Length(); i++) {
           nsRefPtr<AsyncPanZoomController> apzc2 = GetTargetAPZC(ScreenPoint(multiTouchInput.mTouches[i].mScreenPoint));
@@ -323,16 +325,17 @@ APZCTreeManager::ReceiveInputEvent(const
         for (size_t i = 0; i < inputForApzc.mTouches.Length(); i++) {
           ApplyTransform(&(inputForApzc.mTouches[i].mScreenPoint), transformToApzc);
         }
         result = mApzcForInputBlock->ReceiveInputEvent(inputForApzc);
       }
       if (multiTouchInput.mType == MultiTouchInput::MULTITOUCH_CANCEL ||
           multiTouchInput.mType == MultiTouchInput::MULTITOUCH_END) {
         if (mTouchCount >= multiTouchInput.mTouches.Length()) {
+          // MULTITOUCH_END input contains only released touches thus decrementing.
           mTouchCount -= multiTouchInput.mTouches.Length();
         } else {
           NS_WARNING("Got an unexpected touchend/touchcancel");
           mTouchCount = 0;
         }
         // If we have an mApzcForInputBlock and it's the end of the touch sequence
         // then null it out so we don't keep a dangling reference and leak things.
         if (mTouchCount == 0) {
@@ -409,17 +412,19 @@ APZCTreeManager::ProcessTouchEvent(const
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsEventStatus ret = nsEventStatus_eIgnore;
   if (!aEvent.touches.Length()) {
     return ret;
   }
   if (aEvent.message == NS_TOUCH_START) {
-    mTouchCount++;
+    // NS_TOUCH_START event contains all active touches of the current
+    // session thus resetting mTouchCount.
+    mTouchCount = aEvent.touches.Length();
     ScreenPoint point = ScreenPoint(aEvent.touches[0]->mRefPoint.x, aEvent.touches[0]->mRefPoint.y);
     mApzcForInputBlock = GetTouchInputBlockAPZC(aEvent, point);
   }
 
   if (mApzcForInputBlock) {
     mApzcForInputBlock->GetGuid(aOutTargetGuid);
     // For computing the input for the APZC, used the cached transform.
     // This ensures that the sequence of touch points an APZC sees in an
@@ -441,16 +446,17 @@ APZCTreeManager::ProcessTouchEvent(const
       ApplyTransform(&(aOutEvent->touches[i]->mRefPoint), outTransform);
     }
   }
   // If we have an mApzcForInputBlock and it's the end of the touch sequence
   // then null it out so we don't keep a dangling reference and leak things.
   if (aEvent.message == NS_TOUCH_CANCEL ||
       aEvent.message == NS_TOUCH_END) {
     if (mTouchCount >= aEvent.touches.Length()) {
+      // NS_TOUCH_END event contains only released touches thus decrementing.
       mTouchCount -= aEvent.touches.Length();
     } else {
       NS_WARNING("Got an unexpected touchend/touchcancel");
       mTouchCount = 0;
     }
     if (mTouchCount == 0) {
       mApzcForInputBlock = nullptr;
       mOverscrollHandoffChain.clear();