Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug 832159 - Move internal part of InputData (nsEvent conversion) out…

… from the header. r=drs, r=smaug
  • Loading branch information...
commit 2243f8d079ba4abc50e144437a4b61360a9bc025 1 parent ad18556
@romaxa romaxa authored
View
100 widget/InputData.h
@@ -6,10 +6,12 @@
#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 {
@@ -50,6 +52,10 @@ class InputData
INPUTDATA_AS_CHILD_TYPE(PinchGestureInput, PINCHGESTURE_INPUT)
INPUTDATA_AS_CHILD_TYPE(TapGestureInput, TAPGESTURE_INPUT)
+ InputData()
+ {
+ }
+
protected:
InputData(InputType aInputType, uint32_t aTime)
: mInputType(aInputType),
@@ -93,6 +99,10 @@ class SingleTouchData
}
+ 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;
@@ -144,97 +154,19 @@ class MultiTouchInput : public InputData
}
- 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;
View
105 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));
+}
+}
View
1  widget/xpwidgets/Makefile.in
@@ -43,6 +43,7 @@ CPPSRCS = \
PuppetWidget.cpp \
nsFilePickerProxy.cpp \
WidgetUtils.cpp \
+ InputData.cpp \
$(NULL)
ifdef MOZ_X11
Please sign in to comment.
Something went wrong with that request. Please try again.