Bug 1525570 - Move TouchCounter to apz/util/ and allow counting WidgetTouchEvent too. r=botond
☠☠ backed out by 48b049ff10f1 ☠ ☠
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 01 Mar 2019 20:17:58 +0000
changeset 519873 cd326f5e4eb883c0daa8dd5022c99fc886dda9bf
parent 519872 d5c0cad448f90eae7cf255f9a5e5ce45bbc0b299
child 519874 77625f533af6a3628ad4203530dbe1b4526aceb6
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1525570
milestone67.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 1525570 - Move TouchCounter to apz/util/ and allow counting WidgetTouchEvent too. r=botond Differential Revision: https://phabricator.services.mozilla.com/D21577
gfx/layers/apz/src/APZCTreeManager.h
gfx/layers/apz/src/InputBlockState.h
gfx/layers/apz/src/InputQueue.h
gfx/layers/apz/src/TouchCounter.cpp
gfx/layers/apz/src/TouchCounter.h
gfx/layers/apz/util/TouchCounter.cpp
gfx/layers/apz/util/TouchCounter.h
gfx/layers/moz.build
--- a/gfx/layers/apz/src/APZCTreeManager.h
+++ b/gfx/layers/apz/src/APZCTreeManager.h
@@ -15,22 +15,22 @@
 #include "mozilla/gfx/CompositorHitTestInfo.h"
 #include "mozilla/gfx/Logging.h"              // for gfx::TreeLog
 #include "mozilla/gfx/Matrix.h"               // for Matrix4x4
 #include "mozilla/layers/APZInputBridge.h"    // for APZInputBridge
 #include "mozilla/layers/APZTestData.h"       // for APZTestData
 #include "mozilla/layers/IAPZCTreeManager.h"  // for IAPZCTreeManager
 #include "mozilla/layers/LayersTypes.h"
 #include "mozilla/layers/KeyboardMap.h"  // for KeyboardMap
+#include "mozilla/layers/TouchCounter.h" // for TouchCounter
 #include "mozilla/RecursiveMutex.h"      // for RecursiveMutex
 #include "mozilla/RefPtr.h"              // for RefPtr
 #include "mozilla/TimeStamp.h"           // for mozilla::TimeStamp
 #include "mozilla/UniquePtr.h"           // for UniquePtr
 #include "nsCOMPtr.h"                    // for already_AddRefed
