Bug 988110 - check the event index in action to make sure we have correct mTouchDownCount. r=gal
authorViral Wang <vwang@mozilla.com>
Wed, 09 Apr 2014 20:24:00 +0200
changeset 196405 0db1de4da2ee76fc2036657a7b1394a282564e77
parent 196356 901d300bb4418d4a8e6b41dedfbadceb619214f7
child 196406 c9b8283fd770103b8b7824d262683aab203aa1af
push idunknown
push userunknown
push dateunknown
reviewersgal
bugs988110
milestone31.0a1
Bug 988110 - check the event index in action to make sure we have correct mTouchDownCount. r=gal
widget/gonk/nsAppShell.cpp
--- a/widget/gonk/nsAppShell.cpp
+++ b/widget/gonk/nsAppShell.cpp
@@ -24,16 +24,17 @@
 #include <fcntl.h>
 #include <signal.h>
 #include <sys/epoll.h>
 #include <sys/ioctl.h>
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <utils/BitSet.h>
 
 #include "base/basictypes.h"
 #include "GonkPermission.h"
 #include "nscore.h"
 #ifdef MOZ_OMX_DECODER
 #include "MediaResourceManagerService.h"
 #endif
 #include "mozilla/TouchEvents.h"
@@ -616,16 +617,17 @@ private:
     mozilla::Mutex mQueueLock;
     std::queue<UserInputData> mEventQueue;
     sp<EventHub> mEventHub;
 
     int mTouchDownCount;
     int mKeyDownCount;
     bool mTouchEventsFiltered;
     bool mKeyEventsFiltered;
+    BitSet32 mTouchDown;
 };
 
 // GeckoInputReaderPolicy
 void
 GeckoInputReaderPolicy::setDisplayInfo()
 {
     static_assert(nsIScreen::ROTATION_0_DEG ==
                   DISPLAY_ORIENTATION_0,
@@ -693,30 +695,38 @@ GeckoInputDispatcher::dispatchOnce()
     switch (data.type) {
     case UserInputData::MOTION_DATA: {
         if (!mTouchDownCount) {
             // No pending events, the filter state can be updated.
             mTouchEventsFiltered = isExpired(data);
         }
 
         int32_t action = data.action & AMOTION_EVENT_ACTION_MASK;
+        int32_t index = data.action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK;
+        index >>= AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
         switch (action) {
         case AMOTION_EVENT_ACTION_DOWN:
         case AMOTION_EVENT_ACTION_POINTER_DOWN:
-            mTouchDownCount++;
+            if (!mTouchDown.hasBit(index)) {
+                mTouchDown.markBit(index);
+                mTouchDownCount++;
+            }
             break;
         case AMOTION_EVENT_ACTION_MOVE:
         case AMOTION_EVENT_ACTION_HOVER_MOVE:
             // No need to update the count on move.
             break;
         case AMOTION_EVENT_ACTION_UP:
         case AMOTION_EVENT_ACTION_POINTER_UP:
         case AMOTION_EVENT_ACTION_OUTSIDE:
         case AMOTION_EVENT_ACTION_CANCEL:
-            mTouchDownCount--;
+            if (mTouchDown.hasBit(index)) {
+                mTouchDown.clearBit(index);
+                mTouchDownCount--;
+            }
             break;
         default:
             break;
         }
 
         if (mTouchEventsFiltered) {
             return;
         }