Bug 832159 - Move internal part of InputData (nsEvent conversion) out from the header. r=drs, r=smaug
authorOleg Romashin <romaxa@gmail.com>
Wed, 23 Jan 2013 18:30:48 -0500
changeset 130196 ffa079b50b2047b62f4113eb70c4ae7f01341e5f
parent 130195 8568e6577a090644988313ae771af37b021839b1
child 130197 5d86a744800a3460d6d56cc33645b1f66ecc905c
push id317
push userbbajaj@mozilla.com
push dateTue, 07 May 2013 01:20:33 +0000
treeherdermozilla-release@159a10910249 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdrs, smaug
bugs832159
milestone21.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 832159 - Move internal part of InputData (nsEvent conversion) out from the header. r=drs, r=smaug
widget/InputData.h
widget/xpwidgets/InputData.cpp
widget/xpwidgets/Makefile.in
--- a/widget/InputData.h
+++ b/widget/InputData.h
@@ -1,20 +1,22 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #ifndef InputData_h__
 #define InputData_h__
 
-#include "nsGUIEvent.h"
-#include "nsDOMTouchEvent.h"
 #include "nsDebug.h"
+#include "nsPoint.h"
+#include "nsTArray.h"
 
+class nsTouchEvent;
+class nsMouseEvent;
 namespace mozilla {
 
 
 enum InputType
 {
   MULTITOUCH_INPUT,
   PINCHGESTURE_INPUT,
   TAPGESTURE_INPUT
@@ -45,16 +47,20 @@ public:
   // TimeStamp because it is easier to convert from nsInputEvent. The time is
   // platform-specific but it in the case of B2G and Fennec it is since startup.
   uint32_t mTime;
 
   INPUTDATA_AS_CHILD_TYPE(MultiTouchInput, MULTITOUCH_INPUT)
   INPUTDATA_AS_CHILD_TYPE(PinchGestureInput, PINCHGESTURE_INPUT)
   INPUTDATA_AS_CHILD_TYPE(TapGestureInput, TAPGESTURE_INPUT)
 
+  InputData()
+  {
+  }
+
 protected:
   InputData(InputType aInputType, uint32_t aTime)
     : mInputType(aInputType),
       mTime(aTime)
   {
 
 
   }
@@ -88,16 +94,20 @@ public:
       mRadius(aRadius),
       mRotationAngle(aRotationAngle),
       mForce(aForce)
   {
 
 
   }
 
+  SingleTouchData()
+  {
+  }
+
   // A unique number assigned to each SingleTouchData within a MultiTouchInput so
   // that they can be easily distinguished when handling a touch start/move/end.
   int32_t mIdentifier;
 
   // Point on the screen that the touch hit, in device pixels. They are
   // coordinates on the screen.
   nsIntPoint mScreenPoint;
 
@@ -139,107 +149,29 @@ public:
   MultiTouchInput(MultiTouchType aType, uint32_t aTime)
     : InputData(MULTITOUCH_INPUT, aTime),
       mType(aType)
   {
 
 
   }
 
-  MultiTouchInput(const nsTouchEvent& aTouchEvent)
-    : InputData(MULTITOUCH_INPUT, aTouchEvent.time)
+  MultiTouchInput()
   {
-    NS_ABORT_IF_FALSE(NS_IsMainThread(),
-                      "Can only copy from nsTouchEvent on main thread");
+  }
 
-    switch (aTouchEvent.message) {
-      case NS_TOUCH_START:
-        mType = MULTITOUCH_START;
-        break;
-      case NS_TOUCH_MOVE:
-        mType = MULTITOUCH_MOVE;
-        break;
-      case NS_TOUCH_END:
-        mType = MULTITOUCH_END;
-        break;
-      case NS_TOUCH_ENTER:
-        mType = MULTITOUCH_ENTER;
-        break;
-      case NS_TOUCH_LEAVE:
-        mType = MULTITOUCH_LEAVE;
-        break;
-      case NS_TOUCH_CANCEL:
-        mType = MULTITOUCH_CANCEL;
-        break;
-      default:
-        NS_WARNING("Did not assign a type to a MultiTouchInput");
-        break;
-    }
-
-    for (size_t i = 0; i < aTouchEvent.touches.Length(); i++) {
-      nsDOMTouch* domTouch = (nsDOMTouch*)(aTouchEvent.touches[i].get());
-
-      // Extract data from weird interfaces.
-      int32_t identifier, radiusX, radiusY;
-      float rotationAngle, force;
-      domTouch->GetIdentifier(&identifier);
-      domTouch->GetRadiusX(&radiusX);
-      domTouch->GetRadiusY(&radiusY);
-      domTouch->GetRotationAngle(&rotationAngle);
-      domTouch->GetForce(&force);
-
-      SingleTouchData data(identifier,
-                           domTouch->mRefPoint,
-                           nsIntPoint(radiusX, radiusY),
-                           rotationAngle,
-                           force);
-
-      mTouches.AppendElement(data);
-    }
-  }
+  MultiTouchInput(const nsTouchEvent& aTouchEvent);
 
   // This conversion from nsMouseEvent to MultiTouchInput is needed because on
   // the B2G emulator we can only receive mouse events, but we need to be able
   // to pan correctly. To do this, we convert the events into a format that the
   // panning code can handle. This code is very limited and only supports
   // SingleTouchData. It also sends garbage for the identifier, radius, force
   // and rotation angle.
-  MultiTouchInput(const nsMouseEvent& aMouseEvent)
-    : InputData(MULTITOUCH_INPUT, aMouseEvent.time)
-  {
-    NS_ABORT_IF_FALSE(NS_IsMainThread(),
-                      "Can only copy from nsMouseEvent on main thread");
-    switch (aMouseEvent.message) {
-    case NS_MOUSE_BUTTON_DOWN:
-      mType = MULTITOUCH_START;
-      break;
-    case NS_MOUSE_MOVE:
-      mType = MULTITOUCH_MOVE;
-      break;
-    case NS_MOUSE_BUTTON_UP:
-      mType = MULTITOUCH_END;
-      break;
-    // The mouse pointer has been interrupted in an implementation-specific
-    // manner, such as a synchronous event or action cancelling the touch, or a
-    // touch point leaving the document window and going into a non-document
-    // area capable of handling user interactions.
-    case NS_MOUSE_EXIT:
-      mType = MULTITOUCH_CANCEL;
-      break;
-    default:
-      NS_WARNING("Did not assign a type to a MultiTouchInput");
-      break;
-    }
-
-    mTouches.AppendElement(SingleTouchData(0,
-                                           aMouseEvent.refPoint,
-                                           nsIntPoint(1, 1),
-                                           180.0f,
-                                           1.0f));
-  }
+  MultiTouchInput(const nsMouseEvent& aMouseEvent);
 
   MultiTouchType mType;
   nsTArray<SingleTouchData> mTouches;
 };
 
 /**
  * Encapsulation class for pinch events. In general, these will be generated by
  * a gesture listener by looking at SingleTouchData/MultiTouchInput instances and
new file mode 100644
--- /dev/null
+++ b/widget/xpwidgets/InputData.cpp
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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 "InputData.h"
+
+#include "nsGUIEvent.h"
+#include "nsDOMTouchEvent.h"
+#include "nsDebug.h"
+
+namespace mozilla {
+
+MultiTouchInput::MultiTouchInput(const nsTouchEvent& aTouchEvent)
+  : InputData(MULTITOUCH_INPUT, aTouchEvent.time)
+{
+  NS_ABORT_IF_FALSE(NS_IsMainThread(),
+                    "Can only copy from nsTouchEvent on main thread");
+
+  switch (aTouchEvent.message) {
+    case NS_TOUCH_START:
+      mType = MULTITOUCH_START;
+      break;
+    case NS_TOUCH_MOVE:
+      mType = MULTITOUCH_MOVE;
+      break;
+    case NS_TOUCH_END:
+      mType = MULTITOUCH_END;
+      break;
+    case NS_TOUCH_ENTER:
+      mType = MULTITOUCH_ENTER;
+      break;
+    case NS_TOUCH_LEAVE:
+      mType = MULTITOUCH_LEAVE;
+      break;
+    case NS_TOUCH_CANCEL:
+      mType = MULTITOUCH_CANCEL;
+      break;
+    default:
+      NS_WARNING("Did not assign a type to a MultiTouchInput");
+      break;
+  }
+
+  for (size_t i = 0; i < aTouchEvent.touches.Length(); i++) {
+    nsDOMTouch* domTouch = (nsDOMTouch*)(aTouchEvent.touches[i].get());
+
+    // Extract data from weird interfaces.
+    int32_t identifier, radiusX, radiusY;
+    float rotationAngle, force;
+    domTouch->GetIdentifier(&identifier);
+    domTouch->GetRadiusX(&radiusX);
+    domTouch->GetRadiusY(&radiusY);
+    domTouch->GetRotationAngle(&rotationAngle);
+    domTouch->GetForce(&force);
+
+    SingleTouchData data(identifier,
+                         domTouch->mRefPoint,
+                         nsIntPoint(radiusX, radiusY),
+                         rotationAngle,
+                         force);
+
+    mTouches.AppendElement(data);
+  }
+}
+
+// This conversion from nsMouseEvent to MultiTouchInput is needed because on
+// the B2G emulator we can only receive mouse events, but we need to be able
+// to pan correctly. To do this, we convert the events into a format that the
+// panning code can handle. This code is very limited and only supports
+// SingleTouchData. It also sends garbage for the identifier, radius, force
+// and rotation angle.
+MultiTouchInput::MultiTouchInput(const nsMouseEvent& aMouseEvent)
+  : InputData(MULTITOUCH_INPUT, aMouseEvent.time)
+{
+  NS_ABORT_IF_FALSE(NS_IsMainThread(),
+                    "Can only copy from nsMouseEvent on main thread");
+  switch (aMouseEvent.message) {
+  case NS_MOUSE_BUTTON_DOWN:
+    mType = MULTITOUCH_START;
+    break;
+  case NS_MOUSE_MOVE:
+    mType = MULTITOUCH_MOVE;
+    break;
+  case NS_MOUSE_BUTTON_UP:
+    mType = MULTITOUCH_END;
+    break;
+  // The mouse pointer has been interrupted in an implementation-specific
+  // manner, such as a synchronous event or action cancelling the touch, or a
+  // touch point leaving the document window and going into a non-document
+  // area capable of handling user interactions.
+  case NS_MOUSE_EXIT:
+    mType = MULTITOUCH_CANCEL;
+    break;
+  default:
+    NS_WARNING("Did not assign a type to a MultiTouchInput");
+    break;
+  }
+
+  mTouches.AppendElement(SingleTouchData(0,
+                                         aMouseEvent.refPoint,
+                                         nsIntPoint(1, 1),
+                                         180.0f,
+                                         1.0f));
+}
+}
--- a/widget/xpwidgets/Makefile.in
+++ b/widget/xpwidgets/Makefile.in
@@ -38,16 +38,17 @@ CPPSRCS		= \
 		nsIdleService.cpp \
 		nsClipboardPrivacyHandler.cpp \
 		GfxInfoWebGL.cpp \
                 GfxDriverInfo.cpp \
                 GfxInfoBase.cpp \
 		PuppetWidget.cpp \
 		nsFilePickerProxy.cpp \
 		WidgetUtils.cpp \
+		InputData.cpp \
 		$(NULL)
 
 ifdef MOZ_X11
 CPPSRCS		+= \
 		GfxInfoX11.cpp
 endif
 
 ifneq (,$(filter os2 cocoa windows,$(MOZ_WIDGET_TOOLKIT)))