-#include "TouchCounter.h"                // for TouchCounter
 
 #if defined(MOZ_WIDGET_ANDROID)
 #  include "mozilla/layers/AndroidDynamicToolbarAnimator.h"
 #endif  // defined(MOZ_WIDGET_ANDROID)
 
 namespace mozilla {
 class MultiTouchInput;
 
--- a/gfx/layers/apz/src/InputBlockState.h
+++ b/gfx/layers/apz/src/InputBlockState.h
@@ -9,19 +9,19 @@
 
 #include "InputData.h"           // for MultiTouchInput
 #include "mozilla/RefCounted.h"  // for RefCounted
 #include "mozilla/RefPtr.h"      // for RefPtr
 #include "mozilla/gfx/Matrix.h"  // for Matrix4x4
 #include "mozilla/layers/APZUtils.h"
 #include "mozilla/layers/LayersTypes.h"  // for TouchBehaviorFlags
 #include "mozilla/layers/AsyncDragMetrics.h"
+#include "mozilla/layers/TouchCounter.h"
 #include "mozilla/TimeStamp.h"  // for TimeStamp
 #include "nsTArray.h"           // for nsTArray
-#include "TouchCounter.h"
 
 namespace mozilla {
 namespace layers {
 
 class AsyncPanZoomController;
 class OverscrollHandoffChain;
 class CancelableBlockState;
 class TouchBlockState;
--- a/gfx/layers/apz/src/InputQueue.h
+++ b/gfx/layers/apz/src/InputQueue.h
@@ -6,20 +6,20 @@
 
 #ifndef mozilla_layers_InputQueue_h
 #define mozilla_layers_InputQueue_h
 
 #include "APZUtils.h"
 #include "DragTracker.h"
 #include "InputData.h"
 #include "mozilla/EventForwards.h"
+#include "mozilla/layers/TouchCounter.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/UniquePtr.h"
 #include "nsTArray.h"
-#include "TouchCounter.h"
 
 namespace mozilla {
 
 class InputData;
 class MultiTouchInput;
 class ScrollWheelInput;
 
 namespace layers {
rename from gfx/layers/apz/src/TouchCounter.cpp
rename to gfx/layers/apz/util/TouchCounter.cpp
--- a/gfx/layers/apz/src/TouchCounter.cpp
+++ b/gfx/layers/apz/util/TouchCounter.cpp
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "TouchCounter.h"
 
 #include "InputData.h"
+#include "mozilla/TouchEvents.h"
 
 namespace mozilla {
 namespace layers {
 
 TouchCounter::TouchCounter() : mActiveTouchCount(0) {}
 
 void TouchCounter::Update(const MultiTouchInput& aInput) {
   switch (aInput.mType) {
@@ -19,24 +20,47 @@ void TouchCounter::Update(const MultiTou
       // touch-start event contains all active touches of the current session
       mActiveTouchCount = aInput.mTouches.Length();
       break;
     case MultiTouchInput::MULTITOUCH_END:
       if (mActiveTouchCount >= aInput.mTouches.Length()) {
         // touch-end event contains only released touches
         mActiveTouchCount -= aInput.mTouches.Length();
       } else {
-        NS_WARNING("Got an unexpected touchend/touchcancel");
+        NS_WARNING("Got an unexpected touchend");
         mActiveTouchCount = 0;
       }
       break;
     case MultiTouchInput::MULTITOUCH_CANCEL:
       mActiveTouchCount = 0;
       break;
     case MultiTouchInput::MULTITOUCH_MOVE:
       break;
   }
 }
 
+void TouchCounter::Update(const WidgetTouchEvent& aEvent) {
+  switch (aEvent.mMessage) {
+    case eTouchStart:
+      // touch-start event contains all active touches of the current session
+      mActiveTouchCount = aEvent.mTouches.Length();
+      break;
+    case eTouchEnd:
+      if (mActiveTouchCount >= aEvent.mTouches.Length()) {
+        // touch-end event contains only released touches
+        mActiveTouchCount -= aEvent.mTouches.Length();
+      } else {
+        NS_WARNING("Got an unexpected touchend");
+        mActiveTouchCount = 0;
+      }
+      break;
+    case eTouchCancel:
+      mActiveTouchCount = 0;
+      break;
+    default:
+      break;
+  }
+}
+
 uint32_t TouchCounter::GetActiveTouchCount() const { return mActiveTouchCount; }
 
 }  // namespace layers
 }  // namespace mozilla
rename from gfx/layers/apz/src/TouchCounter.h
rename to gfx/layers/apz/util/TouchCounter.h
--- a/gfx/layers/apz/src/TouchCounter.h
+++ b/gfx/layers/apz/util/TouchCounter.h
@@ -11,21 +11,24 @@
 
 namespace mozilla {
 
 class MultiTouchInput;
 
 namespace layers {
 
 // TouchCounter simply tracks the number of active touch points. Feed it
-// your input events to update the internal state.
+// your input events to update the internal state. Generally you should
+// only be calling one of the Update functions, depending on which type
+// of touch inputs you have access to.
 class TouchCounter {
  public:
   TouchCounter();
   void Update(const MultiTouchInput& aInput);
+  void Update(const WidgetTouchEvent& aEvent);
   uint32_t GetActiveTouchCount() const;
 
  private:
   uint32_t mActiveTouchCount;
 };
 
 }  // namespace layers
 }  // namespace mozilla
--- a/gfx/layers/moz.build
+++ b/gfx/layers/moz.build
@@ -113,16 +113,17 @@ EXPORTS.mozilla.layers += [
     'apz/util/APZEventState.h',
     'apz/util/APZThreadUtils.h',
     'apz/util/ChromeProcessController.h',
     'apz/util/ContentProcessController.h',
     'apz/util/DoubleTapToZoom.h',
     'apz/util/InputAPZContext.h',
     'apz/util/ScrollLinkedEffectDetector.h',
     'apz/util/TouchActionHelper.h',
+    'apz/util/TouchCounter.h',
     'AsyncCanvasRenderer.h',
     'AtomicRefCountedWithFinalize.h',
     'AxisPhysicsModel.h',
     'AxisPhysicsMSDModel.h',
     'basic/BasicCompositor.h',
     'basic/MacIOSurfaceTextureHostBasic.h',
     'basic/TextureHostBasic.h',
     'BSPTree.h',
@@ -331,30 +332,30 @@ UNIFIED_SOURCES += [
     'apz/src/InputQueue.cpp',
     'apz/src/KeyboardMap.cpp',
     'apz/src/KeyboardScrollAction.cpp',
     'apz/src/KeyboardScrollAnimation.cpp',
     'apz/src/OverscrollHandoffState.cpp',
     'apz/src/PotentialCheckerboardDurationTracker.cpp',
     'apz/src/QueuedInput.cpp',
     'apz/src/SimpleVelocityTracker.cpp',
-    'apz/src/TouchCounter.cpp',
     'apz/src/WheelScrollAnimation.cpp',
     'apz/testutil/APZTestData.cpp',
     'apz/util/ActiveElementManager.cpp',
     'apz/util/APZCCallbackHelper.cpp',
     'apz/util/APZEventState.cpp',
     'apz/util/APZThreadUtils.cpp',
     'apz/util/CheckerboardReportService.cpp',
     'apz/util/ChromeProcessController.cpp',
     'apz/util/ContentProcessController.cpp',
     'apz/util/DoubleTapToZoom.cpp',
     'apz/util/InputAPZContext.cpp',
     'apz/util/ScrollLinkedEffectDetector.cpp',
     'apz/util/TouchActionHelper.cpp',
+    'apz/util/TouchCounter.cpp',
     'AsyncCanvasRenderer.cpp',
     'AxisPhysicsModel.cpp',
     'AxisPhysicsMSDModel.cpp',
     'basic/BasicCanvasLayer.cpp',
     'basic/BasicColorLayer.cpp',
     'basic/BasicCompositor.cpp',
     'basic/BasicContainerLayer.cpp',
     'basic/BasicImages.cpp',